当前位置: 首页>>代码示例>>Python>>正文


Python StatePush.FunctionCall类代码示例

本文整理汇总了Python中direct.fsm.StatePush.FunctionCall的典型用法代码示例。如果您正苦于以下问题:Python FunctionCall类的具体用法?Python FunctionCall怎么用?Python FunctionCall使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FunctionCall类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

 def __init__(self):
     Hour = FrameProfiler.Hour
     # how long to wait between frame profiles
     self._period = 2 * FrameProfiler.Minute
     if config.GetBool('frequent-frame-profiles', 0):
         self._period = 1 * FrameProfiler.Minute
     # used to prevent profile from being taken exactly every 'period' seconds
     self._jitterMagnitude = self._period * .75
     # when to log output
     # each entry must be an integer multiple of all previous entries
     # as well as an integer multiple of the period
     self._logSchedule = [ 1 * FrameProfiler.Hour,
                           4 * FrameProfiler.Hour,
                          12 * FrameProfiler.Hour,
                           1 * FrameProfiler.Day,
                           ] # day schedule proceeds as 1, 2, 4, 8 days, etc.
     if config.GetBool('frequent-frame-profiles', 0):
         self._logSchedule = [ 1  * FrameProfiler.Minute,
                               4  * FrameProfiler.Minute,
                               12 * FrameProfiler.Minute,
                               24 * FrameProfiler.Minute,
                               ]
     for t in self._logSchedule:
         assert isInteger(t)
         # make sure the period is evenly divisible into each element of the log schedule
         assert (t % self._period) == 0
     # make sure each element of the schedule is evenly divisible into each subsequent element
     for i in xrange(len(self._logSchedule)):
         e = self._logSchedule[i]
         for j in xrange(i, len(self._logSchedule)):
             assert (self._logSchedule[j] % e) == 0
     assert isInteger(self._period)
     self._enableFC = FunctionCall(self._setEnabled, taskMgr.getProfileFramesSV())
     self._enableFC.pushCurrentState()
开发者ID:FelixBucket,项目名称:ToontownFritzServer,代码行数:34,代码来源:FrameProfiler.py

示例2: generate

 def generate(self):
     DistributedPartyTeamActivity.generate(self)
     self._hopOffFinishedSV = StateVar(True)
     self._rewardFinishedSV = StateVar(True)
     self._isWalkStateReadyFC = FunctionCall(
         self._testWalkStateReady, self._hopOffFinishedSV, self._rewardFinishedSV
     )
开发者ID:XamarinDeveloper,项目名称:src,代码行数:7,代码来源:DistributedPartyTugOfWarActivity.py

示例3: __init__

    def __init__(self):
        Hour = FrameProfiler.Hour
        self._period = 2 * FrameProfiler.Minute
        if config.GetBool('frequent-frame-profiles', 0):
            self._period = 1 * FrameProfiler.Minute
        self._jitterMagnitude = self._period * 0.75
        self._logSchedule = [1 * FrameProfiler.Hour,
         4 * FrameProfiler.Hour,
         12 * FrameProfiler.Hour,
         1 * FrameProfiler.Day]
        if config.GetBool('frequent-frame-profiles', 0):
            self._logSchedule = [1 * FrameProfiler.Minute,
             4 * FrameProfiler.Minute,
             12 * FrameProfiler.Minute,
             24 * FrameProfiler.Minute]
        for t in self._logSchedule:
            pass

        for i in xrange(len(self._logSchedule)):
            e = self._logSchedule[i]
            for j in xrange(i, len(self._logSchedule)):
                pass

        self._enableFC = FunctionCall(self._setEnabled, taskMgr.getProfileFramesSV())
        self._enableFC.pushCurrentState()
开发者ID:MasterLoopyBM,项目名称:c0d3,代码行数:25,代码来源:FrameProfiler.pyc.py

示例4: privSetSettingsRef

 def privSetSettingsRef(self, settingsRef):
     SCElement.privSetSettingsRef(self, settingsRef)
     if self._handleWhisperModeFC is None:
         self._handleWhisperModeFC = FunctionCall(self._handleWhisperModeSVChanged, self._handleWhisperModeSV)
         self._handleWhisperModeFC.pushCurrentState()
     self._handleWhisperModeSV.set(self.settingsRef is not None and not self.isWhisperable())
     return
开发者ID:BmanGames,项目名称:ToontownStride,代码行数:7,代码来源:SCTerminal.py

示例5: generate

 def generate(self):
     self._announcerInterest = None
     self._siegeTeam = 0
     self._siegeTeamUpdater = FunctionCall(self._setSiegeTeam, localAvatar._siegeTeamSV)
     self._siegeTeamUpdater.pushCurrentState()
     DistributedObject.generate(self)
     self._pvpTeamJoinable = { }
     base.cr.distributedDistrict.siegeManager = self
开发者ID:TTGhost,项目名称:POTCOR-src,代码行数:8,代码来源:SiegeManager.py

