def remove(self, job):
     jobId = job._getJobId()
     # look up the job's priority
     pri = self._jobId2pri.pop(jobId)
     # TODO: this removal is a linear search
     self._pri2jobIds[pri].remove(jobId)
     # remove the job from the main table
     del self._pri2jobId2job[pri][jobId]
     # clean up the job's generator, if any
     job._cleanupGenerator()
     # remove the job's timeslice count
     self._jobId2timeslices.pop(jobId)
     # remove the overflow time
     self._jobId2overflowTime.pop(jobId)
     if len(self._pri2jobId2job[pri]) == 0:
         del self._pri2jobId2job[pri]
         if pri == self._highestPriority:
             if len(self._jobId2pri) > 0:
                 # calculate a new highest priority
                 # TODO: this is not very fast
                 priorities = self._getSortedPriorities()
                 self._highestPriority = priorities[-1]
             else:
                 taskMgr.remove(JobManager.TaskName)
                 self._highestPriority = 0
     self.notify.debug('removed job: %s' % job.getJobName())
Exemple #2
0
    def shutdown(self):
        taskMgr.remove('eventManager')

        # Flush the event queue.  We do this after removing the task
        # since the task removal itself might also fire off an event.
        if self.eventQueue is not None:
            self.eventQueue.clear()
Exemple #3
0
 def prepareForPickle(self):
     self.colTraverser = None     # Traversers are not picklable
     self.defaultBitMask = None   # BitMasks "..."
     # self.grabIntoBitMask = None  # "..."
     self.colHandlerQueue = None  # CollisonHandlerQueue "..."
     self.grabModelNP.removeNode()
     self.grabModelNP = None
     taskMgr.remove('scaleGrabber')
Exemple #4
0
 def disable(self):
     """
     Detaches any existing sounds and removes the update task
     """
     taskMgr.remove("Audio3DManager-updateTask")
     self.detachListener()
     for object in list(self.sound_dict.keys()):
         for sound in self.sound_dict[object]:
             self.detachSound(sound)
Exemple #5
0
 def __removeTask(self):
     # Kill old task(s), including those from a similarly-named but
     # different interval.
     taskName = self.getName() + '-play'
     oldTasks = taskMgr.getTasksNamed(taskName)
     for task in oldTasks:
         if hasattr(task, "interval"):
             task.interval.privInterrupt()
             taskMgr.remove(task)
Exemple #6
0
 def handleM1Up(self):
     """Stop dragging the selected object."""
     taskMgr.remove('mouse1Dragging')
     self.isDragging = False
     self.currTransformOperation = None  # NOTE other references have been added, but no other object references them
     # record the mouse1 operation
     BBGlobalVars.undoHandler.record(self.selected, CommandUndo([self.initialCommandTrgVal],
                                                                 self.selected.setMat, self.selected.getMat(render)))
     messenger.ignore('mouse1-up', self)
 def avatarChoseQuest(self, avId, npc, questId, rewardId, building):
     toon = self.air.doId2do.get(avId)
     if not toon:
         return
     fromNpc = Quests.getQuestFromNpcId(questId)
     toNpc = Quests.getQuestToNpcId(questId)
     toon.addQuest([questId, fromNpc, toNpc, rewardId, 0], 0,
                     recordHistory = 0)
     npc.assignQuest(avId, questId, rewardId, toNpc)
     taskMgr.remove(npc.uniqueName('clearMovie'))
    def setDeferInterval(self, deferInterval):
        """Specifies the minimum amount of time, in seconds, that must
        elapse before generating any two DistributedObjects whose
        class type is marked "deferrable".  Set this to 0 to indicate
        no deferring will occur."""

        self.deferInterval = deferInterval
        self.setHandleCUpdates(self.deferInterval == 0)

        if self.deferredGenerates:
            taskMgr.remove('deferredGenerate')
            taskMgr.doMethodLater(self.deferInterval, self.doDeferredGenerate, 'deferredGenerate')
 def shrink(db):
     db['text2_text'] = 'Hi!'
     taskMgr.remove('shrink')
     taskMgr.remove('expand')
     # Get a handle on the geometry for the rollover state
     rolloverSmiley = db.component('geom2')
     rolloverSmiley.setScale(db.component('geom0').getScale()[0])
     rolloverSmiley.lerpScale(.1,
                              .1,
                              .1,
                              1.0,
                              blendType='easeInOut',
                              task='shrink')