示例6: __init__

 def __init__(self, cr):
     DistributedObject.__init__(self, cr)
     base.cogdoGame = self
     cr.cogdoGame = self
     self._waitingStartLabel = DirectLabel(
         text=TTL.MinigameWaitingForOtherToons,
         text_fg=VBase4(1, 1, 1, 1),
         relief=None,
         pos=(-0.6, 0, -0.75),
         scale=0.075,
     )
     self._waitingStartLabel.hide()
     self.loadFSM = ClassicFSM.ClassicFSM(
         "DistCogdoGame.loaded",
         [
             State.State("NotLoaded", self.enterNotLoaded, self.exitNotLoaded, ["Loaded"]),
             State.State("Loaded", self.enterLoaded, self.exitLoaded, ["NotLoaded"]),
         ],
         "NotLoaded",
         "NotLoaded",
     )
     self.loadFSM.enterInitialState()
     self.fsm = ClassicFSM.ClassicFSM(
         "DistCogdoGame",
         [
             State.State("Visible", self.enterVisible, self.exitVisible, ["Intro"]),
             State.State("Intro", self.enterIntro, self.exitIntro, ["WaitServerStart"]),
             State.State("WaitServerStart", self.enterWaitServerStart, self.exitWaitServerStart, ["Game"]),
             State.State("Game", self.enterGame, self.exitGame, ["Finish"]),
             State.State("Finish", self.enterFinish, self.exitFinish, ["Off"]),
             State.State("Off", self.enterOff, self.exitOff, ["Visible"]),
         ],
         "Off",
         "Off",
     )
     self.fsm.enterInitialState()
     self.difficultyOverride = None
     self.exteriorZoneOverride = None
     self._gotInterior = StateVar(False)
     self._toonsInEntranceElev = StateVar(False)
     self._wantStashElevator = StateVar(False)
     self._stashElevatorFC = FunctionCall(
         self._doStashElevator, self._toonsInEntranceElev, self._gotInterior, self._wantStashElevator
     )
     return
开发者ID:Teku16,项目名称:Toontown-Crystal-Master,代码行数:45,代码来源:DistCogdoGame.py

示例7: __init__

 def __init__(self, cr):
     DistributedObject.__init__(self, cr)
     base.cogdoGame = self
     cr.cogdoGame = self
     self._waitingStartLabel = DirectLabel(text=TTL.MinigameWaitingForOtherPlayers, text_fg=VBase4(1, 1, 1, 1), relief=None, pos=(-0.6, 0, -0.75), scale=0.075)
     self._waitingStartLabel.hide()
     self.loadFSM = ClassicFSM.ClassicFSM('DistCogdoGame.loaded', [State.State('NotLoaded', self.enterNotLoaded, self.exitNotLoaded, ['Loaded']), State.State('Loaded', self.enterLoaded, self.exitLoaded, ['NotLoaded'])], 'NotLoaded', 'NotLoaded')
     self.loadFSM.enterInitialState()
     self.fsm = ClassicFSM.ClassicFSM('DistCogdoGame', [State.State('Visible', self.enterVisible, self.exitVisible, ['Intro']),
      State.State('Intro', self.enterIntro, self.exitIntro, ['WaitServerStart']),
      State.State('WaitServerStart', self.enterWaitServerStart, self.exitWaitServerStart, ['Game']),
      State.State('Game', self.enterGame, self.exitGame, ['Finish']),
      State.State('Finish', self.enterFinish, self.exitFinish, ['Off']),
      State.State('Off', self.enterOff, self.exitOff, ['Visible'])], 'Off', 'Off')
     self.fsm.enterInitialState()
     self.difficultyOverride = None
     self.exteriorZoneOverride = None
     self._gotInterior = StateVar(False)
     self._toonsInEntranceElev = StateVar(False)
     self._wantStashElevator = StateVar(False)
     self._stashElevatorFC = FunctionCall(self._doStashElevator, self._toonsInEntranceElev, self._gotInterior, self._wantStashElevator)
开发者ID:Toonerz,项目名称:Toontown-World-Online-Leak,代码行数:21,代码来源:DistCogdoGame.py

示例8: DistCogdoGame

class DistCogdoGame(DistCogdoGameBase, DistributedObject):
    notify = directNotify.newCategory('DistCogdoGame')

    def __init__(self, cr):
        DistributedObject.__init__(self, cr)
        base.cogdoGame = self
        cr.cogdoGame = self
        self._waitingStartLabel = DirectLabel(text=TTL.MinigameWaitingForOtherPlayers, text_fg=VBase4(1, 1, 1, 1), relief=None, pos=(-0.6, 0, -0.75), scale=0.075)
        self._waitingStartLabel.hide()
        self.loadFSM = ClassicFSM.ClassicFSM('DistCogdoGame.loaded', [State.State('NotLoaded', self.enterNotLoaded, self.exitNotLoaded, ['Loaded']), State.State('Loaded', self.enterLoaded, self.exitLoaded, ['NotLoaded'])], 'NotLoaded', 'NotLoaded')
        self.loadFSM.enterInitialState()
        self.fsm = ClassicFSM.ClassicFSM('DistCogdoGame', [State.State('Visible', self.enterVisible, self.exitVisible, ['Intro']),
         State.State('Intro', self.enterIntro, self.exitIntro, ['WaitServerStart']),
         State.State('WaitServerStart', self.enterWaitServerStart, self.exitWaitServerStart, ['Game']),
         State.State('Game', self.enterGame, self.exitGame, ['Finish']),
         State.State('Finish', self.enterFinish, self.exitFinish, ['Off']),
         State.State('Off', self.enterOff, self.exitOff, ['Visible'])], 'Off', 'Off')
        self.fsm.enterInitialState()
        self.difficultyOverride = None
        self.exteriorZoneOverride = None
        self._gotInterior = StateVar(False)
        self._toonsInEntranceElev = StateVar(False)
        self._wantStashElevator = StateVar(False)
        self._stashElevatorFC = FunctionCall(self._doStashElevator, self._toonsInEntranceElev, self._gotInterior, self._wantStashElevator)

    def getTitle(self):
        pass

    def getInstructions(self):
        pass

    def setInteriorId(self, interiorId):
        self._interiorId = interiorId

    def setExteriorZone(self, exteriorZone):
        self.exteriorZone = exteriorZone

    def setDifficultyOverrides(self, difficultyOverride, exteriorZoneOverride):
        if difficultyOverride != CogdoGameConsts.NoDifficultyOverride:
            self.difficultyOverride = difficultyOverride / float(CogdoGameConsts.DifficultyOverrideMult)
        if exteriorZoneOverride != CogdoGameConsts.NoExteriorZoneOverride:
            self.exteriorZoneOverride = exteriorZoneOverride

    def getInterior(self):
        return self.cr.getDo(self._interiorId)

    def getEntranceElevator(self, callback):
        return self.getInterior().getEntranceElevator(callback)

    def getToonIds(self):
        interior = self.getInterior()
        if interior is not None:
            return interior.getToonIds()
        else:
            return []

    def getToon(self, toonId):
        if self.cr.doId2do.has_key(toonId):
            return self.cr.doId2do[toonId]
        else:
            return None

    def getNumPlayers(self):
        return len(self.getToonIds())

    def isSinglePlayer(self):
        if self.getNumPlayers() == 1:
            return 1
        else:
            return 0

    def announceGenerate(self):
        DistributedObject.announceGenerate(self)
        self.loadFSM.request('Loaded')
        self._requestInterior()
        self.notify.info('difficulty: %s, safezoneId: %s' % (self.getDifficulty(), self.getSafezoneId()))

    def _requestInterior(self):
        self.cr.relatedObjectMgr.requestObjects([self._interiorId], allCallback=self._handleGotInterior)

    def _handleGotInterior(self, objs):
        self._gotInterior.set(True)
        self.getEntranceElevator(self.placeEntranceElev)

    def stashEntranceElevator(self):
        self._wantStashElevator.set(True)

    def placeEntranceElev(self, elev):
        pass

    def _doStashElevator(self, toonsInEntranceElev, gotInterior, wantStashElevator):
        if gotInterior:
            interior = self.getInterior()
            if interior:
                if not toonsInEntranceElev and wantStashElevator:
                    interior.stashElevatorIn()
                else:
                    interior.stashElevatorIn(False)

    def disable(self):
#.........这里部分代码省略.........
开发者ID:Toonerz,项目名称:Toontown-World-Online-Leak,代码行数:101,代码来源:DistCogdoGame.py

示例9: DistributedPartyTugOfWarActivity