Exemple #10
0
 def destroy(self):
     if hasattr(self, '_leakTaskName'):
         taskMgr.remove(self._leakTaskName)
         for leaker in self._leakers:
             leaker.ignoreAll()
         self._leakers = None
     if self._createJob:
         self._createJob.destroy()
     self._createJob = None
     for typeName, detector in self._typeName2detector.items():
         detector.destroy()
     del self._typeName2detector
     LeakDetector.destroy(self)
Exemple #11
0
 def editStart(self, event):
     taskMgr.remove('guiEditTask')
     vWidget2render2d = self.getPos(ShowBaseGlobal.render2d)
     vMouse2render2d = Point3(event.getMouse()[0], 0, event.getMouse()[1])
     editVec = Vec3(vWidget2render2d - vMouse2render2d)
     if base.mouseWatcherNode.getModifierButtons().isDown(
             KeyboardButton.control()):
         t = taskMgr.add(self.guiScaleTask, 'guiEditTask')
         t.refPos = vWidget2render2d
         t.editVecLen = editVec.length()
         t.initScale = self.getScale()
     else:
         t = taskMgr.add(self.guiDragTask, 'guiEditTask')
         t.editVec = editVec
 def startSmooth(self):
     """
     This function starts the task that ensures the node is
     positioned correctly every frame.  However, while the task is
     running, you won't be able to lerp the node or directly
     position it.
     """
     if not self.wantsSmoothing() or self.isDisabled() or self.isLocal():
         return
     if not self.smoothStarted:
         taskName = self.taskName("smooth")
         taskMgr.remove(taskName)
         self.reloadPosition()
         taskMgr.add(self.doSmoothTask, taskName)
         self.smoothStarted = 1
Exemple #13
0
def remove_task():
    if MotionTrail.task_added:
        total_motion_trails = len(MotionTrail.motion_trail_list)

        if total_motion_trails > 0:
            print(
                "warning: %d motion trails still exist when motion trail task is removed"
                % (total_motion_trails))

        MotionTrail.motion_trail_list = []

        taskMgr.remove(MotionTrail.motion_trail_task_name)

        print("MotionTrail task removed")

        MotionTrail.task_added = False
Exemple #14
0
    def abortRequest(self, tuple):
        """
        Aborts a previous request.  The parameter is the return value
        from a previous call to requestObjects().  The pending request
        is removed from the queue and no further callbacks will be called.

        See Also: requestObjects()
        """
        if tuple:
            allCallback, eachCallback, timeoutCallback, doIdsPending, doIdList, doLaterName = tuple
            assert self.notify.debug(
                "aborting request for %s (remaining: %s)" %
                (doIdList, doIdsPending))

            if doLaterName:
                taskMgr.remove(doLaterName)
            self.__removePending(tuple, doIdsPending)
Exemple #15
0
 def remove(self, job):
     jobId = job._getJobId()
     pri = self._jobId2pri.pop(jobId)
     self._pri2jobIds[pri].remove(jobId)
     del self._pri2jobId2job[pri][jobId]
     job._cleanupGenerator()
     self._jobId2timeslices.pop(jobId)
     self._jobId2overflowTime.pop(jobId)
     if len(self._pri2jobId2job[pri]) == 0:
         del self._pri2jobId2job[pri]
         if pri == self._highestPriority:
             if len(self._jobId2pri) > 0:
                 priorities = self._getSortedPriorities()
                 self._highestPriority = priorities[-1]
             else:
                 taskMgr.remove(JobManager.TaskName)
                 self._highestPriority = 0
     self.notify.debug('removed job: %s' % job.getJobName())
 def remove(self, job):
     jobId = job._getJobId()
     pri = self._jobId2pri.pop(jobId)
     self._pri2jobIds[pri].remove(jobId)
     del self._pri2jobId2job[pri][jobId]
     job._cleanupGenerator()
     self._jobId2timeslices.pop(jobId)
     self._jobId2overflowTime.pop(jobId)
     if len(self._pri2jobId2job[pri]) == 0:
         del self._pri2jobId2job[pri]
         if pri == self._highestPriority:
             if len(self._jobId2pri) > 0:
                 priorities = self._getSortedPriorities()
                 self._highestPriority = priorities[-1]
             else:
                 taskMgr.remove(JobManager.TaskName)
                 self._highestPriority = 0
     self.notify.debug('removed job: %s' % job.getJobName())