class DistributedPartyTugOfWarActivity(DistributedPartyTeamActivity):
    notify = directNotify.newCategory('DistributedPartyTugOfWarActivity')

    def __init__(self, cr):
        DistributedPartyTeamActivity.__init__(self, cr, PartyGlobals.ActivityIds.PartyTugOfWar, startDelay=PartyGlobals.TugOfWarStartDelay)
        self.buttons = [0, 1]
        self.arrowKeys = None
        self.keyTTL = []
        self.idealRate = 0.0
        self.keyRate = 0
        self.allOutMode = False
        self.rateMatchAward = 0.0
        self.toonIdsToStartPositions = {}
        self.toonIdsToIsPullingFlags = {}
        self.toonIdsToRightHands = {}
        self.fallenToons = []
        self.fallenPositions = []
        self.unusedFallenPositionsIndices = [0,
         1,
         2,
         3]
        self.toonIdsToAnimIntervals = {}
        self.tugRopes = []
        return

    def generate(self):
        DistributedPartyTeamActivity.generate(self)
        self._hopOffFinishedSV = StateVar(True)
        self._rewardFinishedSV = StateVar(True)
        self._isWalkStateReadyFC = FunctionCall(self._testWalkStateReady, self._hopOffFinishedSV, self._rewardFinishedSV)

    def delete(self):
        self._isWalkStateReadyFC.destroy()
        self._hopOffFinishedSV.destroy()
        self._rewardFinishedSV.destroy()
        DistributedPartyTeamActivity.delete(self)

    def handleToonJoined(self, toonId):
        DistributedPartyTeamActivity.handleToonJoined(self, toonId)
        self.toonIdsToAnimIntervals[toonId] = None
        if toonId == base.localAvatar.doId:
            base.cr.playGame.getPlace().fsm.request('activity')
            camera.wrtReparentTo(self.root)
            self.cameraMoveIval = LerpPosHprInterval(camera, 1.5, PartyGlobals.TugOfWarCameraPos, PartyGlobals.TugOfWarCameraInitialHpr, other=self.root)
            self.cameraMoveIval.start()
            self.localToonPosIndex = self.getIndex(base.localAvatar.doId, self.localToonTeam)
            self.notify.debug('posIndex: %d' % self.localToonPosIndex)
            toon = self.getAvatar(toonId)
            targetPos = self.dockPositions[self.localToonTeam][self.localToonPosIndex]
            if toon.getZ(self.root) < PartyGlobals.TugOfWarToonPositionZ:
                toon.setZ(self.root, PartyGlobals.TugOfWarToonPositionZ)
            targetH = fitDestAngle2Src(toon.getH(self.root), PartyGlobals.TugOfWarHeadings[self.localToonTeam])
            travelVector = targetPos - toon.getPos(self.root)
            duration = travelVector.length() / 5.0
            if self.toonIdsToAnimIntervals[toonId] is not None:
                self.toonIdsToAnimIntervals[toonId].finish()
            self.toonIdsToAnimIntervals[toonId] = Sequence(Func(toon.startPosHprBroadcast, 0.1), Func(toon.b_setAnimState, 'run'), LerpPosHprInterval(toon, duration, targetPos, VBase3(targetH, 0.0, 0.0), other=self.root), Func(toon.stopPosHprBroadcast), Func(toon.b_setAnimState, 'neutral'))
            self.toonIdsToAnimIntervals[toonId].start()
        return

    def handleToonExited(self, toonId):
        DistributedPartyTeamActivity.handleToonExited(self, toonId)
        if toonId == base.localAvatar.doId:
            self.cameraMoveIval.pause()
            if toonId not in self.fallenToons:
                if toonId in self.toonIdsToAnimIntervals and self.toonIdsToAnimIntervals[toonId] is not None:
                    self.toonIdsToAnimIntervals[toonId].finish()
                toon = self.getAvatar(toonId)
                targetH = fitDestAngle2Src(toon.getH(self.root), 180.0)
                targetPos = self.hopOffPositions[self.getTeam(toonId)][self.getIndex(toonId, self.getTeam(toonId))]
                hopOffAnim = Sequence(Func(toon.startPosHprBroadcast, 0.1), toon.hprInterval(0.2, VBase3(targetH, 0.0, 0.0), other=self.root), Func(toon.b_setAnimState, 'jump', 1.0), Wait(0.4), PartyUtils.arcPosInterval(0.75, toon, targetPos, 5.0, self.root), Func(toon.stopPosHprBroadcast), Func(toon.sendCurrentPosition), Func(self.hopOffFinished, toonId))
                self.toonIdsToAnimIntervals[toonId] = hopOffAnim
                self._hopOffFinishedSV.set(False)
                self.toonIdsToAnimIntervals[toonId].start()
            else:
                self._hopOffFinishedSV.set(True)
                del self.toonIdsToAnimIntervals[toonId]
        return

    def handleRewardDone(self):
        self._rewardFinishedSV.set(True)

    def _testWalkStateReady(self, hoppedOff, rewardFinished):
        if hoppedOff and rewardFinished:
            DistributedPartyTeamActivity.handleRewardDone(self)

    def hopOffFinished(self, toonId):
        if hasattr(self, 'toonIdsToAnimIntervals') and toonId in self.toonIdsToAnimIntervals:
            del self.toonIdsToAnimIntervals[toonId]
        if toonId == base.localAvatar.doId:
            if hasattr(self._hopOffFinishedSV, '_value'):
                self._hopOffFinishedSV.set(True)

    def handleToonShifted(self, toonId):
        if toonId == base.localAvatar.doId:
            self.localToonPosIndex = self.getIndex(base.localAvatar.doId, self.localToonTeam)
            if self.toonIdsToAnimIntervals[toonId] is not None:
                self.toonIdsToAnimIntervals[toonId].finish()
            toon = self.getAvatar(toonId)
            targetPos = self.dockPositions[self.localToonTeam][self.localToonPosIndex]
#.........这里部分代码省略.........
开发者ID:Keithybub,项目名称:ToonTownReviveOld,代码行数:101,代码来源:DistributedPartyTugOfWarActivity.py

示例10: SiegeManager

class SiegeManager(DistributedObject, SiegeManagerBase):
    TeamJoinableChangedEvent = 'PVPTeamJoinableChanged'
    
    def __init__(self, cr):
        DistributedObject.__init__(self, cr)
        SiegeManagerBase.__init__(self)

    
    def generate(self):
        self._announcerInterest = None
        self._siegeTeam = 0
        self._siegeTeamUpdater = FunctionCall(self._setSiegeTeam, localAvatar._siegeTeamSV)
        self._siegeTeamUpdater.pushCurrentState()
        DistributedObject.generate(self)
        self._pvpTeamJoinable = { }
        base.cr.distributedDistrict.siegeManager = self

    
    def delete(self):
        self._siegeTeamUpdater.destroy()
        del self._siegeTeamUpdater
        self._removeAnnouncerInterest()
        del self._pvpTeamJoinable
        del base.cr.distributedDistrict.siegeManager
        DistributedObject.delete(self)

    
    def setPvpEnabled(self, enabled):
        self._pvpEnabled = enabled

    
    def getPvpEnabled(self):
        return self._pvpEnabled

    
    def setTeamsJoinable(self, teamJoinableItems):
        for (teamId, joinable) in teamJoinableItems:
            self._pvpTeamJoinable[teamId] = joinable
        
        messenger.send(SiegeManager.TeamJoinableChangedEvent)

    
    def teamIsJoinable(self, teamId):
        if not config.GetBool('want-pvp-team-balance', 1):
            return True
        
        return self._pvpTeamJoinable.get(teamId, True)

    
    def sendTalk(self, message):
        print 'Seige Manager Sending Message %s' % message
        self.sendUpdate('setTalkGroup', [
            0,
            0,
            '',
            message,
            [],
            0])

    
    def sendWLChat(self, message):
        self.sendUpdate('sendWLChat', [
            message,
            0,
            0])

    
    def sendSC(self, msgIndex):
        self.sendUpdate('sendSC', [
            msgIndex])

    
    def setTalkGroup(self, fromAv, fromAC, avatarName, chat, mods, flags):
        print 'Seige Manager- SetTalkGroup %s' % chat
        teamName = self.getPVPChatTeamName(localAvatar.getSiegeTeam())
        (message, scrubbed) = localAvatar.scrubTalk(chat, mods)
        base.talkAssistant.receiveShipPVPMessage(fromAv, fromAC, avatarName, teamName, message, scrubbed)

    
    def recvChat(self, avatarId, message, chatFlags, DISLid, name):
        teamName = self.getPVPChatTeamName(localAvatar.getSiegeTeam())
        if not self.cr.avatarFriendsManager.checkIgnored(avatarId):
            displayMess = '%s %s %s' % (name, self.getPVPChatTeamName(localAvatar.getSiegeTeam()), message)
            base.talkAssistant.receiveShipPVPMessage(avatarId, DISLid, name, teamName, message)
        

    
    def recvWLChat(self, avatarId, message, chatFlags, DISLid, name):
        teamName = self.getPVPChatTeamName(localAvatar.getSiegeTeam())
        if not self.cr.avatarFriendsManager.checkIgnored(avatarId):
            displayMess = '%s %s %s' % (name, self.getPVPChatTeamName(localAvatar.getSiegeTeam()), message)
            base.talkAssistant.receiveShipPVPMessage(avatarId, DISLid, name, teamName, message)
        

    
    def recvSpeedChat(self, avatarId, msgIndex, name):
        print 'siege manager recvSpeedChat'
        if not self.cr.avatarFriendsManager.checkIgnored(avatarId):
            displayMess = '%s %s %s' % (name, self.getPVPChatTeamName(localAvatar.getSiegeTeam()), SCDecoders.decodeSCStaticTextMsg(msgIndex))
            message = SCDecoders.decodeSCStaticTextMsg(msgIndex)
#.........这里部分代码省略.........
开发者ID:TTGhost,项目名称:POTCOR-src,代码行数:101,代码来源:SiegeManager.py

示例11: SCTerminal