Exemple #17
0
def remove_task():
    if MotionTrail.task_added:
        total_motion_trails = len(MotionTrail.motion_trail_list)

        if total_motion_trails > 0:
            if __debug__:
                warnings.warn(
                    "%d motion trails still exist when motion trail task is removed"
                    % (total_motion_trails),
                    RuntimeWarning,
                    stacklevel=2)

        MotionTrail.motion_trail_list = []

        taskMgr.remove(MotionTrail.motion_trail_task_name)

        print("MotionTrail task removed")

        MotionTrail.task_added = False
Exemple #18
0
    def abortAllRequests(self):
        """
        Call this method to abruptly abort all pending requests, but
        leave the RelatedObjectMgr in a state for accepting more
        requests.
        """

        # Stop listening for all events.
        self.ignoreAll()

        # Iterate through all the pendingObjects and stop any pending
        # tasks.
        for pendingList in self.pendingObjects.values():
            for tuple in pendingList:
                allCallback, eachCallback, timeoutCallback, doIdsPending, doIdList, doLaterName = tuple
                if doLaterName:
                    taskMgr.remove(doLaterName)

        self.pendingObjects = {}
Exemple #19
0
    def cleanup(self):
        if not self.cleanedUp:
            self.cleanedUp = True

            # Remove the window.
            base.graphicsEngine.removeWindow(self.win)
            self.win = None
            self.gsg = None
            self.pipe = None

            # Remove the mouse.
            self.mouse.detachNode()

            taskMgr.remove(self.task)
            self.ignoreAll()

            self.canvas.getChildren().detach()
            self.texRecordsByTex = {}
            self.texRecordsByKey = {}
            self.texPlacements = {}
Exemple #20
0
    def startPosHprBroadcast(self, period=.2, stagger=0, type=None):
        if self.cnode is None:
            self.initializeCnode()

        BT = DistributedSmoothNodeBase.BroadcastTypes
        if type is None:
            type = BT.FULL
        # set the broadcast type
        self.broadcastType = type

        broadcastFuncs = {
            BT.FULL: self.cnode.broadcastPosHprFull,
            BT.XYH: self.cnode.broadcastPosHprXyh,
            BT.XY: self.cnode.broadcastPosHprXy,
        }
        # this comment is here so it will show up in a grep for 'def d_broadcastPosHpr'
        self.d_broadcastPosHpr = broadcastFuncs[self.broadcastType]

        # Set stagger to non-zero to randomly delay the initial task execution
        # over 'period' seconds, to spread out task processing over time
        # when a large number of SmoothNodes are created simultaneously.
        taskName = self.getPosHprBroadcastTaskName()

        # Set up telemetry optimization variables
        self.cnode.initialize(self, self.dclass, self.doId)

        self.setPosHprBroadcastPeriod(period)
        # Broadcast our initial position
        self.b_clearSmoothing()
        self.cnode.sendEverything()

        # remove any old tasks
        taskMgr.remove(taskName)
        # spawn the new task
        delay = 0.
        if stagger:
            delay = randFloat(period)
        if self.wantSmoothPosBroadcastTask():
            taskMgr.doMethodLater(self.__broadcastPeriod + delay,
                                  self._posHprBroadcast, taskName)
Exemple #21
0
def arbitraryShadow(node):
    # Turn off the existing drop shadow, if any
    if hasattr(node, "dropShadow"):
        # stash it so that when the game hides and shows it, it will still be gone
        node.dropShadow.stash()

    # Set up a new node to hold the "light": this is an abitrary point
    # somewhere above the node, looking down, as if from the sun.
    objectPath = node
    shadowCamera = objectPath.attachNewNode('shadowCamera')
    lightPath = shadowCamera.attachNewNode('lightPath')

    # We can change this position at will to change the angle of the
    # sun.
    lightPath.setPos(50, 0, 50)

    # We need a task to keep the shadowCamera rotated in the same
    # direction relative to render (otherwise, the shadow seems to
    # rotate when you rotate your avatar, which is strange).  We can't
    # just use a compass effect, since that doesn't work on cameras.
    def shadowCameraRotate(task, shadowCamera = shadowCamera):
        shadowCamera.setHpr(render, 0, 0, 0)
        lightPath.lookAt(shadowCamera, 0, 0, 3)
        return Task.cont

    taskMgr.remove('shadowCamera')
    taskMgr.add(shadowCameraRotate, 'shadowCamera')

    global sc
    if sc is not None:
        sc.clear()

    sc = ShadowCaster(lightPath, objectPath, 100, 100)

    # Naively, just apply the shadow to everything in the world.  It
    # would probably be better to use a little restraint.
    sc.setGround(render)

    return sc
Exemple #22
0
    def __generated(self, object):
        # The indicated object has been generated.
        doId = object.doId
        assert self.notify.debug("Got generate from %s" % (doId))
        pendingList = self.pendingObjects[doId]
        del self.pendingObjects[doId]

        for tuple in pendingList:
            allCallback, eachCallback, timeoutCallback, doIdsPending, doIdList, doLaterName = tuple

            # Here we are depending on Python to unify this one list
            # across all objects that share it.  When we remove our
            # doId from our reference to the list, it is also removed
            # from all the other references.
            doIdsPending.remove(doId)

            if eachCallback:
                eachCallback(object)

            if len(doIdsPending) == 0:
                # That was the last doId on the list.  Call the
                # allCallback!
                assert self.notify.debug("All objects generated on list: %s" %
                                         (doIdList, ))
                if doLaterName:
                    taskMgr.remove(doLaterName)

                objects, doIdsPending = self.__generateObjectList(doIdList)
                if None in objects:
                    assert self.notify.warning(
                        'calling %s with None.\n objects=%s\n doIdsPending=%s\n doIdList=%s\n'
                        % (allCallback, objects, doIdsPending, doIdList))
                if allCallback:
                    allCallback(objects)

            else:
                assert self.notify.debug("Objects still pending: %s" %
                                         (doIdsPending))
Exemple #23
0
def lerpBackgroundColor(r, g, b, duration):
    """
    Function to lerp background color to a new value
    """
    def lerpColor(state):
        dt = base.clock.getDt()
        state.time += dt
        sf = state.time / state.duration
        if sf >= 1.0:
            base.setBackgroundColor(state.ec[0], state.ec[1], state.ec[2])
            return Task.done
        else:
            r = sf * state.ec[0] + (1 - sf) * state.sc[0]
            g = sf * state.ec[1] + (1 - sf) * state.sc[1]
            b = sf * state.ec[2] + (1 - sf) * state.sc[2]
            base.setBackgroundColor(r, g, b)
            return Task.cont

    taskMgr.remove('lerpBackgroundColor')
    t = taskMgr.add(lerpColor, 'lerpBackgroundColor')
    t.time = 0.0
    t.duration = duration
    t.sc = base.getBackgroundColor()
    t.ec = VBase4(r, g, b, 1)
 def ouch(db):
     taskMgr.remove('shrink')
     taskMgr.remove('expand')
     taskMgr.remove('runAway')
     db.component('geom0').setScale(db.component('geom2').getScale()[0])
     db.component('geom1').setScale(db.component('geom2').getScale()[0])
     db['text2_text'] = 'Ouch!'
     db['geom2_color'] = (1, 0, 0, 1)
     newX = -1.0 + random() * 2.0
     newZ = -1.0 + random() * 2.0
     db.lerpPos(Point3(newX, 0, newZ),
                1.0,
                task='runAway',
                blendType='easeOut')
    def cleanup(self):
        """ Interrupts all pending downloads.  No further callbacks
        will be made. """

        self.packageLock.acquire()
        try:
            if self.descFileTask:
                taskMgr.remove(self.descFileTask)
                self.descFileTask = None
            if self.downloadTask:
                taskMgr.remove(self.downloadTask)
                self.downloadTask = None
        finally:
            self.packageLock.release()

        if self.progressTask:
            taskMgr.remove(self.progressTask)
            self.progressTask = None

        self.ignoreAll()