class SCTerminal(SCElement):

    def __init__(self, linkedEmote = None):
        SCElement.__init__(self)
        self.setLinkedEmote(linkedEmote)
        scGui = loader.loadModel(SCMenu.GuiModelName)
        self.emotionIcon = scGui.find('**/emotionIcon')
        self.setDisabled(False)
        self.__numCharges = -1
        self._handleWhisperModeSV = StateVar(False)
        self._handleWhisperModeFC = None
        return

    def destroy(self):
        self._handleWhisperModeSV.set(False)
        if self._handleWhisperModeFC:
            self._handleWhisperModeFC.destroy()
        self._handleWhisperModeSV.destroy()
        SCElement.destroy(self)

    def privSetSettingsRef(self, settingsRef):
        SCElement.privSetSettingsRef(self, settingsRef)
        if self._handleWhisperModeFC is None:
            self._handleWhisperModeFC = FunctionCall(self._handleWhisperModeSVChanged, self._handleWhisperModeSV)
            self._handleWhisperModeFC.pushCurrentState()
        self._handleWhisperModeSV.set(self.settingsRef is not None and not self.isWhisperable())
        return

    def _handleWhisperModeSVChanged(self, handleWhisperMode):
        if handleWhisperMode:
            self._wmcListener = DirectObject()
            self._wmcListener.accept(self.getEventName(SCWhisperModeChangeEvent), self._handleWhisperModeChange)
        elif hasattr(self, '_wmcListener'):
            self._wmcListener.ignoreAll()
            del self._wmcListener
            self.invalidate()

    def _handleWhisperModeChange(self, whisperMode):
        self.invalidate()

    def handleSelect(self):
        messenger.send(self.getEventName(SCTerminalSelectedEvent))
        if self.hasLinkedEmote() and self.linkedEmoteEnabled():
            messenger.send(self.getEventName(SCTerminalLinkedEmoteEvent), [self.linkedEmote])

    def isWhisperable(self):
        return True

    def getLinkedEmote(self):
        return self.linkedEmote

    def setLinkedEmote(self, linkedEmote):
        self.linkedEmote = linkedEmote
        self.invalidate()

    def hasLinkedEmote(self):
        return self.linkedEmote is not None

    def linkedEmoteEnabled(self):
        if Emote.globalEmote:
            return Emote.globalEmote.isEnabled(self.linkedEmote)

    def getCharges(self):
        return self.__numCharges

    def setCharges(self, nCharges):
        self.__numCharges = nCharges
        if nCharges is 0:
            self.setDisabled(True)

    def isDisabled(self):
        return self.__disabled or self.isWhispering() and not self.isWhisperable()

    def setDisabled(self, bDisabled):
        self.__disabled = bDisabled

    def onMouseClick(self, event):
        if not self.isDisabled():
            SCElement.onMouseClick(self, event)
            self.handleSelect()

    def getMinDimensions(self):
        width, height = SCElement.getMinDimensions(self)
        if self.hasLinkedEmote():
            width += 1.3
        return (width, height)

    def finalize(self, dbArgs = {}):
        if not self.isDirty():
            return
        args = {}
        if self.hasLinkedEmote():
            self.lastEmoteIconColor = self.getEmoteIconColor()
            self.emotionIcon.setColorScale(*self.lastEmoteIconColor)
            args.update({'image': self.emotionIcon,
             'image_pos': (self.width - 0.6, 0, -self.height * 0.5)})
        if self.isDisabled():
            args.update({'rolloverColor': (0, 0, 0, 0),
             'pressedColor': (0, 0, 0, 0),
             'rolloverSound': None,
#.........这里部分代码省略.........
开发者ID:BmanGames,项目名称:ToontownStride,代码行数:101,代码来源:SCTerminal.py

示例12: TaskProfiler

class TaskProfiler():
    __module__ = __name__
    notify = directNotify.newCategory('TaskProfiler')

    def __init__(self):
        self._enableFC = FunctionCall(self._setEnabled, taskMgr.getProfileTasksSV())
        self._enableFC.pushCurrentState()
        self._namePrefix2tracker = {}
        self._task = None
        return

    def destroy(self):
        if taskMgr.getProfileTasks():
            self._setEnabled(False)
        self._enableFC.destroy()
        for tracker in self._namePrefix2tracker.itervalues():
            tracker.destroy()

        del self._namePrefix2tracker
        del self._task

    @staticmethod
    def GetDefaultSpikeThreshold():
        return config.GetFloat('profile-task-spike-threshold', 5.0)

    @staticmethod
    def SetSpikeThreshold(spikeThreshold):
        TaskTracker.SpikeThreshold = spikeThreshold

    @staticmethod
    def GetSpikeThreshold():
        return TaskTracker.SpikeThreshold

    def logProfiles(self, name = None):
        if name:
            name = name.lower()
        for namePrefix, tracker in self._namePrefix2tracker.iteritems():
            if name and name not in namePrefix.lower():
                continue
            tracker.log()

    def flush(self, name):
        if name:
            name = name.lower()
        for namePrefix, tracker in self._namePrefix2tracker.iteritems():
            if name and name not in namePrefix.lower():
                continue
            tracker.flush()

    def _setEnabled(self, enabled):
        if enabled:
            self.notify.info('task profiler started')
            self._taskName = 'profile-tasks-%s' % id(self)
            taskMgr.add(self._doProfileTasks, self._taskName, priority=-200)
        else:
            taskMgr.remove(self._taskName)
            del self._taskName
            self.notify.info('task profiler stopped')

    def _doProfileTasks(self, task = None):
        if self._task is not None and taskMgr._hasProfiledDesignatedTask():
            session = taskMgr._getLastTaskProfileSession()
            if session.profileSucceeded():
                namePrefix = self._task.getNamePrefix()
                if namePrefix not in self._namePrefix2tracker:
                    self._namePrefix2tracker[namePrefix] = TaskTracker(namePrefix)
                tracker = self._namePrefix2tracker[namePrefix]
                tracker.addProfileSession(session)
        self._task = taskMgr._getRandomTask()
        taskMgr._setProfileTask(self._task)
        return task.cont
开发者ID:MasterLoopyBM,项目名称:c0d3,代码行数:71,代码来源:TaskProfiler.pyc.py

示例13: __init__

class TaskProfiler:
    # this does intermittent profiling of tasks running on the system
    # if a task has a spike in execution time, the profile of the spike is logged
    notify = directNotify.newCategory("TaskProfiler")

    def __init__(self):
        self._enableFC = FunctionCall(self._setEnabled, taskMgr.getProfileTasksSV())
        self._enableFC.pushCurrentState()
        # table of task name pattern to TaskTracker
        self._namePrefix2tracker = {}
        self._task = None

    def destroy(self):
        if taskMgr.getProfileTasks():
            self._setEnabled(False)
        self._enableFC.destroy()
        for tracker in self._namePrefix2tracker.itervalues():
            tracker.destroy()
        del self._namePrefix2tracker
        del self._task

    @staticmethod
    def GetDefaultSpikeThreshold():
        return config.GetFloat('profile-task-spike-threshold', 5.)

    @staticmethod
    def SetSpikeThreshold(spikeThreshold):
        TaskTracker.SpikeThreshold = spikeThreshold
    @staticmethod
    def GetSpikeThreshold():
        return TaskTracker.SpikeThreshold

    def logProfiles(self, name=None):
        if name:
            name = name.lower()
        for namePrefix, tracker in self._namePrefix2tracker.iteritems():
            if (name and (name not in namePrefix.lower())):
                continue
            tracker.log()

    def flush(self, name):
        if name:
            name = name.lower()
        # flush stored task profiles
        for namePrefix, tracker in self._namePrefix2tracker.iteritems():
            if (name and (name not in namePrefix.lower())):
                continue
            tracker.flush()

    def _setEnabled(self, enabled):
        if enabled:
            self.notify.info('task profiler started')
            self._taskName = 'profile-tasks-%s' % id(self)
            taskMgr.add(self._doProfileTasks, self._taskName, priority=-200)
        else:
            taskMgr.remove(self._taskName)
            del self._taskName
            self.notify.info('task profiler stopped')

    def _doProfileTasks(self, task=None):
        # gather data from the previous frame
        # set up for the next frame
        if (self._task is not None) and taskMgr._hasProfiledDesignatedTask():
            session = taskMgr._getLastTaskProfileSession()
            # if we couldn't profile, throw this result out
            if session.profileSucceeded():
                namePrefix = self._task.getNamePrefix()
                if namePrefix not in self._namePrefix2tracker:
                    self._namePrefix2tracker[namePrefix] = TaskTracker(namePrefix)
                tracker = self._namePrefix2tracker[namePrefix]
                tracker.addProfileSession(session)

        # set up the next task
        self._task = taskMgr._getRandomTask()
        taskMgr._setProfileTask(self._task)

        return task.cont
开发者ID:BmanGames,项目名称:Toontown-Level-Editor,代码行数:77,代码来源:TaskProfiler.py

示例14: __init__

 def __init__(self, cr):
     DistributedObject.DistributedObject.__init__(self, cr)
     self.toons = []
     self.activeIntervals = {}
     self.openSfx = base.loadSfx('phase_5/audio/sfx/elevator_door_open.ogg')
     self.closeSfx = base.loadSfx('phase_5/audio/sfx/elevator_door_close.ogg')
     self.suits = []
     self.reserveSuits = []
     self.joiningReserves = []
     self.distBldgDoId = None
     self._CogdoGameRepeat = config.GetBool('cogdo-game-repeat', 0)
     self.currentFloor = -1
     self.elevatorName = self.__uniqueName('elevator')
     self.floorModel = None
     self.elevatorOutOpen = 0
     self.BottomFloor_SuitPositions = [Point3(0, 15, 0),
      Point3(10, 20, 0),
      Point3(-7, 24, 0),
      Point3(-10, 0, 0)]
     self.BottomFloor_SuitHs = [75,
      170,
      -91,
      -44]
     self.Cubicle_SuitPositions = [Point3(0, 18, 0),
      Point3(10, 12, 0),
      Point3(-9, 11, 0),
      Point3(-3, 13, 0)]
     self.Cubicle_SuitHs = [170,
      56,
      -52,
      10]
     self.BossOffice_SuitPositions = [Point3(0, 15, 0),
      Point3(10, 20, 0),
      Point3(-10, 6, 0),
      Point3(-17, 30, 0)]
     self.BossOffice_SuitHs = [170,
      120,
      12,
      38]
     self._wantBarrelRoom = config.GetBool('cogdo-want-barrel-room', 1)
     self.barrelRoom = CogdoBarrelRoom.CogdoBarrelRoom()
     self.brResults = [[], []]
     self.barrelRoomIntroTrack = None
     self.penthouseOutroTrack = None
     self.penthouseOutroChatDoneTrack = None
     self.penthouseIntroTrack = None
     self.waitMusic = base.loadMusic('phase_7/audio/bgm/encntr_toon_winning_indoor.ogg')
     self.elevatorMusic = base.loadMusic('phase_7/audio/bgm/tt_elevator.ogg')
     self.fsm = ClassicFSM.ClassicFSM('DistributedCogdoInterior', [State.State('WaitForAllToonsInside', self.enterWaitForAllToonsInside, self.exitWaitForAllToonsInside, ['Elevator']),
      State.State('Elevator', self.enterElevator, self.exitElevator, ['Game', 'BattleIntro', 'BarrelRoomIntro']),
      State.State('Game', self.enterGame, self.exitGame, ['Resting', 'Failed', 'BattleIntro', 'BarrelRoomIntro', 'Elevator']),
      State.State('BarrelRoomIntro', self.enterBarrelRoomIntro, self.exitBarrelRoomIntro, ['CollectBarrels', 'Off']),
      State.State('CollectBarrels', self.enterCollectBarrels, self.exitCollectBarrels, ['BarrelRoomReward', 'Off']),
      State.State('BarrelRoomReward', self.enterBarrelRoomReward, self.exitBarrelRoomReward, ['Battle',
       'ReservesJoining',
       'BattleIntro',
       'Off']),
      State.State('BattleIntro', self.enterBattleIntro, self.exitBattleIntro, ['Battle', 'ReservesJoining', 'Off']),
      State.State('Battle', self.enterBattle, self.exitBattle, ['Resting', 'Reward', 'ReservesJoining']),
      State.State('ReservesJoining', self.enterReservesJoining, self.exitReservesJoining, ['Battle']),
      State.State('Resting', self.enterResting, self.exitResting, ['Elevator']),
      State.State('Reward', self.enterReward, self.exitReward, ['Off']),
      State.State('Failed', self.enterFailed, self.exitFailed, ['Off']),
      State.State('Off', self.enterOff, self.exitOff, ['Elevator', 'WaitForAllToonsInside', 'Battle'])], 'Off', 'Off')
     self.fsm.enterInitialState()
     self._haveEntranceElevator = StateVar(False)
     self._stashEntranceElevator = StateVar(False)
     self._stashEntranceElevatorFC = FunctionCall(self._doStashEntranceElevator, self._haveEntranceElevator, self._stashEntranceElevator)
     self._entranceElevCallbacks = []
     self._doEntranceElevCallbacksFC = FunctionCall(self._doEntranceElevCallbacks, self._haveEntranceElevator)
     self.cage = None
     self.shopOwnerNpcId = None
     self.shopOwnerNpc = None
     self._movie = None
     self.SOSToonName = None
     self.FOType = None
开发者ID:BmanGames,项目名称:ToontownStride,代码行数:76,代码来源:DistributedCogdoInterior.py

示例15: DistributedCogdoInterior

class DistributedCogdoInterior(DistributedObject.DistributedObject):
    id = 0
    cageHeights = [11.36, 0.01]

    def __init__(self, cr):
        DistributedObject.DistributedObject.__init__(self, cr)
        self.toons = []
        self.activeIntervals = {}
        self.openSfx = base.loadSfx('phase_5/audio/sfx/elevator_door_open.ogg')
        self.closeSfx = base.loadSfx('phase_5/audio/sfx/elevator_door_close.ogg')
        self.suits = []
        self.reserveSuits = []
        self.joiningReserves = []
        self.distBldgDoId = None
        self._CogdoGameRepeat = config.GetBool('cogdo-game-repeat', 0)
        self.currentFloor = -1
        self.elevatorName = self.__uniqueName('elevator')
        self.floorModel = None
        self.elevatorOutOpen = 0
        self.BottomFloor_SuitPositions = [Point3(0, 15, 0),
         Point3(10, 20, 0),
         Point3(-7, 24, 0),
         Point3(-10, 0, 0)]
        self.BottomFloor_SuitHs = [75,
         170,
         -91,
         -44]
        self.Cubicle_SuitPositions = [Point3(0, 18, 0),
         Point3(10, 12, 0),
         Point3(-9, 11, 0),
         Point3(-3, 13, 0)]
        self.Cubicle_SuitHs = [170,
         56,
         -52,
         10]
        self.BossOffice_SuitPositions = [Point3(0, 15, 0),
         Point3(10, 20, 0),
         Point3(-10, 6, 0),
         Point3(-17, 30, 0)]
        self.BossOffice_SuitHs = [170,
         120,
         12,
         38]
        self._wantBarrelRoom = config.GetBool('cogdo-want-barrel-room', 1)
        self.barrelRoom = CogdoBarrelRoom.CogdoBarrelRoom()
        self.brResults = [[], []]
        self.barrelRoomIntroTrack = None
        self.penthouseOutroTrack = None
        self.penthouseOutroChatDoneTrack = None
        self.penthouseIntroTrack = None
        self.waitMusic = base.loadMusic('phase_7/audio/bgm/encntr_toon_winning_indoor.ogg')
        self.elevatorMusic = base.loadMusic('phase_7/audio/bgm/tt_elevator.ogg')
        self.fsm = ClassicFSM.ClassicFSM('DistributedCogdoInterior', [State.State('WaitForAllToonsInside', self.enterWaitForAllToonsInside, self.exitWaitForAllToonsInside, ['Elevator']),
         State.State('Elevator', self.enterElevator, self.exitElevator, ['Game', 'BattleIntro', 'BarrelRoomIntro']),
         State.State('Game', self.enterGame, self.exitGame, ['Resting', 'Failed', 'BattleIntro', 'BarrelRoomIntro', 'Elevator']),
         State.State('BarrelRoomIntro', self.enterBarrelRoomIntro, self.exitBarrelRoomIntro, ['CollectBarrels', 'Off']),
         State.State('CollectBarrels', self.enterCollectBarrels, self.exitCollectBarrels, ['BarrelRoomReward', 'Off']),
         State.State('BarrelRoomReward', self.enterBarrelRoomReward, self.exitBarrelRoomReward, ['Battle',
          'ReservesJoining',
          'BattleIntro',
          'Off']),
         State.State('BattleIntro', self.enterBattleIntro, self.exitBattleIntro, ['Battle', 'ReservesJoining', 'Off']),
         State.State('Battle', self.enterBattle, self.exitBattle, ['Resting', 'Reward', 'ReservesJoining']),
         State.State('ReservesJoining', self.enterReservesJoining, self.exitReservesJoining, ['Battle']),
         State.State('Resting', self.enterResting, self.exitResting, ['Elevator']),
         State.State('Reward', self.enterReward, self.exitReward, ['Off']),
         State.State('Failed', self.enterFailed, self.exitFailed, ['Off']),
         State.State('Off', self.enterOff, self.exitOff, ['Elevator', 'WaitForAllToonsInside', 'Battle'])], 'Off', 'Off')
        self.fsm.enterInitialState()
        self._haveEntranceElevator = StateVar(False)
        self._stashEntranceElevator = StateVar(False)
        self._stashEntranceElevatorFC = FunctionCall(self._doStashEntranceElevator, self._haveEntranceElevator, self._stashEntranceElevator)
        self._entranceElevCallbacks = []
        self._doEntranceElevCallbacksFC = FunctionCall(self._doEntranceElevCallbacks, self._haveEntranceElevator)
        self.cage = None
        self.shopOwnerNpcId = None
        self.shopOwnerNpc = None
        self._movie = None
        self.SOSToonName = None
        self.FOType = None

    def setShopOwnerNpcId(self, npcId):
        self.shopOwnerNpcId = npcId

    def setSOSNpcId(self, npcId):
        self.SOSToonName = NPCToons.getNPCName(npcId)

    def setFOType(self, typeId):
        self.FOType = chr(typeId)

    def getFOType(self):
        return self.FOType

    def __uniqueName(self, name):
        DistributedCogdoInterior.id += 1
        return name + '%d' % DistributedCogdoInterior.id

    def generate(self):
        DistributedObject.DistributedObject.generate(self)
        self.announceGenerateName = self.uniqueName('generate')
#.........这里部分代码省略.........
开发者ID:BmanGames,项目名称:ToontownStride,代码行数:101,代码来源:DistributedCogdoInterior.py


注:本文中的direct.fsm.StatePush.FunctionCall类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。