Exemple #26
0
    def cleanup(self):
        """ Interrupts all pending downloads.  No further callbacks
        will be made. """

        self.packageLock.acquire()
        try:
            if self.descFileTask:
                taskMgr.remove(self.descFileTask)
                self.descFileTask = None
            if self.downloadTask:
                taskMgr.remove(self.downloadTask)
                self.downloadTask = None
        finally:
            self.packageLock.release()

        if self.progressTask:
            taskMgr.remove(self.progressTask)
            self.progressTask = None

        self.ignoreAll()
Exemple #27
0
 def destroy(self):
     messenger.ignoreAll(self)
     self.detachNode()
     taskMgr.remove(self.task)
Exemple #28
0
 def __buttonUp(self, event):
     assert self.notify.debugStateCall(self)
     taskName = self.taskName('repeatStep')
     #print 'buttonUp: removing ', taskName
     taskMgr.remove(taskName)
 def exit(self):
     taskMgr.remove(self.task_)           
     if self.elapsed_ < PLAY_TASK_DELAY:
         logging.info("Exited task early after %f seconds instead of %f"%(self.elapsed_,PLAY_TASK_DELAY))    
     else:
         logging.info("Exited task at %f seconds"%(self.elapsed_))        
Exemple #30
0
 def destroy(self):
     messenger.ignoreAll(self)
     self.detachNode()
     taskMgr.remove(self.task)
 def tearDownClass(cls):
     taskMgr.remove('Joystick Polling')
     cls.cb.close()
     del cls.cb
     print 'tore down'
Exemple #32
0
 def startCheckingIncomingHTTP(self, interval=0.3):
     taskMgr.remove('pollHTTPTask')
     taskMgr.doMethodLater(interval,self.pollHTTPTask,'pollHTTPTask')
 def avatarCancelled(self, npcId):
     npc = self.air.doId2do.get(npcId)
     if not npc:
         return
     taskMgr.remove(npc.uniqueName('clearMovie'))
Exemple #34
0
 def editStop(self, event):
     taskMgr.remove('guiEditTask')
Exemple #35
0
 def stop(self):
     taskMgr.remove('Update Timer Object')
 def destroy(self):
     taskMgr.remove(JobManager.TaskName)
     del self._pri2jobId2job
Exemple #37
0
 def shutdown(self):
     taskMgr.remove('eventManager')
Exemple #38
0
 def removeTask(self):
     taskMgr.remove("EnemyUpdateTask#" + str(self.numNpc))
Exemple #39
0
 def stopPosHprBroadcast(self):
     taskMgr.remove(self.getPosHprBroadcastTaskName())
     # Delete this callback because it maintains a reference to self
     self.d_broadcastPosHpr = None
Exemple #40
0
 def destroy(self):
     taskMgr.remove(JobManager.TaskName)
     del self._pri2jobId2job
 def shutdown(self):
     # Should be safe to import the global taskMgr by now.
     from direct.task.TaskManagerGlobal import taskMgr
     taskMgr.remove('eventManager')
Exemple #42
0
 def collide2(self,f,collEntry):
     for i in self.highlighted_indices:
         if self.contacts[i] == False:
             return
     taskMgr.remove('too_long%d' % f)
 def disable(self):
     taskMgr.remove(self.name + '-updateTask')
Exemple #44
0
 def collide3(self,f,collEntry):
     taskMgr.remove('too_long%d' % f)
     self.reset_fing(f)
     self.tar.setColorScale(0.1,0.1,0.1,1)
     self.tar.setAlphaScale(0.7)
Exemple #45
0
 def stopCheckingIncomingHTTP(self):
     taskMgr.remove('pollHTTPTask')
Exemple #46
0
 def destroy(self):
     if hasattr(self, '_leakTaskName'):
         taskMgr.remove(self._leakTaskName)
     del self._render
     LeakDetector.destroy(self)
Exemple #47
0
 def stopUpdateGridTask(self):
     taskMgr.remove(self.taskName("updateGridTask"))
     self.updateTaskStarted = 0
Exemple #48
0
 def stopActorControls(self):
     taskMgr.remove(self.id + '_UpdateTask')
Exemple #49
0
 def stopHeartbeat(self):
     taskMgr.remove("heartBeat")
     self.heartbeatStarted = 0
 def shutdown(self):
     from direct.task.TaskManagerGlobal import taskMgr
     taskMgr.remove('eventManager')