def enter(self, requestStatus): self.fsm.enterInitialState() base.transitions.fadeOut(t=0) base.localAvatar.inventory.setRespectInvasions(0) base.cr.forbidCheesyEffects(1) self._telemLimiter = TLGatherAllAvs('MintInterior', RotationLimitToH) def commence(self = self): NametagGlobals.setWant2dNametags(True) self.fsm.request(requestStatus['how'], [requestStatus]) base.playMusic(self.music, looping=1, volume=0.8) base.transitions.irisIn() mint = bboard.get(DistributedMint.DistributedMint.ReadyPost) self.loader.hood.spawnTitleText(mint.mintId, mint.floorNum) self.mintReadyWatcher = BulletinBoardWatcher.BulletinBoardWatcher('MintReady', DistributedMint.DistributedMint.ReadyPost, commence) self.mintDefeated = 0 self.acceptOnce(DistributedMint.DistributedMint.WinEvent, self.handleMintWinEvent) if __debug__ and 0: self.accept('f10', lambda : messenger.send(DistributedMint.DistributedMint.WinEvent)) self.confrontedBoss = 0 def handleConfrontedBoss(self = self): self.confrontedBoss = 1 self.acceptOnce('localToonConfrontedMintBoss', handleConfrontedBoss)
def enter(self, requestStatus, visibilityFlag = 1, arrowsOn = 1): teleportDebug(requestStatus, 'Street.enter(%s)' % (requestStatus,)) self._ttfToken = None self.fsm.enterInitialState() base.playMusic(self.loader.music, looping=1, volume=0.8) self.loader.geom.reparentTo(render) if visibilityFlag: self.visibilityOn() base.localAvatar.setGeom(self.loader.geom) base.localAvatar.setOnLevelGround(1) self._telemLimiter = TLGatherAllAvs('Street', RotationLimitToH) NametagGlobals.setMasterArrowsOn(arrowsOn) self.zone = ZoneUtil.getBranchZone(requestStatus['zoneId']) def __lightDecorationOn__(): geom = base.cr.playGame.getPlace().loader.geom self.halloweenLights = geom.findAllMatches('**/*light*') self.halloweenLights += geom.findAllMatches('**/*lamp*') self.halloweenLights += geom.findAllMatches('**/prop_snow_tree*') for light in self.halloweenLights: light.setColorScaleOff(1) if base.cr.newsManager.isHolidayRunning(ToontownGlobals.HALLOWEEN) and self.loader.hood.spookySkyFile: lightsOff = Sequence(LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.1, Vec4(0.55, 0.55, 0.65, 1)), Func(self.loader.hood.startSpookySky)) lightsOff.start() else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.1, Vec4(1, 1, 1, 1)) lightsOn.start() self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) self.enterZone(requestStatus['zoneId']) self.tunnelOriginList = base.cr.hoodMgr.addLinkTunnelHooks(self, self.loader.nodeList) self.fsm.request(requestStatus['how'], [requestStatus])
def enter(self, requestStatus): self.fsm.enterInitialState() base.transitions.fadeOut(t=0) self._telemLimiter = TLGatherAllAvs("StageInterior", RotationLimitToH) base.localAvatar.inventory.setRespectInvasions(0) base.cr.forbidCheesyEffects(1) def commence(self=self): NametagGlobals.setWant2dNametags(True) self.fsm.request(requestStatus["how"], [requestStatus]) base.playMusic(self.music, looping=1, volume=0.8) base.transitions.irisIn() stage = bboard.get(DistributedStage.DistributedStage.ReadyPost) self.loader.hood.spawnTitleText(stage.stageId) self.stageReadyWatcher = BulletinBoardWatcher.BulletinBoardWatcher( "StageReady", DistributedStage.DistributedStage.ReadyPost, commence ) self.stageDefeated = 0 self.acceptOnce(DistributedStage.DistributedStage.WinEvent, self.handleStageWinEvent) if __debug__ and 0: self.accept("f10", lambda: messenger.send(DistributedStage.DistributedStage.WinEvent)) self.confrontedBoss = 0 def handleConfrontedBoss(self=self): self.confrontedBoss = 1 self.acceptOnce("localToonConfrontedStageBoss", handleConfrontedBoss)
def enter(self, requestStatus): self.fsm.enterInitialState() base.transitions.fadeOut(t=0) base.localAvatar.inventory.setRespectInvasions(0) self._telemLimiter = TLGatherAllAvs('FactoryInterior', RotationLimitToH) def commence(self = self): NametagGlobals.setMasterArrowsOn(1) self.fsm.request(requestStatus['how'], [requestStatus]) base.playMusic(self.music, looping=1, volume=0.8) base.transitions.irisIn() if hasattr(base, 'factoryReady'): commence() else: self.acceptOnce('FactoryReady', commence) self.factoryDefeated = 0 self.acceptOnce('FactoryWinEvent', self.handleFactoryWinEvent) if __debug__ and 0: self.accept('f10', lambda : messenger.send('FactoryWinEvent')) self.confrontedForeman = 0 def handleConfrontedForeman(self = self): self.confrontedForeman = 1 self.acceptOnce('localToonConfrontedForeman', handleConfrontedForeman)
def enter(self, requestStatus): self.zoneId = requestStatus['zoneId'] self.fsm.enterInitialState() messenger.send('enterHouse') self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) self._telemLimiter = TLGatherAllAvs('House', RotationLimitToH) NametagGlobals.setMasterArrowsOn(1) self.fsm.request(requestStatus['how'], [requestStatus])
def enter(self, requestStatus, bossCog): self.zoneId = requestStatus['zoneId'] BattlePlace.BattlePlace.enter(self) self.fsm.enterInitialState() self.bossCog = bossCog if self.bossCog: self.bossCog.d_avatarEnter() self._telemLimiter = TLGatherAllAvs('CogHQBossBattle', RotationLimitToH) NametagGlobals.setWant2dNametags(True) base.localAvatar.inventory.setRespectInvasions(0) self.fsm.request(requestStatus['how'], [requestStatus])
def enter(self, requestStatus): self.zoneId = requestStatus['zoneId'] Place.Place.enter(self) self.fsm.enterInitialState() base.playMusic(self.loader.music, looping=1, volume=0.8) self.loader.geom.reparentTo(render) self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) how = requestStatus['how'] self.fsm.request(how, [requestStatus]) self._telemLimiter = TLGatherAllAvs('CogHQLobby', RotationLimitToH)
def enter(self, requestStatus): self.zoneId = requestStatus["zoneId"] self.fsm.enterInitialState() messenger.send("enterToonInterior") self.accept("doorDoneEvent", self.handleDoorDoneEvent) self.accept("DistributedDoor_doorTrigger", self.handleDoorTrigger) volume = requestStatus.get("musicVolume", 0.7) base.playMusic(self.loader.activityMusic, looping=1, volume=volume) self._telemLimiter = TLGatherAllAvs("ToonInterior", RotationLimitToH) NametagGlobals.setMasterArrowsOn(1) self.fsm.request(requestStatus["how"], [requestStatus])
def enter(self, requestStatus): self.zoneId = requestStatus['zoneId'] self.fsm.enterInitialState() messenger.send('enterToonInterior') self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) volume = requestStatus.get('musicVolume', 0.7) base.playMusic(self.loader.activityMusic, looping=1, volume=volume) self._telemLimiter = TLGatherAllAvs('ToonInterior', RotationLimitToH) NametagGlobals.setMasterArrowsOn(1) self.fsm.request(requestStatus['how'], [requestStatus])
def enter(self, requestStatus, bossCog): self.zoneId = requestStatus["zoneId"] BattlePlace.BattlePlace.enter(self) self.fsm.enterInitialState() self.bossCog = bossCog if self.bossCog: self.bossCog.d_avatarEnter() self._telemLimiter = TLGatherAllAvs("CogHQBossBattle", RotationLimitToH) NametagGlobals.setMasterArrowsOn(1) base.localAvatar.inventory.setRespectInvasions(0) self.fsm.request(requestStatus["how"], [requestStatus])
def enter(self, requestStatus, visibilityFlag=1, arrowsOn=1): teleportDebug(requestStatus, "Street.enter(%s)" % (requestStatus,)) self._ttfToken = None self.fsm.enterInitialState() base.playMusic(self.loader.music, looping=1, volume=0.80000000000000004) self.loader.geom.reparentTo(render) if visibilityFlag: self.visibilityOn() base.localAvatar.setGeom(self.loader.geom) base.localAvatar.setOnLevelGround(1) self._telemLimiter = TLGatherAllAvs("Street", RotationLimitToH) NametagGlobals.setMasterArrowsOn(arrowsOn) def __lightDecorationOn__(): geom = base.cr.playGame.getPlace().loader.geom self.halloweenLights = geom.findAllMatches("**/*light*") self.halloweenLights += geom.findAllMatches("**/*lamp*") self.halloweenLights += geom.findAllMatches("**/prop_snow_tree*") for light in self.halloweenLights: light.setColorScaleOff(1) newsManager = base.cr.newsManager if newsManager: holidayIds = base.cr.newsManager.getDecorationHolidayId() if ( ToontownGlobals.HALLOWEEN_COSTUMES in holidayIds or ToontownGlobals.SPOOKY_COSTUMES in holidayIds ) and self.loader.hood.spookySkyFile: lightsOff = Sequence( LerpColorScaleInterval( base.cr.playGame.hood.loader.geom, 0.10000000000000001, Vec4(0.55000000000000004, 0.55000000000000004, 0.65000000000000002, 1), ), Func(self.loader.hood.startSpookySky), ) lightsOff.start() else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval( base.cr.playGame.hood.loader.geom, 0.10000000000000001, Vec4(1, 1, 1, 1) ) lightsOn.start() else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.10000000000000001, Vec4(1, 1, 1, 1)) lightsOn.start() self.accept("doorDoneEvent", self.handleDoorDoneEvent) self.accept("DistributedDoor_doorTrigger", self.handleDoorTrigger) self.enterZone(requestStatus["zoneId"]) self.tunnelOriginList = base.cr.hoodMgr.addLinkTunnelHooks(self, self.loader.nodeList, self.zoneId) self.fsm.request(requestStatus["how"], [requestStatus]) self.replaceStreetSignTextures()
def enter(self, requestStatus): self.zoneId = requestStatus["zoneId"] BattlePlace.BattlePlace.enter(self) self.fsm.enterInitialState() base.playMusic(self.loader.music, looping=1, volume=0.8) self.loader.geom.reparentTo(render) self.nodeList = [self.loader.geom] self._telemLimiter = TLGatherAllAvs("CogHQExterior", RotationLimitToH) self.accept("doorDoneEvent", self.handleDoorDoneEvent) self.accept("DistributedDoor_doorTrigger", self.handleDoorTrigger) NametagGlobals.setMasterArrowsOn(1) self.tunnelOriginList = base.cr.hoodMgr.addLinkTunnelHooks(self, self.nodeList, self.zoneId) how = requestStatus["how"] self.fsm.request(how, [requestStatus])
def enter(self, requestStatus): self.fsm.enterInitialState() messenger.send('enterPlayground') self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) base.playMusic(self.loader.music, looping=1, volume=0.8) self.loader.geom.reparentTo(render) for i in self.loader.nodeList: self.loader.enterAnimatedProps(i) self._telemLimiter = TLGatherAllAvs('Playground', RotationLimitToH) def __lightDecorationOn__(): geom = base.cr.playGame.hood.loader.geom self.loader.hood.eventLights = geom.findAllMatches('**/*light*') self.loader.hood.eventLights += geom.findAllMatches('**/*lamp*') self.loader.hood.eventLights += geom.findAllMatches('**/prop_snow_tree*') self.loader.hood.eventLights += geom.findAllMatches('**/prop_tree*') self.loader.hood.eventLights += geom.findAllMatches('**/*christmas*') for light in self.loader.hood.eventLights: light.setColorScaleOff(0) if base.cr.newsManager.isHolidayRunning(ToontownGlobals.HALLOWEEN) and self.loader.hood.spookySkyFile: lightsOff = Sequence(LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.1, Vec4(0.55, 0.55, 0.65, 1)), Func(self.loader.hood.startSpookySky), Func(__lightDecorationOn__)) lightsOff.start() elif base.cr.newsManager.isHolidayRunning(ToontownGlobals.CHRISTMAS) and self.loader.hood.snowySkyFile: lightsOff = Sequence(LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.1, Vec4(0.7, 0.7, 0.8, 1)), Func(self.loader.hood.startSnowySky), Func(__lightDecorationOn__)) lightsOff.start() self.snowEvent = BattleParticles.loadParticleFile('snowdisk.ptf') self.snowEvent.setPos(0, 30, 10) self.snowEventRender = base.cr.playGame.hood.loader.geom.attachNewNode('snowRender') self.snowEventRender.setDepthWrite(2) self.snowEventRender.setBin('fixed', 1) self.snowEventFade = None self.snowEvent.start(camera, self.snowEventRender) else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.1, Vec4(1, 1, 1, 1)) lightsOn.start() NametagGlobals.setMasterArrowsOn(1) self.zoneId = requestStatus['zoneId'] self.tunnelOriginList = base.cr.hoodMgr.addLinkTunnelHooks(self, self.loader.nodeList) how = requestStatus['how'] if how == 'teleportIn': how = 'deathAck' self.fsm.request(how, [requestStatus])
def enter(self, requestStatus): hoodId = requestStatus['hoodId'] zoneId = requestStatus['zoneId'] if config.GetBool('want-party-telemetry-limiter', 1): limiter = TLGatherAllAvs('Party', RotationLimitToH) else: limiter = TLNull() self._telemLimiter = limiter self.loader.hood.startSky() for i in self.loader.nodeList: self.loader.enterAnimatedProps(i) self.loader.geom.reparentTo(render) self.fsm.request(requestStatus['how'], [requestStatus]) self.playMusic()
def enter(self, requestStatus): self.zoneId = requestStatus['zoneId'] self.updateVis(self.zoneId) BattlePlace.BattlePlace.enter(self) self.fsm.enterInitialState() base.playMusic(self.loader.music, looping=1, volume=0.8) self.loader.geom.reparentTo(render) self.nodeList = [self.loader.geom] self.loader.hood.startSky() self._telemLimiter = TLGatherAllAvs('FactoryExterior', RotationLimitToH) self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) NametagGlobals.setMasterArrowsOn(1) self.tunnelOriginList = base.cr.hoodMgr.addLinkTunnelHooks(self, self.nodeList, self.zoneId) how = requestStatus['how'] self.fsm.request(how, [requestStatus])
def enter(self, requestStatus): self.fsm.enterInitialState() messenger.send('enterPlayground') self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) base.playMusic(self.loader.music, looping = 1, volume = 0.80000000000000004) self.loader.geom.reparentTo(render) for i in self.loader.nodeList: self.loader.enterAnimatedProps(i) self._telemLimiter = TLGatherAllAvs('Playground', RotationLimitToH) def __lightDecorationOn__(): geom = base.cr.playGame.hood.loader.geom self.loader.hood.halloweenLights = geom.findAllMatches('**/*light*') self.loader.hood.halloweenLights += geom.findAllMatches('**/*lamp*') self.loader.hood.halloweenLights += geom.findAllMatches('**/prop_snow_tree*') for light in self.loader.hood.halloweenLights: light.setColorScaleOff(0) newsManager = base.cr.newsManager if newsManager: holidayIds = base.cr.newsManager.getDecorationHolidayId() if (ToontownGlobals.HALLOWEEN_COSTUMES in holidayIds or ToontownGlobals.SPOOKY_COSTUMES in holidayIds) and self.loader.hood.spookySkyFile: lightsOff = Sequence(LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.10000000000000001, Vec4(0.55000000000000004, 0.55000000000000004, 0.65000000000000002, 1)), Func(self.loader.hood.startSpookySky), Func(__lightDecorationOn__)) lightsOff.start() else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.10000000000000001, Vec4(1, 1, 1, 1)) lightsOn.start() else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.10000000000000001, Vec4(1, 1, 1, 1)) lightsOn.start() NametagGlobals.setMasterArrowsOn(1) self.zoneId = requestStatus['zoneId'] self.tunnelOriginList = base.cr.hoodMgr.addLinkTunnelHooks(self, self.loader.nodeList, self.zoneId) how = requestStatus['how'] if how == 'teleportIn': how = 'deathAck' self.fsm.request(how, [ requestStatus])
def enter(self, requestStatus): hoodId = requestStatus['hoodId'] zoneId = requestStatus['zoneId'] newsManager = base.cr.newsManager if config.GetBool('want-estate-telemetry-limiter', 1): limiter = TLGatherAllAvs('Estate', RotationLimitToH) else: limiter = TLNull() self._telemLimiter = limiter if newsManager: holidayIds = base.cr.newsManager.getDecorationHolidayId() if (ToontownGlobals.HALLOWEEN_COSTUMES in holidayIds or ToontownGlobals.SPOOKY_COSTUMES in holidayIds) and self.loader.hood.spookySkyFile: lightsOff = Sequence( LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.1, Vec4(0.55, 0.55, 0.65, 1)), Func(self.loader.hood.startSpookySky)) lightsOff.start() else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval( base.cr.playGame.hood.loader.geom, 0.1, Vec4(1, 1, 1, 1)) lightsOn.start() else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval( base.cr.playGame.hood.loader.geom, 0.1, Vec4(1, 1, 1, 1)) lightsOn.start() self.loader.hood.sky.setFogOff() self.__setFaintFog() for i in self.loader.nodeList: self.loader.enterAnimatedProps(i) self.loader.geom.reparentTo(render) # The client April Toons Manager is currently broken, so we have to do this hacky thing instead. :( #if hasattr(base.cr, 'aprilToonsMgr'): #if self.isEventActive(AprilToonsGlobals.EventEstateGravity): #base.localAvatar.startAprilToonsControls() if base.config.GetBool('want-april-toons'): base.localAvatar.startAprilToonsControls() self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) self.fsm.request(requestStatus['how'], [requestStatus])
def enter(self, requestStatus): hoodId = requestStatus['hoodId'] zoneId = requestStatus['zoneId'] newsManager = base.cr.newsManager if config.GetBool('want-estate-telemetry-limiter', 1): limiter = TLGatherAllAvs('Estate', RotationLimitToH) else: limiter = TLNull() self._telemLimiter = limiter if newsManager: holidayIds = base.cr.newsManager.getDecorationHolidayId() if (ToontownGlobals.HALLOWEEN_COSTUMES in holidayIds or ToontownGlobals.SPOOKY_COSTUMES in holidayIds) and self.loader.hood.spookySkyFile: lightsOff = Sequence( LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.1, Vec4(0.55, 0.55, 0.65, 1)), Func(self.loader.hood.startSpookySky)) lightsOff.start() else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval( base.cr.playGame.hood.loader.geom, 0.1, Vec4(1, 1, 1, 1)) lightsOn.start() else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval( base.cr.playGame.hood.loader.geom, 0.1, Vec4(1, 1, 1, 1)) lightsOn.start() self.loader.hood.sky.setFogOff() self.__setFaintFog() for i in self.loader.nodeList: self.loader.enterAnimatedProps(i) self.loader.geom.reparentTo(render) if base.cr.newsManager: if base.cr.newsManager.isHolidayRunning( ToontownGlobals.APRIL_FOOLS_COSTUMES): base.localAvatar.startAprilToonsControls() self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) base.playMusic(self.loader.music, looping=1, volume=0.8) self.fsm.request(requestStatus['how'], [requestStatus])
def enter(self, requestStatus): self.zoneId = requestStatus['zoneId'] # Load the CogHQ DNA file: dnaStore = DNAStorage() dnaFileName = self.genDNAFileName(self.zoneId) if not dnaFileName.endswith('13200.dna'): loadDNAFileAI(dnaStore, dnaFileName) # Collect all of the vis group zone IDs: self.zoneVisDict = {} for i in xrange(dnaStore.getNumDNAVisGroupsAI()): groupFullName = dnaStore.getDNAVisGroupName(i) visGroup = dnaStore.getDNAVisGroupAI(i) visZoneId = int(base.cr.hoodMgr.extractGroupName(groupFullName)) visZoneId = ZoneUtil.getTrueZoneId(visZoneId, self.zoneId) visibles = [] for i in xrange(visGroup.getNumVisibles()): visibles.append(int(visGroup.visibles[i])) visibles.append(ZoneUtil.getBranchZone(visZoneId)) self.zoneVisDict[visZoneId] = visibles # Next, we want interest in all vis groups due to this being a Cog HQ: base.cr.sendSetZoneMsg(self.zoneId, self.zoneVisDict.values()[0]) BattlePlace.BattlePlace.enter(self) self.fsm.enterInitialState() base.playMusic(self.loader.music, looping=1, volume=0.8) self.loader.geom.reparentTo(render) self.nodeList = [self.loader.geom] self.loader.hood.startSky() self._telemLimiter = TLGatherAllAvs('FactoryExterior', RotationLimitToH) self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) NametagGlobals.setMasterArrowsOn(1) self.tunnelOriginList = base.cr.hoodMgr.addLinkTunnelHooks(self, self.nodeList, self.zoneId) how = requestStatus['how'] self.fsm.request(how, [requestStatus])
def enter(self, requestStatus): hoodId = requestStatus['hoodId'] zoneId = requestStatus['zoneId'] newsManager = base.cr.newsManager if config.GetBool('want-estate-telemetry-limiter', 1): limiter = TLGatherAllAvs('Estate', RotationLimitToH) else: limiter = TLNull() self._telemLimiter = limiter if newsManager: holidayIds = base.cr.newsManager.getDecorationHolidayId() if (ToontownGlobals.HALLOWEEN_COSTUMES in holidayIds or ToontownGlobals.SPOOKY_COSTUMES in holidayIds) and self.loader.hood.spookySkyFile: lightsOff = Sequence(LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.10000000000000001, Vec4(0.55000000000000004, 0.55000000000000004, 0.65000000000000002, 1)), Func(self.loader.hood.startSpookySky)) lightsOff.start() else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.10000000000000001, Vec4(1, 1, 1, 1)) lightsOn.start() else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.10000000000000001, Vec4(1, 1, 1, 1)) lightsOn.start() self.loader.hood.sky.setFogOff() self._Estate__setFaintFog() for i in self.loader.nodeList: self.loader.enterAnimatedProps(i) self.loader.geom.reparentTo(render) if hasattr(base.cr, 'newsManager') and base.cr.newsManager: holidayIds = base.cr.newsManager.getHolidayIdList() if ToontownGlobals.APRIL_FOOLS_COSTUMES in holidayIds or ToontownGlobals.SILLYMETER_EXT_HOLIDAY in holidayIds: self.startAprilFoolsControls() self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) self.fsm.request(requestStatus['how'], [ requestStatus])
def enter(self, requestStatus): if self.dnaFile is not None: dna = loader.loadDNA(self.dnaFile) visgroups = DNAUtil.getVisGroups(dna) visZones = [] for vg in visgroups: if vg.getZone() == dna.zone: visZones = vg.getVisibleZones() break self.visInterest = base.cr.addInterest(base.localAvatar.defaultShard, visZones, 'cogHQVis') self.zoneId = requestStatus['zoneId'] BattlePlace.BattlePlace.enter(self) self.fsm.enterInitialState() base.playMusic(self.loader.music, looping=1, volume=0.8) self.loader.geom.reparentTo(render) self.nodeList = [self.loader.geom] self._telemLimiter = TLGatherAllAvs('CogHQExterior', RotationLimitToH) self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) NametagGlobals.setMasterArrowsOn(1) self.tunnelOriginList = base.cr.hoodMgr.addLinkTunnelHooks(self, self.nodeList, self.zoneId) how = requestStatus['how'] self.fsm.request(how, [requestStatus])
def enter(self, requestStatus): self.fsm.enterInitialState() messenger.send('enterPlayground') self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) base.playMusic(self.loader.music, looping=1, volume=0.8) self.loader.geom.reparentTo(render) for i in self.loader.nodeList: self.loader.enterAnimatedProps(i) self._telemLimiter = TLGatherAllAvs('Playground', RotationLimitToH) def __lightDecorationOn__(): geom = base.cr.playGame.hood.loader.geom self.loader.hood.eventLights = geom.findAllMatches('**/*light*') self.loader.hood.eventLights += geom.findAllMatches('**/*lamp*') self.loader.hood.eventLights += geom.findAllMatches( '**/prop_snow_tree*') self.loader.hood.eventLights += geom.findAllMatches( '**/prop_tree*') self.loader.hood.eventLights += geom.findAllMatches( '**/*christmas*') for light in self.loader.hood.eventLights: light.setColorScaleOff(0) newsManager = base.cr.newsManager if newsManager: holidayIds = base.cr.newsManager.getDecorationHolidayId() #Halloween Event if (ToontownGlobals.HALLOWEEN_COSTUMES in holidayIds or ToontownGlobals.SPOOKY_COSTUMES in holidayIds) and self.loader.hood.spookySkyFile: lightsOff = Sequence( LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.1, Vec4(0.55, 0.55, 0.65, 1)), Func(self.loader.hood.startSpookySky), Func(__lightDecorationOn__)) lightsOff.start() else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval( base.cr.playGame.hood.loader.geom, 0.1, Vec4(1, 1, 1, 1)) lightsOn.start() #Christmas Event if (ToontownGlobals.WINTER_DECORATIONS in holidayIds or ToontownGlobals.WACKY_WINTER_DECORATIONS in holidayIds) and self.loader.hood.snowySkyFile: lightsOff = Sequence( LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.1, Vec4(0.7, 0.7, 0.8, 1)), Func(self.loader.hood.startSnowySky), Func(__lightDecorationOn__)) lightsOff.start() self.snowEvent = BattleParticles.loadParticleFile( 'snowdisk.ptf') self.snowEvent.setPos(0, 30, 10) #2 and 3 are only for the blizzard event and should be removed self.snowEvent2 = BattleParticles.loadParticleFile( 'snowdisk.ptf') self.snowEvent2.setPos(0, 10, 10) self.snowEvent3 = BattleParticles.loadParticleFile( 'snowdisk.ptf') self.snowEvent3.setPos(0, 20, 5) self.snowEventRender = base.cr.playGame.hood.loader.geom.attachNewNode( 'snowRender') self.snowEventRender.setDepthWrite(2) self.snowEventRender.setBin('fixed', 1) self.snowEventFade = None self.snowEvent.start(camera, self.snowEventRender) #2 and 3 are only for the blizzard event and should be removed self.snowEvent2.start(camera, self.snowEventRender) self.snowEvent3.start(camera, self.snowEventRender) else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval( base.cr.playGame.hood.loader.geom, 0.1, Vec4(1, 1, 1, 1)) lightsOn.start() else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval( base.cr.playGame.hood.loader.geom, 0.1, Vec4(1, 1, 1, 1)) lightsOn.start() NametagGlobals.setWant2dNametags(True) self.zoneId = requestStatus['zoneId'] self.tunnelOriginList = base.cr.hoodMgr.addLinkTunnelHooks( self, self.loader.nodeList, self.zoneId) how = requestStatus['how'] if how == 'teleportIn': how = 'deathAck' self.fsm.request(how, [requestStatus]) if base.config.GetBool('want-charity-screen', False): from toontown.events.CharityScreen import CharityScreen if self.zoneId in ([ ToontownGlobals.ToontownCentral, ToontownGlobals.DonaldsDock, ToontownGlobals.DaisyGardens, ToontownGlobals.MinniesMelodyland, ToontownGlobals.TheBrrrgh, ToontownGlobals.DonaldsDreamland ]): self.screen = CharityScreen(base.cr) self.screen.start(self.zoneId)
def enter(self, requestStatus, visibilityFlag=1, arrowsOn=1): teleportDebug(requestStatus, 'Street.enter(%s)' % (requestStatus, )) self._ttfToken = None self.fsm.enterInitialState() base.playMusic(self.loader.music, looping=1, volume=0.8) self.loader.geom.reparentTo(render) if visibilityFlag: self.visibilityOn() base.localAvatar.setGeom(self.loader.geom) base.localAvatar.setOnLevelGround(1) self._telemLimiter = TLGatherAllAvs('Street', RotationLimitToH) NametagGlobals.setMasterArrowsOn(arrowsOn) def __lightDecorationOn__(): geom = base.cr.playGame.getPlace().loader.geom self.loader.hood.eventLights = geom.findAllMatches('**/*light*') self.loader.hood.eventLights += geom.findAllMatches('**/*lamp*') self.loader.hood.eventLights += geom.findAllMatches( '**/prop_snow_tree*') self.loader.hood.eventLights += geom.findAllMatches( '**/prop_tree*') self.loader.hood.eventLights += geom.findAllMatches( '**/*christmas*') for light in self.loader.hood.eventLights: light.setColorScaleOff(1) newsManager = base.cr.newsManager if newsManager: holidayIds = base.cr.newsManager.getDecorationHolidayId() if (ToontownGlobals.HALLOWEEN_COSTUMES in holidayIds or ToontownGlobals.SPOOKY_COSTUMES in holidayIds or base.cr.newsManager.isHolidayRunning( ToontownGlobals.HALLOWEEN) ) and self.loader.hood.spookySkyFile: lightsOff = Sequence( LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.1, Vec4(0.55, 0.55, 0.65, 1)), Func(self.loader.hood.startSpookySky)) lightsOff.start() else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval( base.cr.playGame.hood.loader.geom, 0.1, Vec4(1, 1, 1, 1)) lightsOn.start() if (ToontownGlobals.WINTER_DECORATIONS in holidayIds or ToontownGlobals.WACKY_WINTER_DECORATIONS in holidayIds) and self.loader.hood.snowySkyFile: lightsOff = Sequence( LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.1, Vec4(0.7, 0.7, 0.8, 1)), Func(self.loader.hood.startSnowySky), Func(__lightDecorationOn__)) lightsOff.start() self.snowEvent = BattleParticles.loadParticleFile( 'snowdisk.ptf') self.snowEvent.setPos(0, 30, 10) self.snowEvent2 = BattleParticles.loadParticleFile( 'snowdisk.ptf') self.snowEvent2.setPos(0, 10, 10) self.snowEvent3 = BattleParticles.loadParticleFile( 'snowdisk.ptf') self.snowEvent3.setPos(0, 20, 5) self.snowEventRender = base.cr.playGame.hood.loader.geom.attachNewNode( 'snowRender') self.snowEventRender.setDepthWrite(2) self.snowEventRender.setBin('fixed', 1) self.snowEventFade = None self.snowEvent.start(camera, self.snowEventRender) self.snowEvent2.start(camera, self.snowEventRender) self.snowEvent3.start(camera, self.snowEventRender) else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval( base.cr.playGame.hood.loader.geom, 0.1, Vec4(1, 1, 1, 1)) lightsOn.start() else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval( base.cr.playGame.hood.loader.geom, 0.1, Vec4(1, 1, 1, 1)) lightsOn.start() self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) self.enterZone(requestStatus['zoneId']) self.tunnelOriginList = base.cr.hoodMgr.addLinkTunnelHooks( self, self.loader.nodeList, self.zoneId) self.fsm.request(requestStatus['how'], [requestStatus]) self.replaceStreetSignTextures() return
class CogHQExterior(BattlePlace.BattlePlace): notify = DirectNotifyGlobal.directNotify.newCategory('CogHQExterior') def __init__(self, loader, parentFSM, doneEvent): BattlePlace.BattlePlace.__init__(self, loader, doneEvent) self.parentFSM = parentFSM self.fsm = ClassicFSM.ClassicFSM('CogHQExterior', [ State.State('start', self.enterStart, self.exitStart, [ 'walk', 'tunnelIn', 'teleportIn', 'doorIn']), State.State('walk', self.enterWalk, self.exitWalk, [ 'stickerBook', 'teleportOut', 'tunnelOut', 'DFA', 'doorOut', 'died', 'stopped', 'WaitForBattle', 'battle', 'squished', 'stopped']), State.State('stopped', self.enterStopped, self.exitStopped, [ 'walk', 'teleportOut', 'stickerBook']), State.State('doorIn', self.enterDoorIn, self.exitDoorIn, [ 'walk', 'stopped']), State.State('doorOut', self.enterDoorOut, self.exitDoorOut, [ 'walk', 'stopped']), State.State('stickerBook', self.enterStickerBook, self.exitStickerBook, [ 'walk', 'DFA', 'WaitForBattle', 'battle', 'tunnelOut', 'doorOut', 'squished', 'died']), State.State('WaitForBattle', self.enterWaitForBattle, self.exitWaitForBattle, [ 'battle', 'walk']), State.State('battle', self.enterBattle, self.exitBattle, [ 'walk', 'teleportOut', 'died']), State.State('DFA', self.enterDFA, self.exitDFA, [ 'DFAReject', 'teleportOut', 'tunnelOut']), State.State('DFAReject', self.enterDFAReject, self.exitDFAReject, [ 'walk']), State.State('squished', self.enterSquished, self.exitSquished, [ 'walk', 'died', 'teleportOut']), State.State('teleportIn', self.enterTeleportIn, self.exitTeleportIn, [ 'walk', 'WaitForBattle', 'battle']), State.State('teleportOut', self.enterTeleportOut, self.exitTeleportOut, [ 'teleportIn', 'final', 'WaitForBattle']), State.State('died', self.enterDied, self.exitDied, [ 'quietZone']), State.State('tunnelIn', self.enterTunnelIn, self.exitTunnelIn, [ 'walk', 'WaitForBattle', 'battle']), State.State('tunnelOut', self.enterTunnelOut, self.exitTunnelOut, [ 'final']), State.State('final', self.enterFinal, self.exitFinal, [ 'start'])], 'start', 'final') def load(self): self.parentFSM.getStateNamed('cogHQExterior').addChild(self.fsm) BattlePlace.BattlePlace.load(self) def unload(self): self.parentFSM.getStateNamed('cogHQExterior').removeChild(self.fsm) del self.fsm BattlePlace.BattlePlace.unload(self) def enter(self, requestStatus): self.zoneId = requestStatus['zoneId'] BattlePlace.BattlePlace.enter(self) self.fsm.enterInitialState() base.playMusic(self.loader.music, looping = 1, volume = 0.80000000000000004) self.loader.geom.reparentTo(render) self.nodeList = [ self.loader.geom] self._telemLimiter = TLGatherAllAvs('CogHQExterior', RotationLimitToH) self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) NametagGlobals.setMasterArrowsOn(1) self.tunnelOriginList = base.cr.hoodMgr.addLinkTunnelHooks(self, self.nodeList, self.zoneId) how = requestStatus['how'] self.fsm.request(how, [ requestStatus]) def exit(self): self.fsm.requestFinalState() self._telemLimiter.destroy() del self._telemLimiter self.loader.music.stop() for node in self.tunnelOriginList: node.removeNode() del self.tunnelOriginList if self.loader.geom: self.loader.geom.reparentTo(hidden) self.ignoreAll() BattlePlace.BattlePlace.exit(self) def enterTunnelOut(self, requestStatus): fromZoneId = self.zoneId - self.zoneId % 100 tunnelName = base.cr.hoodMgr.makeLinkTunnelName(self.loader.hood.id, fromZoneId) requestStatus['tunnelName'] = tunnelName BattlePlace.BattlePlace.enterTunnelOut(self, requestStatus) def enterTeleportIn(self, requestStatus): (x, y, z, h, p, r) = base.cr.hoodMgr.getPlaygroundCenterFromId(self.loader.hood.id) base.localAvatar.setPosHpr(render, x, y, z, h, p, r) BattlePlace.BattlePlace.enterTeleportIn(self, requestStatus) def enterTeleportOut(self, requestStatus, callback = None): if requestStatus.has_key('battle'): self._CogHQExterior__teleportOutDone(requestStatus) else: BattlePlace.BattlePlace.enterTeleportOut(self, requestStatus, self._CogHQExterior__teleportOutDone) def _CogHQExterior__teleportOutDone(self, requestStatus): hoodId = requestStatus['hoodId'] zoneId = requestStatus['zoneId'] avId = requestStatus['avId'] shardId = requestStatus['shardId'] if hoodId == self.loader.hood.hoodId and zoneId == self.loader.hood.hoodId and shardId == None: self.fsm.request('teleportIn', [ requestStatus]) elif hoodId == ToontownGlobals.MyEstate: self.getEstateZoneAndGoHome(requestStatus) else: self.doneStatus = requestStatus messenger.send(self.doneEvent) def exitTeleportOut(self): BattlePlace.BattlePlace.exitTeleportOut(self) def enterSquished(self): base.localAvatar.laffMeter.start() base.localAvatar.b_setAnimState('Squish') taskMgr.doMethodLater(2.0, self.handleSquishDone, base.localAvatar.uniqueName('finishSquishTask')) def handleSquishDone(self, extraArgs = []): base.cr.playGame.getPlace().setState('walk') def exitSquished(self): taskMgr.remove(base.localAvatar.uniqueName('finishSquishTask')) base.localAvatar.laffMeter.stop()
class FactoryExterior(BattlePlace.BattlePlace): notify = DirectNotifyGlobal.directNotify.newCategory('FactoryExterior') def __init__(self, loader, parentFSM, doneEvent): BattlePlace.BattlePlace.__init__(self, loader, doneEvent) self.parentFSM = parentFSM self.elevatorDoneEvent = 'elevatorDone' def load(self): self.fsm = ClassicFSM.ClassicFSM('FactoryExterior', [State.State('start', self.enterStart, self.exitStart, ['walk', 'tunnelIn', 'teleportIn', 'doorIn']), State.State('walk', self.enterWalk, self.exitWalk, ['stickerBook', 'teleportOut', 'tunnelOut', 'DFA', 'doorOut', 'elevator', 'stopped', 'WaitForBattle', 'battle']), State.State('stopped', self.enterStopped, self.exitStopped, ['walk', 'teleportOut', 'elevator']), State.State('stickerBook', self.enterStickerBook, self.exitStickerBook, ['walk', 'DFA', 'WaitForBattle', 'battle', 'elevator']), State.State('WaitForBattle', self.enterWaitForBattle, self.exitWaitForBattle, ['battle', 'walk']), State.State('battle', self.enterBattle, self.exitBattle, ['walk', 'teleportOut', 'died']), State.State('DFA', self.enterDFA, self.exitDFA, ['DFAReject', 'teleportOut', 'tunnelOut']), State.State('DFAReject', self.enterDFAReject, self.exitDFAReject, ['walk']), State.State('teleportIn', self.enterTeleportIn, self.exitTeleportIn, ['walk']), State.State('teleportOut', self.enterTeleportOut, self.exitTeleportOut, ['teleportIn', 'final', 'WaitForBattle']), State.State('doorIn', self.enterDoorIn, self.exitDoorIn, ['walk']), State.State('doorOut', self.enterDoorOut, self.exitDoorOut, ['walk']), State.State('died', self.enterDied, self.exitDied, ['quietZone']), State.State('tunnelIn', self.enterTunnelIn, self.exitTunnelIn, ['walk']), State.State('tunnelOut', self.enterTunnelOut, self.exitTunnelOut, ['final']), State.State('elevator', self.enterElevator, self.exitElevator, ['walk', 'stopped']), State.State('final', self.enterFinal, self.exitFinal, ['start'])], 'start', 'final') self.parentFSM.getStateNamed('factoryExterior').addChild(self.fsm) BattlePlace.BattlePlace.load(self) def unload(self): self.parentFSM.getStateNamed('factoryExterior').removeChild(self.fsm) del self.fsm BattlePlace.BattlePlace.unload(self) def enter(self, requestStatus): self.zoneId = requestStatus['zoneId'] # Load the CogHQ DNA file: dnaStore = DNAStorage() dnaFileName = self.genDNAFileName(self.zoneId) if not dnaFileName.endswith('13200.dna'): loadDNAFileAI(dnaStore, dnaFileName) # Collect all of the vis group zone IDs: self.zoneVisDict = {} for i in xrange(dnaStore.getNumDNAVisGroupsAI()): groupFullName = dnaStore.getDNAVisGroupName(i) visGroup = dnaStore.getDNAVisGroupAI(i) visZoneId = int(base.cr.hoodMgr.extractGroupName(groupFullName)) visZoneId = ZoneUtil.getTrueZoneId(visZoneId, self.zoneId) visibles = [] for i in xrange(visGroup.getNumVisibles()): visibles.append(int(visGroup.visibles[i])) visibles.append(ZoneUtil.getBranchZone(visZoneId)) self.zoneVisDict[visZoneId] = visibles # Next, we want interest in all vis groups due to this being a Cog HQ: base.cr.sendSetZoneMsg(self.zoneId, self.zoneVisDict.values()[0]) BattlePlace.BattlePlace.enter(self) self.fsm.enterInitialState() base.playMusic(self.loader.music, looping=1, volume=0.8) self.loader.geom.reparentTo(render) self.nodeList = [self.loader.geom] self.loader.hood.startSky() self._telemLimiter = TLGatherAllAvs('FactoryExterior', RotationLimitToH) self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) NametagGlobals.setMasterArrowsOn(1) self.tunnelOriginList = base.cr.hoodMgr.addLinkTunnelHooks(self, self.nodeList, self.zoneId) how = requestStatus['how'] self.fsm.request(how, [requestStatus]) def exit(self): self._telemLimiter.destroy() del self._telemLimiter self.loader.hood.stopSky() self.fsm.requestFinalState() self.loader.music.stop() for node in self.tunnelOriginList: node.removeNode() del self.tunnelOriginList del self.nodeList self.ignoreAll() BattlePlace.BattlePlace.exit(self) def enterTunnelOut(self, requestStatus): fromZoneId = self.zoneId - self.zoneId % 100 tunnelName = base.cr.hoodMgr.makeLinkTunnelName(self.loader.hood.id, fromZoneId) requestStatus['tunnelName'] = tunnelName BattlePlace.BattlePlace.enterTunnelOut(self, requestStatus) def enterTeleportIn(self, requestStatus): base.localAvatar.setPosHpr(-34, -350, 0, -28, 0, 0) BattlePlace.BattlePlace.enterTeleportIn(self, requestStatus) def enterTeleportOut(self, requestStatus): BattlePlace.BattlePlace.enterTeleportOut(self, requestStatus, self.__teleportOutDone) def __teleportOutDone(self, requestStatus): hoodId = requestStatus['hoodId'] zoneId = requestStatus['zoneId'] avId = requestStatus['avId'] shardId = requestStatus['shardId'] if hoodId == self.loader.hood.hoodId and zoneId == self.zoneId and shardId == None: self.fsm.request('teleportIn', [requestStatus]) elif hoodId == ToontownGlobals.MyEstate: self.getEstateZoneAndGoHome(requestStatus) else: self.doneStatus = requestStatus messenger.send(self.doneEvent) return def exitTeleportOut(self): BattlePlace.BattlePlace.exitTeleportOut(self) def enterElevator(self, distElevator, skipDFABoard = 0): self.accept(self.elevatorDoneEvent, self.handleElevatorDone) self.elevator = Elevator.Elevator(self.fsm.getStateNamed('elevator'), self.elevatorDoneEvent, distElevator) if skipDFABoard: self.elevator.skipDFABoard = 1 distElevator.elevatorFSM = self.elevator self.elevator.load() self.elevator.enter() def exitElevator(self): self.ignore(self.elevatorDoneEvent) self.elevator.unload() self.elevator.exit() del self.elevator def detectedElevatorCollision(self, distElevator): self.fsm.request('elevator', [distElevator]) def handleElevatorDone(self, doneStatus): self.notify.debug('handling elevator done event') where = doneStatus['where'] if where == 'reject': if hasattr(base.localAvatar, 'elevatorNotifier') and base.localAvatar.elevatorNotifier.isNotifierOpen(): pass else: self.fsm.request('walk') elif where == 'exit': self.fsm.request('walk') elif where == 'factoryInterior': self.doneStatus = doneStatus messenger.send(self.doneEvent) elif where == 'stageInterior': self.doneStatus = doneStatus messenger.send(self.doneEvent) else: self.notify.error('Unknown mode: ' + where + ' in handleElevatorDone')
class FactoryExterior(BattlePlace.BattlePlace): notify = DirectNotifyGlobal.directNotify.newCategory('FactoryExterior') dnaFile = 'phase_9/dna/cog_hq_sellbot_11200.xml' def __init__(self, loader, parentFSM, doneEvent): BattlePlace.BattlePlace.__init__(self, loader, doneEvent) self.parentFSM = parentFSM self.elevatorDoneEvent = 'elevatorDone' self.visInterest = None self.visGroups = None def load(self): self.fsm = ClassicFSM.ClassicFSM('FactoryExterior', [State.State('start', self.enterStart, self.exitStart, ['walk', 'tunnelIn', 'teleportIn', 'doorIn']), State.State('walk', self.enterWalk, self.exitWalk, ['stickerBook', 'teleportOut', 'tunnelOut', 'DFA', 'doorOut', 'elevator', 'stopped', 'WaitForBattle', 'battle']), State.State('stopped', self.enterStopped, self.exitStopped, ['walk', 'teleportOut', 'elevator']), State.State('stickerBook', self.enterStickerBook, self.exitStickerBook, ['walk', 'DFA', 'WaitForBattle', 'battle', 'elevator']), State.State('WaitForBattle', self.enterWaitForBattle, self.exitWaitForBattle, ['battle', 'walk']), State.State('battle', self.enterBattle, self.exitBattle, ['walk', 'teleportOut', 'died']), State.State('DFA', self.enterDFA, self.exitDFA, ['DFAReject', 'teleportOut', 'tunnelOut']), State.State('DFAReject', self.enterDFAReject, self.exitDFAReject, ['walk']), State.State('teleportIn', self.enterTeleportIn, self.exitTeleportIn, ['walk']), State.State('teleportOut', self.enterTeleportOut, self.exitTeleportOut, ['teleportIn', 'final', 'WaitForBattle']), State.State('doorIn', self.enterDoorIn, self.exitDoorIn, ['walk']), State.State('doorOut', self.enterDoorOut, self.exitDoorOut, ['walk']), State.State('died', self.enterDied, self.exitDied, ['quietZone']), State.State('tunnelIn', self.enterTunnelIn, self.exitTunnelIn, ['walk']), State.State('tunnelOut', self.enterTunnelOut, self.exitTunnelOut, ['final']), State.State('elevator', self.enterElevator, self.exitElevator, ['walk', 'stopped']), State.State('final', self.enterFinal, self.exitFinal, ['start'])], 'start', 'final') self.parentFSM.getStateNamed('factoryExterior').addChild(self.fsm) BattlePlace.BattlePlace.load(self) def unload(self): self.parentFSM.getStateNamed('factoryExterior').removeChild(self.fsm) del self.fsm BattlePlace.BattlePlace.unload(self) def enter(self, requestStatus): self.zoneId = requestStatus['zoneId'] self.updateVis(self.zoneId) BattlePlace.BattlePlace.enter(self) self.fsm.enterInitialState() base.playMusic(self.loader.music, looping=1, volume=0.8) self.loader.geom.reparentTo(render) self.nodeList = [self.loader.geom] self.loader.hood.startSky() self._telemLimiter = TLGatherAllAvs('FactoryExterior', RotationLimitToH) self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) NametagGlobals.setMasterArrowsOn(1) self.tunnelOriginList = base.cr.hoodMgr.addLinkTunnelHooks(self, self.nodeList, self.zoneId) how = requestStatus['how'] self.fsm.request(how, [requestStatus]) def exit(self): self._telemLimiter.destroy() del self._telemLimiter self.loader.hood.stopSky() self.fsm.requestFinalState() self.loader.music.stop() for node in self.tunnelOriginList: node.removeNode() del self.tunnelOriginList del self.nodeList self.ignoreAll() if self.visInterest: base.cr.removeInterest(self.visInterest) BattlePlace.BattlePlace.exit(self) def enterTunnelOut(self, requestStatus): fromZoneId = self.zoneId - self.zoneId % 100 tunnelName = base.cr.hoodMgr.makeLinkTunnelName(self.loader.hood.id, fromZoneId) requestStatus['tunnelName'] = tunnelName BattlePlace.BattlePlace.enterTunnelOut(self, requestStatus) def enterTeleportIn(self, requestStatus): base.localAvatar.setPosHpr(-34, -350, 0, -28, 0, 0) BattlePlace.BattlePlace.enterTeleportIn(self, requestStatus) def enterTeleportOut(self, requestStatus): BattlePlace.BattlePlace.enterTeleportOut(self, requestStatus, self.__teleportOutDone) def __teleportOutDone(self, requestStatus): hoodId = requestStatus['hoodId'] zoneId = requestStatus['zoneId'] avId = requestStatus['avId'] shardId = requestStatus['shardId'] if hoodId == self.loader.hood.hoodId and zoneId == self.zoneId and shardId == None: self.fsm.request('teleportIn', [requestStatus]) elif hoodId == ToontownGlobals.MyEstate: self.getEstateZoneAndGoHome(requestStatus) else: self.doneStatus = requestStatus messenger.send(self.doneEvent) return def exitTeleportOut(self): BattlePlace.BattlePlace.exitTeleportOut(self) def enterElevator(self, distElevator, skipDFABoard = 0): self.accept(self.elevatorDoneEvent, self.handleElevatorDone) self.elevator = Elevator.Elevator(self.fsm.getStateNamed('elevator'), self.elevatorDoneEvent, distElevator) if skipDFABoard: self.elevator.skipDFABoard = 1 distElevator.elevatorFSM = self.elevator self.elevator.load() self.elevator.enter() def exitElevator(self): self.ignore(self.elevatorDoneEvent) self.elevator.unload() self.elevator.exit() del self.elevator def detectedElevatorCollision(self, distElevator): self.fsm.request('elevator', [distElevator]) def handleElevatorDone(self, doneStatus): self.notify.debug('handling elevator done event') where = doneStatus['where'] if where == 'reject': if hasattr(base.localAvatar, 'elevatorNotifier') and base.localAvatar.elevatorNotifier.isNotifierOpen(): pass else: self.fsm.request('walk') elif where == 'exit': self.fsm.request('walk') elif where == 'factoryInterior': self.doneStatus = doneStatus messenger.send(self.doneEvent) elif where == 'stageInterior': self.doneStatus = doneStatus messenger.send(self.doneEvent) else: self.notify.error('Unknown mode: ' + where + ' in handleElevatorDone') def updateVis(self, zone): if not self.visGroups: dna = loader.loadDNA(self.dnaFile) self.visGroups = DNAUtil.getVisGroups(dna) visZones = [] for vg in self.visGroups: if vg.getZone() == zone: visZones = vg.getVisibleZones() visZones.append(ToontownGlobals.SellbotFactoryExt) # :dolphin: break if not self.visInterest: self.visInterest = base.cr.addInterest(base.localAvatar.defaultShard, visZones, 'cogHQVis') else: base.cr.alterInterest(self.visInterest, base.localAvatar.defaultShard, visZones) def doEnterZone(self, newZoneId): self.updateVis(newZoneId) if newZoneId != self.zoneId: if newZoneId != None: base.cr.sendSetZoneMsg(newZoneId) self.notify.debug('Entering Zone %d' % newZoneId) self.zoneId = newZoneId return
def enter(self, requestStatus): self.fsm.enterInitialState() messenger.send('enterPlayground') self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) base.playMusic(self.loader.music, looping=1, volume=0.8) self.loader.geom.reparentTo(render) for i in self.loader.nodeList: self.loader.enterAnimatedProps(i) self._telemLimiter = TLGatherAllAvs('Playground', RotationLimitToH) def __lightDecorationOn__(): geom = base.cr.playGame.hood.loader.geom self.loader.hood.eventLights = geom.findAllMatches('**/*light*') self.loader.hood.eventLights += geom.findAllMatches('**/*lamp*') self.loader.hood.eventLights += geom.findAllMatches( '**/prop_snow_tree*') self.loader.hood.eventLights += geom.findAllMatches( '**/prop_tree*') self.loader.hood.eventLights += geom.findAllMatches( '**/*christmas*') for light in self.loader.hood.eventLights: light.setColorScaleOff(0) newsManager = base.cr.newsManager if newsManager: holidayIds = base.cr.newsManager.getDecorationHolidayId() if (ToontownGlobals.HALLOWEEN_COSTUMES in holidayIds or ToontownGlobals.SPOOKY_COSTUMES in holidayIds) and self.loader.hood.spookySkyFile: lightsOff = Sequence( LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.1, Vec4(0.55, 0.55, 0.65, 1)), Func(self.loader.hood.startSpookySky), Func(__lightDecorationOn__)) lightsOff.start() else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval( base.cr.playGame.hood.loader.geom, 0.1, Vec4(1, 1, 1, 1)) lightsOn.start() if (ToontownGlobals.WINTER_DECORATIONS in holidayIds or ToontownGlobals.WACKY_WINTER_DECORATIONS in holidayIds) and self.loader.hood.snowySkyFile: lightsOff = Sequence( LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.1, Vec4(0.7, 0.7, 0.8, 1)), Func(self.loader.hood.startSnowySky), Func(__lightDecorationOn__)) lightsOff.start() self.snowEvent = BattleParticles.loadParticleFile( 'snowdisk.ptf') self.snowEvent.setPos(0, 30, 10) self.snowEvent2 = BattleParticles.loadParticleFile( 'snowdisk.ptf') self.snowEvent2.setPos(0, 10, 10) self.snowEvent3 = BattleParticles.loadParticleFile( 'snowdisk.ptf') self.snowEvent3.setPos(0, 20, 5) self.snowEventRender = base.cr.playGame.hood.loader.geom.attachNewNode( 'snowRender') self.snowEventRender.setDepthWrite(2) self.snowEventRender.setBin('fixed', 1) self.snowEventFade = None self.snowEvent.start(camera, self.snowEventRender) self.snowEvent2.start(camera, self.snowEventRender) self.snowEvent3.start(camera, self.snowEventRender) else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval( base.cr.playGame.hood.loader.geom, 0.1, Vec4(1, 1, 1, 1)) lightsOn.start() else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval( base.cr.playGame.hood.loader.geom, 0.1, Vec4(1, 1, 1, 1)) lightsOn.start() NametagGlobals.setMasterArrowsOn(1) self.zoneId = requestStatus['zoneId'] self.tunnelOriginList = base.cr.hoodMgr.addLinkTunnelHooks( self, self.loader.nodeList, self.zoneId) how = requestStatus['how'] if how == 'teleportIn': how = 'deathAck' self.fsm.request(how, [requestStatus]) return
class ToonInterior(Place.Place): notify = DirectNotifyGlobal.directNotify.newCategory('ToonInterior') def __init__(self, loader, parentFSMState, doneEvent): Place.Place.__init__(self, loader, doneEvent) self.dnaFile = 'phase_7/models/modules/toon_interior' self.isInterior = 1 self.tfaDoneEvent = 'tfaDoneEvent' self.hfaDoneEvent = 'hfaDoneEvent' self.npcfaDoneEvent = 'npcfaDoneEvent' self.fsm = ClassicFSM.ClassicFSM('ToonInterior', [ State.State('start', self.enterStart, self.exitStart, ['doorIn', 'teleportIn', 'tutorial']), State.State('walk', self.enterWalk, self.exitWalk, [ 'sit', 'stickerBook', 'doorOut', 'DFA', 'trialerFA', 'teleportOut', 'quest', 'purchase', 'phone', 'stopped', 'pet', 'died' ]), State.State('sit', self.enterSit, self.exitSit, ['walk']), State.State( 'stickerBook', self.enterStickerBook, self.exitStickerBook, [ 'walk', 'DFA', 'trialerFA', 'sit', 'doorOut', 'teleportOut', 'quest', 'purchase', 'phone', 'stopped', 'pet', 'died' ]), State.State('trialerFA', self.enterTrialerFA, self.exitTrialerFA, ['trialerFAReject', 'DFA']), State.State('trialerFAReject', self.enterTrialerFAReject, self.exitTrialerFAReject, ['walk']), State.State( 'DFA', self.enterDFA, self.exitDFA, ['DFAReject', 'HFA', 'NPCFA', 'teleportOut', 'doorOut']), State.State('DFAReject', self.enterDFAReject, self.exitDFAReject, ['walk']), State.State('NPCFA', self.enterNPCFA, self.exitNPCFA, ['NPCFAReject', 'HFA', 'teleportOut']), State.State('NPCFAReject', self.enterNPCFAReject, self.exitNPCFAReject, ['walk']), State.State('HFA', self.enterHFA, self.exitHFA, ['HFAReject', 'teleportOut', 'tunnelOut']), State.State('HFAReject', self.enterHFAReject, self.exitHFAReject, ['walk']), State.State('doorIn', self.enterDoorIn, self.exitDoorIn, ['walk']), State.State('doorOut', self.enterDoorOut, self.exitDoorOut, ['walk']), State.State('teleportIn', self.enterTeleportIn, self.exitTeleportIn, ['walk']), State.State('teleportOut', self.enterTeleportOut, self.exitTeleportOut, ['teleportIn']), State.State('quest', self.enterQuest, self.exitQuest, ['walk', 'doorOut']), State.State('tutorial', self.enterTutorial, self.exitTutorial, ['walk', 'quest']), State.State('purchase', self.enterPurchase, self.exitPurchase, ['walk', 'doorOut']), State.State('pet', self.enterPet, self.exitPet, ['walk']), State.State('phone', self.enterPhone, self.exitPhone, ['walk', 'doorOut']), State.State('stopped', self.enterStopped, self.exitStopped, ['walk', 'doorOut']), State.State('died', self.enterDied, self.exitDied, ['walk', 'stickerBook', 'final']), State.State('final', self.enterFinal, self.exitFinal, ['start']) ], 'start', 'final') self.parentFSMState = parentFSMState def load(self): Place.Place.load(self) self.parentFSMState.addChild(self.fsm) def unload(self): Place.Place.unload(self) self.parentFSMState.removeChild(self.fsm) del self.parentFSMState del self.fsm ModelPool.garbageCollect() TexturePool.garbageCollect() def enter(self, requestStatus): self.zoneId = requestStatus['zoneId'] self.fsm.enterInitialState() messenger.send('enterToonInterior') self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) volume = requestStatus.get('musicVolume', 0.7) if self.zoneId in (ToontownGlobals.Kongdominium, ToontownGlobals.PrivateServerCafe): if self.zoneId == ToontownGlobals.Kongdominium: type = 0 elif self.zoneId == ToontownGlobals.PrivateServerCafe: type = 1 else: type = -1 taskMgr.add(self.customMusicTask, 'custom-music-task', extraArgs=[volume, type], appendTask=True) else: base.playMusic(self.loader.activityMusic, looping=1, volume=volume) self._telemLimiter = TLGatherAllAvs('ToonInterior', RotationLimitToH) NametagGlobals.setMasterArrowsOn(1) self.fsm.request(requestStatus['how'], [requestStatus]) zoneId = self.zoneId if not base.localAvatar.tutorialAck: zoneId = 20002 base.cr.discordManager.setInfo( base.cr.discordManager.getState(), None, ToontownGlobals.Zone2String.get(ZoneUtil.getHoodId(zoneId)), None, None, None, zoneId) return def exit(self): self.ignoreAll() messenger.send('exitToonInterior') self._telemLimiter.destroy() del self._telemLimiter NametagGlobals.setMasterArrowsOn(0) if self.zoneId in (ToontownGlobals.Kongdominium, ToontownGlobals. PrivateServerCafe) and self.activityMusicOverride: taskMgr.remove('custom-music-task') self.activityMusicOverride.stop() else: self.loader.activityMusic.stop() def setState(self, state): self.fsm.request(state) def enterTutorial(self, requestStatus): self.fsm.request('walk') base.localAvatar.b_setParent(ToontownGlobals.SPRender) globalClock.tick() base.transitions.irisIn() messenger.send('enterTutorialInterior') def exitTutorial(self): pass def doRequestLeave(self, requestStatus): self.fsm.request('trialerFA', [requestStatus]) def enterDFACallback(self, requestStatus, doneStatus): self.dfa.exit() del self.dfa ds = doneStatus['mode'] if ds == 'complete': self.fsm.request('NPCFA', [requestStatus]) elif ds == 'incomplete': self.fsm.request('DFAReject') else: self.notify.error( 'Unknown done status for DownloadForceAcknowledge: ' + ` doneStatus `) def enterNPCFA(self, requestStatus): self.acceptOnce(self.npcfaDoneEvent, self.enterNPCFACallback, [requestStatus]) self.npcfa = NPCForceAcknowledge.NPCForceAcknowledge( self.npcfaDoneEvent) self.npcfa.enter() def exitNPCFA(self): self.ignore(self.npcfaDoneEvent) def enterNPCFACallback(self, requestStatus, doneStatus): self.npcfa.exit() del self.npcfa if doneStatus['mode'] == 'complete': outHow = { 'teleportIn': 'teleportOut', 'tunnelIn': 'tunnelOut', 'doorIn': 'doorOut' } self.fsm.request(outHow[requestStatus['how']], [requestStatus]) elif doneStatus['mode'] == 'incomplete': self.fsm.request('NPCFAReject') else: self.notify.error('Unknown done status for NPCForceAcknowledge: ' + ` doneStatus `) def enterNPCFAReject(self): self.fsm.request('walk') def exitNPCFAReject(self): pass def enterHFA(self, requestStatus): self.acceptOnce(self.hfaDoneEvent, self.enterHFACallback, [requestStatus]) self.hfa = HealthForceAcknowledge.HealthForceAcknowledge( self.hfaDoneEvent) self.hfa.enter(1) def exitHFA(self): self.ignore(self.hfaDoneEvent) def enterHFACallback(self, requestStatus, doneStatus): self.hfa.exit() del self.hfa if doneStatus['mode'] == 'complete': outHow = { 'teleportIn': 'teleportOut', 'tunnelIn': 'tunnelOut', 'doorIn': 'doorOut' } self.fsm.request(outHow[requestStatus['how']], [requestStatus]) elif doneStatus['mode'] == 'incomplete': self.fsm.request('HFAReject') else: self.notify.error( 'Unknown done status for HealthForceAcknowledge: ' + ` doneStatus `) def enterHFAReject(self): self.fsm.request('walk') def exitHFAReject(self): pass def enterTeleportIn(self, requestStatus): if ZoneUtil.isPetshop(self.zoneId): base.localAvatar.setPosHpr(0, 0, ToontownGlobals.FloorOffset, 45.0, 0.0, 0.0) else: base.localAvatar.setPosHpr(2.5, 11.5, ToontownGlobals.FloorOffset, 45.0, 0.0, 0.0) Place.Place.enterTeleportIn(self, requestStatus) def enterTeleportOut(self, requestStatus): Place.Place.enterTeleportOut(self, requestStatus, self.__teleportOutDone) def __teleportOutDone(self, requestStatus): hoodId = requestStatus['hoodId'] zoneId = requestStatus['zoneId'] shardId = requestStatus['shardId'] if hoodId == self.loader.hood.id and zoneId == self.zoneId and shardId == None: self.fsm.request('teleportIn', [requestStatus]) elif hoodId == ToontownGlobals.MyEstate: self.getEstateZoneAndGoHome(requestStatus) else: self.doneStatus = requestStatus messenger.send(self.doneEvent) return def goHomeFailed(self, task): self.notifyUserGoHomeFailed() self.ignore('setLocalEstateZone') self.doneStatus['avId'] = -1 self.doneStatus['zoneId'] = self.getZoneId() self.fsm.request('teleportIn', [self.doneStatus]) return Task.done def exitTeleportOut(self): Place.Place.exitTeleportOut(self) def getCustomSongs(self, type): if not type: return ToontownGlobals.KongdominiumSongs else: return ToontownGlobals.PrivateServerCafeSongs def customMusicTask(self, volume, type, task): if type == -1: return customSongs = self.getCustomSongs(type) songName = random.choice(customSongs.keys()) songChoice = customSongs[songName] self.activityMusicOverride = base.loader.loadMusic(songChoice) base.playMusic(self.activityMusicOverride, looping=0, volume=volume) signOrigin = render.find('**/sign_origin;+s') if not signOrigin.isEmpty(): songNameNP = render.find('**/songName') if not songNameNP.isEmpty(): songNameNP.removeNode() songNameNP = signOrigin.attachNewNode(TextNode('songName')) if not type: font = ToontownGlobals.getSignFont() else: font = ToontownGlobals.getFancyFont() songNameNP.node().setTextColor(0.501961, 0, 0.25098, 1) songNameNP.node().setFont(font) songNameNP.node().setText(songName) songNameNP.setDepthWrite(1, 1) songNameNP.flattenLight() ll = Point3() ur = Point3() songNameNP.calcTightBounds(ll, ur) width = ur[0] - ll[0] height = ur[2] - ll[2] if width != 0 and height != 0: xScale = 8 / width zScale = 5.0 / height scale = min(xScale, zScale) if len(songName) < 15: scale = scale - 0.85 xCenter = (ur[0] + ll[0]) / 2.0 songNameNP.setZ(songNameNP.getZ() - 2.25) songNameNP.setX(0 / 2.0 - xCenter * scale) songNameNP.setScale(scale) task.delayTime = self.activityMusicOverride.length() + 2.0 return task.again
def enter(self, requestStatus): self.fsm.enterInitialState() self._telemLimiter = TLGatherAllAvs('SuitInterior', RotationLimitToH) self.zoneId = requestStatus['zoneId'] self.accept('DSIDoneEvent', self.handleDSIDoneEvent)
class SuitInterior(Place.Place): __module__ = __name__ notify = DirectNotifyGlobal.directNotify.newCategory('SuitInterior') def __init__(self, loader, parentFSM, doneEvent): Place.Place.__init__(self, loader, doneEvent) self.fsm = ClassicFSM.ClassicFSM('SuitInterior', [State.State('entrance', self.enterEntrance, self.exitEntrance, ['battle', 'walk']), State.State('Elevator', self.enterElevator, self.exitElevator, ['battle', 'walk']), State.State('battle', self.enterBattle, self.exitBattle, ['walk', 'died']), State.State('walk', self.enterWalk, self.exitWalk, ['stickerBook', 'stopped', 'sit', 'died', 'teleportOut', 'Elevator', 'DFA', 'trialerFA']), State.State('sit', self.enterSit, self.exitSit, ['walk']), State.State('stickerBook', self.enterStickerBook, self.exitStickerBook, ['walk', 'stopped', 'sit', 'died', 'DFA', 'trialerFA', 'teleportOut', 'Elevator']), State.State('trialerFA', self.enterTrialerFA, self.exitTrialerFA, ['trialerFAReject', 'DFA']), State.State('trialerFAReject', self.enterTrialerFAReject, self.exitTrialerFAReject, ['walk']), State.State('DFA', self.enterDFA, self.exitDFA, ['DFAReject', 'teleportOut']), State.State('DFAReject', self.enterDFAReject, self.exitDFAReject, ['walk']), State.State('teleportIn', self.enterTeleportIn, self.exitTeleportIn, ['walk']), State.State('teleportOut', self.enterTeleportOut, self.exitTeleportOut, ['teleportIn']), State.State('stopped', self.enterStopped, self.exitStopped, ['walk', 'elevatorOut']), State.State('died', self.enterDied, self.exitDied, []), State.State('elevatorOut', self.enterElevatorOut, self.exitElevatorOut, [])], 'entrance', 'elevatorOut') self.parentFSM = parentFSM self.elevatorDoneEvent = 'elevatorDoneSI' self.currentFloor = 0 def enter(self, requestStatus): self.fsm.enterInitialState() self._telemLimiter = TLGatherAllAvs('SuitInterior', RotationLimitToH) self.zoneId = requestStatus['zoneId'] self.accept('DSIDoneEvent', self.handleDSIDoneEvent) def exit(self): self.ignoreAll() self._telemLimiter.destroy() del self._telemLimiter def load(self): Place.Place.load(self) self.parentFSM.getStateNamed('suitInterior').addChild(self.fsm) self.townBattle = TownBattle.TownBattle('town-battle-done') self.townBattle.load() for i in range(1, 3): Suit.loadSuits(i) def unload(self): Place.Place.unload(self) self.parentFSM.getStateNamed('suitInterior').removeChild(self.fsm) del self.parentFSM del self.fsm self.ignoreAll() ModelPool.garbageCollect() TexturePool.garbageCollect() self.townBattle.unload() self.townBattle.cleanup() del self.townBattle for i in range(1, 3): Suit.unloadSuits(i) def setState(self, state, battleEvent = None): if battleEvent: self.fsm.request(state, [battleEvent]) else: self.fsm.request(state) def getZoneId(self): return self.zoneId def enterZone(self, zoneId): pass def isPeriodTimerEffective(self): return 0 def handleDSIDoneEvent(self, requestStatus): self.doneStatus = requestStatus messenger.send(self.doneEvent) def doRequestLeave(self, requestStatus): self.fsm.request('trialerFA', [requestStatus]) def enterEntrance(self): pass def exitEntrance(self): pass def enterElevator(self, distElevator): self.accept(self.elevatorDoneEvent, self.handleElevatorDone) self.elevator = Elevator.Elevator(self.fsm.getStateNamed('Elevator'), self.elevatorDoneEvent, distElevator) self.elevator.load() self.elevator.enter() base.localAvatar.cantLeaveGame = 1 def exitElevator(self): base.localAvatar.cantLeaveGame = 0 self.ignore(self.elevatorDoneEvent) self.elevator.unload() self.elevator.exit() del self.elevator return None def detectedElevatorCollision(self, distElevator): self.fsm.request('Elevator', [distElevator]) return None def handleElevatorDone(self, doneStatus): self.notify.debug('handling elevator done event') where = doneStatus['where'] if where == 'reject': if hasattr(base.localAvatar, 'elevatorNotifier') and base.localAvatar.elevatorNotifier.isNotifierOpen(): pass else: self.fsm.request('walk') elif where == 'exit': self.fsm.request('walk') elif where == 'suitInterior': pass else: self.notify.error('Unknown mode: ' + +' in handleElevatorDone') def enterBattle(self, event): mult = ToontownBattleGlobals.getCreditMultiplier(self.currentFloor) self.townBattle.enter(event, self.fsm.getStateNamed('battle'), bldg=1, creditMultiplier=mult) base.localAvatar.b_setAnimState('off', 1) base.localAvatar.cantLeaveGame = 1 def exitBattle(self): self.townBattle.exit() base.localAvatar.cantLeaveGame = 0 def enterWalk(self, teleportIn = 0): Place.Place.enterWalk(self, teleportIn) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterStickerBook(self, page = None): Place.Place.enterStickerBook(self, page) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterSit(self): Place.Place.enterSit(self) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterStopped(self): Place.Place.enterStopped(self) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterTeleportIn(self, requestStatus): base.localAvatar.setPosHpr(2.5, 11.5, ToontownGlobals.FloorOffset, 45.0, 0.0, 0.0) Place.Place.enterTeleportIn(self, requestStatus) def enterTeleportOut(self, requestStatus): Place.Place.enterTeleportOut(self, requestStatus, self.__teleportOutDone) def __teleportOutDone(self, requestStatus): hoodId = requestStatus['hoodId'] if hoodId == ToontownGlobals.MyEstate: self.getEstateZoneAndGoHome(requestStatus) else: messenger.send('localToonLeft') self.doneStatus = requestStatus messenger.send(self.doneEvent) def exitTeleportOut(self): Place.Place.exitTeleportOut(self) def goHomeFailed(self, task): self.notifyUserGoHomeFailed() self.ignore('setLocalEstateZone') self.doneStatus['avId'] = -1 self.doneStatus['zoneId'] = self.getZoneId() self.fsm.request('teleportIn', [self.doneStatus]) return Task.done def enterElevatorOut(self): return None def __elevatorOutDone(self, requestStatus): self.doneStatus = requestStatus messenger.send(self.doneEvent) def exitElevatorOut(self): return None
class FactoryExterior(BattlePlace.BattlePlace): notify = DirectNotifyGlobal.directNotify.newCategory('FactoryExterior') def __init__(self, loader, parentFSM, doneEvent): BattlePlace.BattlePlace.__init__(self, loader, doneEvent) self.parentFSM = parentFSM self.elevatorDoneEvent = 'elevatorDone' def load(self): self.fsm = ClassicFSM.ClassicFSM('FactoryExterior', [ State.State('start', self.enterStart, self.exitStart, ['walk', 'tunnelIn', 'teleportIn', 'doorIn']), State.State('walk', self.enterWalk, self.exitWalk, [ 'stickerBook', 'teleportOut', 'tunnelOut', 'DFA', 'doorOut', 'elevator', 'stopped', 'WaitForBattle', 'battle' ]), State.State('stopped', self.enterStopped, self.exitStopped, ['walk', 'teleportOut', 'elevator']), State.State( 'stickerBook', self.enterStickerBook, self.exitStickerBook, ['walk', 'DFA', 'WaitForBattle', 'battle', 'elevator']), State.State('WaitForBattle', self.enterWaitForBattle, self.exitWaitForBattle, ['battle', 'walk']), State.State('battle', self.enterBattle, self.exitBattle, ['walk', 'teleportOut', 'died']), State.State('DFA', self.enterDFA, self.exitDFA, ['DFAReject', 'teleportOut', 'tunnelOut']), State.State('DFAReject', self.enterDFAReject, self.exitDFAReject, ['walk']), State.State('teleportIn', self.enterTeleportIn, self.exitTeleportIn, ['walk']), State.State('teleportOut', self.enterTeleportOut, self.exitTeleportOut, ['teleportIn', 'final', 'WaitForBattle']), State.State('doorIn', self.enterDoorIn, self.exitDoorIn, ['walk']), State.State('doorOut', self.enterDoorOut, self.exitDoorOut, ['walk']), State.State('died', self.enterDied, self.exitDied, ['quietZone']), State.State('tunnelIn', self.enterTunnelIn, self.exitTunnelIn, ['walk']), State.State('tunnelOut', self.enterTunnelOut, self.exitTunnelOut, ['final']), State.State('elevator', self.enterElevator, self.exitElevator, ['walk', 'stopped']), State.State('final', self.enterFinal, self.exitFinal, ['start']) ], 'start', 'final') self.parentFSM.getStateNamed('factoryExterior').addChild(self.fsm) BattlePlace.BattlePlace.load(self) def unload(self): self.parentFSM.getStateNamed('factoryExterior').removeChild(self.fsm) del self.fsm BattlePlace.BattlePlace.unload(self) def enter(self, requestStatus): self.zoneId = requestStatus['zoneId'] # Load the CogHQ DNA file: dnaStore = DNAStorage() dnaFileName = self.genDNAFileName(self.zoneId) if not dnaFileName.endswith('13200.pdna'): loadDNAFileAI(dnaStore, dnaFileName) # Collect all of the vis group zone IDs: self.zoneVisDict = {} for i in xrange(dnaStore.getNumDNAVisGroupsAI()): groupFullName = dnaStore.getDNAVisGroupName(i) visGroup = dnaStore.getDNAVisGroupAI(i) visZoneId = int( base.cr.hoodMgr.extractGroupName(groupFullName)) visZoneId = ZoneUtil.getTrueZoneId(visZoneId, self.zoneId) visibles = [] for i in xrange(visGroup.getNumVisibles()): visibles.append(int(visGroup.visibles[i])) visibles.append(ZoneUtil.getBranchZone(visZoneId)) self.zoneVisDict[visZoneId] = visibles # Next, we want interest in all vis groups due to this being a Cog HQ: base.cr.sendSetZoneMsg(self.zoneId, self.zoneVisDict.values()[0]) BattlePlace.BattlePlace.enter(self) self.fsm.enterInitialState() base.playMusic(self.loader.music, looping=1, volume=0.8) self.loader.geom.reparentTo(render) self.nodeList = [self.loader.geom] self.loader.hood.startSky() self._telemLimiter = TLGatherAllAvs('FactoryExterior', RotationLimitToH) self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) NametagGlobals.setWant2dNametags(True) self.tunnelOriginList = base.cr.hoodMgr.addLinkTunnelHooks( self, self.nodeList, self.zoneId) how = requestStatus['how'] self.fsm.request(how, [requestStatus]) def exit(self): self._telemLimiter.destroy() del self._telemLimiter self.loader.hood.stopSky() self.fsm.requestFinalState() self.loader.music.stop() for node in self.tunnelOriginList: node.removeNode() del self.tunnelOriginList del self.nodeList self.ignoreAll() BattlePlace.BattlePlace.exit(self) def enterTunnelOut(self, requestStatus): fromZoneId = self.zoneId - self.zoneId % 100 tunnelName = base.cr.hoodMgr.makeLinkTunnelName( self.loader.hood.id, fromZoneId) requestStatus['tunnelName'] = tunnelName BattlePlace.BattlePlace.enterTunnelOut(self, requestStatus) def enterTeleportIn(self, requestStatus): base.localAvatar.setPosHpr(-34, -350, 0, -28, 0, 0) BattlePlace.BattlePlace.enterTeleportIn(self, requestStatus) def enterTeleportOut(self, requestStatus): BattlePlace.BattlePlace.enterTeleportOut(self, requestStatus, self.__teleportOutDone) def __teleportOutDone(self, requestStatus): hoodId = requestStatus['hoodId'] zoneId = requestStatus['zoneId'] avId = requestStatus['avId'] shardId = requestStatus['shardId'] if hoodId == self.loader.hood.hoodId and zoneId == self.zoneId and shardId == None: self.fsm.request('teleportIn', [requestStatus]) elif hoodId == ToontownGlobals.MyEstate: self.getEstateZoneAndGoHome(requestStatus) else: self.doneStatus = requestStatus messenger.send(self.doneEvent) return def exitTeleportOut(self): BattlePlace.BattlePlace.exitTeleportOut(self) def enterElevator(self, distElevator, skipDFABoard=0): self.accept(self.elevatorDoneEvent, self.handleElevatorDone) self.elevator = Elevator.Elevator(self.fsm.getStateNamed('elevator'), self.elevatorDoneEvent, distElevator) if skipDFABoard: self.elevator.skipDFABoard = 1 distElevator.elevatorFSM = self.elevator self.elevator.load() self.elevator.enter() def exitElevator(self): self.ignore(self.elevatorDoneEvent) self.elevator.unload() self.elevator.exit() del self.elevator def detectedElevatorCollision(self, distElevator): self.fsm.request('elevator', [distElevator]) def handleElevatorDone(self, doneStatus): self.notify.debug('handling elevator done event') where = doneStatus['where'] if where == 'reject': if hasattr( base.localAvatar, 'elevatorNotifier' ) and base.localAvatar.elevatorNotifier.isNotifierOpen(): pass else: self.fsm.request('walk') elif where == 'exit': self.fsm.request('walk') elif where == 'factoryInterior': self.doneStatus = doneStatus messenger.send(self.doneEvent) elif where == 'stageInterior': self.doneStatus = doneStatus messenger.send(self.doneEvent) else: self.notify.error('Unknown mode: ' + where + ' in handleElevatorDone')
class CountryClubInterior(BattlePlace.BattlePlace): __module__ = __name__ notify = DirectNotifyGlobal.directNotify.newCategory('CountryClubInterior') def __init__(self, loader, parentFSM, doneEvent): BattlePlace.BattlePlace.__init__(self, loader, doneEvent) self.parentFSM = parentFSM self.zoneId = loader.countryClubId self.elevatorDoneEvent = 'elevatorDone' self.fsm = ClassicFSM.ClassicFSM('CountryClubInterior', [State.State('start', self.enterStart, self.exitStart, ['walk', 'teleportIn', 'fallDown']), State.State('walk', self.enterWalk, self.exitWalk, ['push', 'sit', 'stickerBook', 'WaitForBattle', 'battle', 'died', 'teleportOut', 'squished', 'DFA', 'fallDown', 'stopped', 'elevator']), State.State('stopped', self.enterStopped, self.exitStopped, ['walk', 'teleportOut', 'stickerBook']), State.State('sit', self.enterSit, self.exitSit, ['walk', 'died', 'teleportOut']), State.State('push', self.enterPush, self.exitPush, ['walk', 'died', 'teleportOut']), State.State('stickerBook', self.enterStickerBook, self.exitStickerBook, ['walk', 'battle', 'DFA', 'WaitForBattle', 'died', 'teleportOut']), State.State('WaitForBattle', self.enterWaitForBattle, self.exitWaitForBattle, ['battle', 'walk', 'died', 'teleportOut']), State.State('battle', self.enterBattle, self.exitBattle, ['walk', 'teleportOut', 'died']), State.State('fallDown', self.enterFallDown, self.exitFallDown, ['walk', 'died', 'teleportOut']), State.State('squished', self.enterSquished, self.exitSquished, ['walk', 'died', 'teleportOut']), State.State('teleportIn', self.enterTeleportIn, self.exitTeleportIn, ['walk', 'teleportOut', 'quietZone', 'died']), State.State('teleportOut', self.enterTeleportOut, self.exitTeleportOut, ['teleportIn', 'FLA', 'quietZone', 'WaitForBattle']), State.State('DFA', self.enterDFA, self.exitDFA, ['DFAReject', 'teleportOut']), State.State('DFAReject', self.enterDFAReject, self.exitDFAReject, ['walkteleportOut']), State.State('died', self.enterDied, self.exitDied, ['teleportOut']), State.State('FLA', self.enterFLA, self.exitFLA, ['quietZone']), State.State('quietZone', self.enterQuietZone, self.exitQuietZone, ['teleportIn']), State.State('elevator', self.enterElevator, self.exitElevator, ['walk']), State.State('final', self.enterFinal, self.exitFinal, ['start'])], 'start', 'final') def load(self): self.parentFSM.getStateNamed('countryClubInterior').addChild(self.fsm) BattlePlace.BattlePlace.load(self) musicName = random.choice(['phase_12/audio/bgm/Bossbot_Factory_v1.mid', 'phase_12/audio/bgm/Bossbot_Factory_v2.mid', 'phase_12/audio/bgm/Bossbot_Factory_v3.mid']) self.music = base.loadMusic(musicName) def unload(self): self.parentFSM.getStateNamed('countryClubInterior').removeChild(self.fsm) del self.music del self.fsm del self.parentFSM BattlePlace.BattlePlace.unload(self) def enter(self, requestStatus): self.fsm.enterInitialState() base.transitions.fadeOut(t=0) base.localAvatar.inventory.setRespectInvasions(0) base.cr.forbidCheesyEffects(1) self._telemLimiter = TLGatherAllAvs('CountryClubInterior', RotationLimitToH) def commence(self = self): NametagGlobals.setMasterArrowsOn(1) self.fsm.request(requestStatus['how'], [requestStatus]) base.playMusic(self.music, looping=1, volume=0.8) base.transitions.irisIn() CountryClub = bboard.get(DistributedCountryClub.DistributedCountryClub.ReadyPost) self.loader.hood.spawnTitleText(CountryClub.countryClubId, CountryClub.floorNum) self.CountryClubReadyWatcher = BulletinBoardWatcher.BulletinBoardWatcher('CountryClubReady', DistributedCountryClub.DistributedCountryClub.ReadyPost, commence) self.CountryClubDefeated = 0 self.acceptOnce(DistributedCountryClub.DistributedCountryClub.WinEvent, self.handleCountryClubWinEvent) if __debug__ and 0: self.accept('f10', lambda : messenger.send(DistributedCountryClub.DistributedCountryClub.WinEvent)) self.confrontedBoss = 0 def handleConfrontedBoss(self = self): self.confrontedBoss = 1 self.acceptOnce('localToonConfrontedCountryClubBoss', handleConfrontedBoss) def exit(self): NametagGlobals.setMasterArrowsOn(0) bboard.remove(DistributedCountryClub.DistributedCountryClub.ReadyPost) self._telemLimiter.destroy() del self._telemLimiter base.cr.forbidCheesyEffects(0) base.localAvatar.inventory.setRespectInvasions(1) self.fsm.requestFinalState() self.loader.music.stop() self.music.stop() self.ignoreAll() del self.CountryClubReadyWatcher def enterStopped(self): BattlePlace.BattlePlace.enterStopped(self) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterWalk(self, teleportIn = 0): BattlePlace.BattlePlace.enterWalk(self, teleportIn) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterPush(self): BattlePlace.BattlePlace.enterPush(self) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterWaitForBattle(self): CountryClubInterior.notify.debug('enterWaitForBattle') BattlePlace.BattlePlace.enterWaitForBattle(self) if base.localAvatar.getParent() != render: base.localAvatar.wrtReparentTo(render) base.localAvatar.b_setParent(ToontownGlobals.SPRender) def exitWaitForBattle(self): CountryClubInterior.notify.debug('exitWaitForBattle') BattlePlace.BattlePlace.exitWaitForBattle(self) def enterBattle(self, event): CountryClubInterior.notify.debug('enterBattle') self.music.stop() BattlePlace.BattlePlace.enterBattle(self, event) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterTownBattle(self, event): mult = ToontownBattleGlobals.getCountryClubCreditMultiplier(self.zoneId) base.localAvatar.inventory.setBattleCreditMultiplier(mult) self.loader.townBattle.enter(event, self.fsm.getStateNamed('battle'), bldg=1, creditMultiplier=mult) def exitBattle(self): CountryClubInterior.notify.debug('exitBattle') BattlePlace.BattlePlace.exitBattle(self) self.loader.music.stop() base.playMusic(self.music, looping=1, volume=0.8) def enterStickerBook(self, page = None): BattlePlace.BattlePlace.enterStickerBook(self, page) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterSit(self): BattlePlace.BattlePlace.enterSit(self) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterZone(self, zoneId): pass def enterTeleportOut(self, requestStatus): CountryClubInterior.notify.debug('enterTeleportOut()') BattlePlace.BattlePlace.enterTeleportOut(self, requestStatus, self.__teleportOutDone) def __processLeaveRequest(self, requestStatus): hoodId = requestStatus['hoodId'] if hoodId == ToontownGlobals.MyEstate: self.getEstateZoneAndGoHome(requestStatus) else: self.doneStatus = requestStatus messenger.send(self.doneEvent) def __teleportOutDone(self, requestStatus): CountryClubInterior.notify.debug('__teleportOutDone()') messenger.send('leavingCountryClub') messenger.send('localToonLeft') if self.CountryClubDefeated and not self.confrontedBoss: self.fsm.request('FLA', [requestStatus]) else: self.__processLeaveRequest(requestStatus) def exitTeleportOut(self): CountryClubInterior.notify.debug('exitTeleportOut()') BattlePlace.BattlePlace.exitTeleportOut(self) def handleCountryClubWinEvent--- This code section failed: ---
class StageInterior(BattlePlace.BattlePlace): notify = DirectNotifyGlobal.directNotify.newCategory("StageInterior") def __init__(self, loader, parentFSM, doneEvent): BattlePlace.BattlePlace.__init__(self, loader, doneEvent) self.parentFSM = parentFSM self.zoneId = loader.stageId self.elevatorDoneEvent = "elevatorDone" self.fsm = ClassicFSM.ClassicFSM( "StageInterior", [ State.State("start", self.enterStart, self.exitStart, ["walk", "teleportIn", "fallDown"]), State.State( "walk", self.enterWalk, self.exitWalk, [ "push", "sit", "stickerBook", "WaitForBattle", "battle", "died", "teleportOut", "squished", "DFA", "fallDown", "elevator", ], ), State.State("sit", self.enterSit, self.exitSit, ["walk", "died", "teleportOut"]), State.State("push", self.enterPush, self.exitPush, ["walk", "died", "teleportOut"]), State.State( "stickerBook", self.enterStickerBook, self.exitStickerBook, ["walk", "battle", "DFA", "WaitForBattle", "died", "teleportOut"], ), State.State( "WaitForBattle", self.enterWaitForBattle, self.exitWaitForBattle, ["battle", "walk", "died", "teleportOut"], ), State.State("battle", self.enterBattle, self.exitBattle, ["walk", "teleportOut", "died"]), State.State("fallDown", self.enterFallDown, self.exitFallDown, ["walk", "died", "teleportOut"]), State.State("squished", self.enterSquished, self.exitSquished, ["walk", "died", "teleportOut"]), State.State( "teleportIn", self.enterTeleportIn, self.exitTeleportIn, ["walk", "teleportOut", "quietZone", "died"], ), State.State( "teleportOut", self.enterTeleportOut, self.exitTeleportOut, ["teleportIn", "FLA", "quietZone", "WaitForBattle"], ), State.State("DFA", self.enterDFA, self.exitDFA, ["DFAReject", "teleportOut"]), State.State("DFAReject", self.enterDFAReject, self.exitDFAReject, ["walkteleportOut"]), State.State("died", self.enterDied, self.exitDied, ["teleportOut"]), State.State("FLA", self.enterFLA, self.exitFLA, ["quietZone"]), State.State("quietZone", self.enterQuietZone, self.exitQuietZone, ["teleportIn"]), State.State("elevator", self.enterElevator, self.exitElevator, ["walk"]), State.State("final", self.enterFinal, self.exitFinal, ["start"]), ], "start", "final", ) def load(self): self.parentFSM.getStateNamed("stageInterior").addChild(self.fsm) BattlePlace.BattlePlace.load(self) self.music = base.loadMusic("phase_9/audio/bgm/CHQ_FACT_bg.ogg") def unload(self): self.parentFSM.getStateNamed("stageInterior").removeChild(self.fsm) del self.music del self.fsm del self.parentFSM BattlePlace.BattlePlace.unload(self) def enter(self, requestStatus): self.fsm.enterInitialState() base.transitions.fadeOut(t=0) self._telemLimiter = TLGatherAllAvs("StageInterior", RotationLimitToH) base.localAvatar.inventory.setRespectInvasions(0) base.cr.forbidCheesyEffects(1) def commence(self=self): NametagGlobals.setWant2dNametags(True) self.fsm.request(requestStatus["how"], [requestStatus]) base.playMusic(self.music, looping=1, volume=0.8) base.transitions.irisIn() stage = bboard.get(DistributedStage.DistributedStage.ReadyPost) self.loader.hood.spawnTitleText(stage.stageId) self.stageReadyWatcher = BulletinBoardWatcher.BulletinBoardWatcher( "StageReady", DistributedStage.DistributedStage.ReadyPost, commence ) self.stageDefeated = 0 self.acceptOnce(DistributedStage.DistributedStage.WinEvent, self.handleStageWinEvent) if __debug__ and 0: self.accept("f10", lambda: messenger.send(DistributedStage.DistributedStage.WinEvent)) self.confrontedBoss = 0 def handleConfrontedBoss(self=self): self.confrontedBoss = 1 self.acceptOnce("localToonConfrontedStageBoss", handleConfrontedBoss) def exit(self): NametagGlobals.setWant2dNametags(False) self._telemLimiter.destroy() del self._telemLimiter bboard.remove(DistributedStage.DistributedStage.ReadyPost) base.cr.forbidCheesyEffects(0) base.localAvatar.inventory.setRespectInvasions(1) self.fsm.requestFinalState() self.loader.music.stop() self.music.stop() self.ignoreAll() del self.stageReadyWatcher def enterWalk(self, teleportIn=0): BattlePlace.BattlePlace.enterWalk(self, teleportIn) self.ignore("teleportQuery") base.localAvatar.setTeleportAvailable(0) def enterPush(self): BattlePlace.BattlePlace.enterPush(self) self.ignore("teleportQuery") base.localAvatar.setTeleportAvailable(0) def enterWaitForBattle(self): StageInterior.notify.debug("enterWaitForBattle") BattlePlace.BattlePlace.enterWaitForBattle(self) if base.localAvatar.getParent() != render: base.localAvatar.wrtReparentTo(render) base.localAvatar.b_setParent(ToontownGlobals.SPRender) def exitWaitForBattle(self): StageInterior.notify.debug("exitWaitForBattle") BattlePlace.BattlePlace.exitWaitForBattle(self) def enterBattle(self, event): StageInterior.notify.debug("enterBattle") self.music.stop() BattlePlace.BattlePlace.enterBattle(self, event) self.ignore("teleportQuery") base.localAvatar.setTeleportAvailable(0) def enterTownBattle(self, event): mult = ToontownBattleGlobals.getStageCreditMultiplier(bboard.get(DistributedStage.DistributedStage.FloorNum)) base.localAvatar.inventory.setBattleCreditMultiplier(mult) self.loader.townBattle.enter(event, self.fsm.getStateNamed("battle"), bldg=1, creditMultiplier=mult) def exitBattle(self): StageInterior.notify.debug("exitBattle") BattlePlace.BattlePlace.exitBattle(self) self.loader.music.stop() base.playMusic(self.music, looping=1, volume=0.8) def enterStickerBook(self, page=None): BattlePlace.BattlePlace.enterStickerBook(self, page) self.ignore("teleportQuery") base.localAvatar.setTeleportAvailable(0) def enterSit(self): BattlePlace.BattlePlace.enterSit(self) self.ignore("teleportQuery") base.localAvatar.setTeleportAvailable(0) def enterZone(self, zoneId): pass def enterTeleportOut(self, requestStatus): StageInterior.notify.debug("enterTeleportOut()") BattlePlace.BattlePlace.enterTeleportOut(self, requestStatus, self.__teleportOutDone) def __processLeaveRequest(self, requestStatus): hoodId = requestStatus["hoodId"] if hoodId == ToontownGlobals.MyEstate: self.getEstateZoneAndGoHome(requestStatus) else: self.doneStatus = requestStatus messenger.send(self.doneEvent) def __teleportOutDone(self, requestStatus): StageInterior.notify.debug("__teleportOutDone()") messenger.send("leavingStage") messenger.send("localToonLeft") if self.stageDefeated and not self.confrontedBoss: self.fsm.request("FLA", [requestStatus]) else: self.__processLeaveRequest(requestStatus) def exitTeleportOut(self): StageInterior.notify.debug("exitTeleportOut()") BattlePlace.BattlePlace.exitTeleportOut(self) def handleStageWinEvent(self): StageInterior.notify.debug("handleStageWinEvent") if base.cr.playGame.getPlace().fsm.getCurrentState().getName() == "died": return self.stageDefeated = 1 if 1: zoneId = ZoneUtil.getHoodId(self.zoneId) else: zoneId = ZoneUtil.getSafeZoneId(base.localAvatar.defaultZone) self.fsm.request( "teleportOut", [ { "loader": ZoneUtil.getLoaderName(zoneId), "where": ZoneUtil.getToonWhereName(zoneId), "how": "teleportIn", "hoodId": zoneId, "zoneId": zoneId, "shardId": None, "avId": -1, } ], ) def enterDied(self, requestStatus, callback=None): StageInterior.notify.debug("enterDied") def diedDone(requestStatus, self=self, callback=callback): if callback is not None: callback() messenger.send("leavingStage") self.doneStatus = requestStatus messenger.send(self.doneEvent) return BattlePlace.BattlePlace.enterDied(self, requestStatus, diedDone) def enterFLA(self, requestStatus): StageInterior.notify.debug("enterFLA") self.flaDialog = TTDialog.TTGlobalDialog( message=TTLocalizer.ForcedLeaveStageAckMsg, doneEvent="FLADone", style=TTDialog.Acknowledge, fadeScreen=1 ) def continueExit(self=self, requestStatus=requestStatus): self.__processLeaveRequest(requestStatus) self.accept("FLADone", continueExit) self.flaDialog.show() def exitFLA(self): StageInterior.notify.debug("exitFLA") if hasattr(self, "flaDialog"): self.flaDialog.cleanup() del self.flaDialog def detectedElevatorCollision(self, distElevator): self.fsm.request("elevator", [distElevator]) def enterElevator(self, distElevator): self.accept(self.elevatorDoneEvent, self.handleElevatorDone) self.elevator = Elevator.Elevator(self.fsm.getStateNamed("elevator"), self.elevatorDoneEvent, distElevator) distElevator.elevatorFSM = self.elevator self.elevator.load() self.elevator.enter() def exitElevator(self): self.ignore(self.elevatorDoneEvent) self.elevator.unload() self.elevator.exit() def handleElevatorDone(self, doneStatus): self.notify.debug("handling elevator done event") where = doneStatus["where"] if where == "reject": if hasattr(base.localAvatar, "elevatorNotifier") and base.localAvatar.elevatorNotifier.isNotifierOpen(): pass else: self.fsm.request("walk") elif where == "exit": self.fsm.request("walk") elif where == "factoryInterior" or where == "suitInterior": self.doneStatus = doneStatus self.doneEvent = "lawOfficeFloorDone" messenger.send(self.doneEvent) else: self.notify.error("Unknown mode: " + where + " in handleElevatorDone")
class CountryClubInterior(BattlePlace.BattlePlace): notify = DirectNotifyGlobal.directNotify.newCategory('CountryClubInterior') def __init__(self, loader, parentFSM, doneEvent): BattlePlace.BattlePlace.__init__(self, loader, doneEvent) self.parentFSM = parentFSM self.zoneId = loader.countryClubId self.elevatorDoneEvent = 'elevatorDone' self.fsm = ClassicFSM.ClassicFSM('CountryClubInterior', [ State.State('start', self.enterStart, self.exitStart, ['walk', 'teleportIn', 'fallDown']), State.State('walk', self.enterWalk, self.exitWalk, [ 'push', 'sit', 'stickerBook', 'WaitForBattle', 'battle', 'died', 'teleportOut', 'squished', 'DFA', 'fallDown', 'stopped', 'elevator' ]), State.State('stopped', self.enterStopped, self.exitStopped, ['walk', 'teleportOut', 'stickerBook']), State.State('sit', self.enterSit, self.exitSit, ['walk', 'died', 'teleportOut']), State.State('push', self.enterPush, self.exitPush, ['walk', 'died', 'teleportOut']), State.State('stickerBook', self.enterStickerBook, self.exitStickerBook, [ 'walk', 'battle', 'DFA', 'WaitForBattle', 'died', 'teleportOut' ]), State.State('WaitForBattle', self.enterWaitForBattle, self.exitWaitForBattle, ['battle', 'walk', 'died', 'teleportOut']), State.State('battle', self.enterBattle, self.exitBattle, ['walk', 'teleportOut', 'died']), State.State('fallDown', self.enterFallDown, self.exitFallDown, ['walk', 'died', 'teleportOut']), State.State('squished', self.enterSquished, self.exitSquished, ['walk', 'died', 'teleportOut']), State.State('teleportIn', self.enterTeleportIn, self.exitTeleportIn, ['walk', 'teleportOut', 'quietZone', 'died']), State.State('teleportOut', self.enterTeleportOut, self.exitTeleportOut, ['teleportIn', 'FLA', 'quietZone', 'WaitForBattle']), State.State('DFA', self.enterDFA, self.exitDFA, ['DFAReject', 'teleportOut']), State.State('DFAReject', self.enterDFAReject, self.exitDFAReject, ['walkteleportOut']), State.State('died', self.enterDied, self.exitDied, ['teleportOut']), State.State('FLA', self.enterFLA, self.exitFLA, ['quietZone']), State.State('quietZone', self.enterQuietZone, self.exitQuietZone, ['teleportIn']), State.State('elevator', self.enterElevator, self.exitElevator, ['walk']), State.State('final', self.enterFinal, self.exitFinal, ['start']) ], 'start', 'final') def load(self): self.parentFSM.getStateNamed('countryClubInterior').addChild(self.fsm) BattlePlace.BattlePlace.load(self) musicName = random.choice([ 'phase_12/audio/bgm/Bossbot_Factory_v1.ogg', 'phase_12/audio/bgm/Bossbot_Factory_v2.ogg', 'phase_12/audio/bgm/Bossbot_Factory_v3.ogg', 'phase_12/audio/bgm/Bossbot_Factory_v4.ogg' ]) self.music = base.loadMusic(musicName) def unload(self): self.parentFSM.getStateNamed('countryClubInterior').removeChild( self.fsm) del self.music del self.fsm del self.parentFSM BattlePlace.BattlePlace.unload(self) def enter(self, requestStatus): self.fsm.enterInitialState() base.transitions.fadeOut(t=0) base.localAvatar.inventory.setRespectInvasions(0) base.cr.forbidCheesyEffects(1) self._telemLimiter = TLGatherAllAvs('CountryClubInterior', RotationLimitToH) def commence(self=self): NametagGlobals.setMasterArrowsOn(1) self.fsm.request(requestStatus['how'], [requestStatus]) base.playMusic(self.music, looping=1, volume=0.8) base.transitions.irisIn() CountryClub = bboard.get( DistributedCountryClub.DistributedCountryClub.ReadyPost) self.loader.hood.spawnTitleText(CountryClub.countryClubId, CountryClub.floorNum) self.CountryClubReadyWatcher = BulletinBoardWatcher.BulletinBoardWatcher( 'CountryClubReady', DistributedCountryClub.DistributedCountryClub.ReadyPost, commence) self.CountryClubDefeated = 0 self.acceptOnce(DistributedCountryClub.DistributedCountryClub.WinEvent, self.handleCountryClubWinEvent) if __debug__ and 0: self.accept( 'f10', lambda: messenger.send(DistributedCountryClub. DistributedCountryClub.WinEvent)) self.confrontedBoss = 0 def handleConfrontedBoss(self=self): self.confrontedBoss = 1 self.acceptOnce('localToonConfrontedCountryClubBoss', handleConfrontedBoss) def exit(self): NametagGlobals.setMasterArrowsOn(0) bboard.remove(DistributedCountryClub.DistributedCountryClub.ReadyPost) self._telemLimiter.destroy() del self._telemLimiter base.cr.forbidCheesyEffects(0) base.localAvatar.inventory.setRespectInvasions(1) self.fsm.requestFinalState() self.loader.music.stop() self.music.stop() self.ignoreAll() del self.CountryClubReadyWatcher def enterStopped(self): BattlePlace.BattlePlace.enterStopped(self) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterWalk(self, teleportIn=0): BattlePlace.BattlePlace.enterWalk(self, teleportIn) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterPush(self): BattlePlace.BattlePlace.enterPush(self) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterWaitForBattle(self): CountryClubInterior.notify.debug('enterWaitForBattle') BattlePlace.BattlePlace.enterWaitForBattle(self) if base.localAvatar.getParent() != render: base.localAvatar.wrtReparentTo(render) base.localAvatar.b_setParent(ToontownGlobals.SPRender) def exitWaitForBattle(self): CountryClubInterior.notify.debug('exitWaitForBattle') BattlePlace.BattlePlace.exitWaitForBattle(self) def enterBattle(self, event): CountryClubInterior.notify.debug('enterBattle') self.music.stop() BattlePlace.BattlePlace.enterBattle(self, event) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterTownBattle(self, event): mult = ToontownBattleGlobals.getCountryClubCreditMultiplier( self.zoneId) base.localAvatar.inventory.setBattleCreditMultiplier(mult) self.loader.townBattle.enter(event, self.fsm.getStateNamed('battle'), bldg=1, creditMultiplier=mult) def exitBattle(self): CountryClubInterior.notify.debug('exitBattle') BattlePlace.BattlePlace.exitBattle(self) self.loader.music.stop() base.playMusic(self.music, looping=1, volume=0.8) def enterStickerBook(self, page=None): BattlePlace.BattlePlace.enterStickerBook(self, page) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterSit(self): BattlePlace.BattlePlace.enterSit(self) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterZone(self, zoneId): pass def enterTeleportOut(self, requestStatus): CountryClubInterior.notify.debug('enterTeleportOut()') BattlePlace.BattlePlace.enterTeleportOut(self, requestStatus, self.__teleportOutDone) def __processLeaveRequest(self, requestStatus): hoodId = requestStatus['hoodId'] if hoodId == ToontownGlobals.MyEstate: self.getEstateZoneAndGoHome(requestStatus) else: self.doneStatus = requestStatus messenger.send(self.doneEvent) def __teleportOutDone(self, requestStatus): CountryClubInterior.notify.debug('__teleportOutDone()') messenger.send('leavingCountryClub') messenger.send('localToonLeft') if self.CountryClubDefeated and not self.confrontedBoss: self.fsm.request('FLA', [requestStatus]) else: self.__processLeaveRequest(requestStatus) def exitTeleportOut(self): CountryClubInterior.notify.debug('exitTeleportOut()') BattlePlace.BattlePlace.exitTeleportOut(self) def handleCountryClubWinEvent(self): CountryClubInterior.notify.debug('handleCountryClubWinEvent') if base.cr.playGame.getPlace().fsm.getCurrentState().getName( ) == 'died': return self.CountryClubDefeated = 1 if 1: zoneId = ZoneUtil.getHoodId(self.zoneId) else: zoneId = ZoneUtil.getSafeZoneId(base.localAvatar.defaultZone) self.fsm.request('teleportOut', [{ 'loader': ZoneUtil.getLoaderName(zoneId), 'where': ZoneUtil.getToonWhereName(zoneId), 'how': 'teleportIn', 'hoodId': zoneId, 'zoneId': zoneId, 'shardId': None, 'avId': -1, }]) def enterDied(self, requestStatus, callback=None): CountryClubInterior.notify.debug('enterDied') def diedDone(requestStatus, self=self, callback=callback): if callback is not None: callback() messenger.send('leavingCountryClub') self.doneStatus = requestStatus messenger.send(self.doneEvent) return BattlePlace.BattlePlace.enterDied(self, requestStatus, diedDone) def enterFLA(self, requestStatus): CountryClubInterior.notify.debug('enterFLA') self.flaDialog = TTDialog.TTGlobalDialog( message=TTLocalizer.ForcedLeaveCountryClubAckMsg, doneEvent='FLADone', style=TTDialog.Acknowledge, fadeScreen=1) def continueExit(self=self, requestStatus=requestStatus): self.__processLeaveRequest(requestStatus) self.accept('FLADone', continueExit) self.flaDialog.show() def exitFLA(self): CountryClubInterior.notify.debug('exitFLA') if hasattr(self, 'flaDialog'): self.flaDialog.cleanup() del self.flaDialog def detectedElevatorCollision(self, distElevator): self.fsm.request('elevator', [distElevator]) def enterElevator(self, distElevator, skipDFABoard=0): self.accept(self.elevatorDoneEvent, self.handleElevatorDone) self.elevator = Elevator.Elevator(self.fsm.getStateNamed('elevator'), self.elevatorDoneEvent, distElevator) if skipDFABoard: self.elevator.skipDFABoard = 1 self.elevator.setReverseBoardingCamera(True) distElevator.elevatorFSM = self.elevator self.elevator.load() self.elevator.enter() def exitElevator(self): self.ignore(self.elevatorDoneEvent) self.elevator.unload() self.elevator.exit() def handleElevatorDone(self, doneStatus): self.notify.debug('handling elevator done event') where = doneStatus['where'] if where == 'reject': if hasattr( base.localAvatar, 'elevatorNotifier' ) and base.localAvatar.elevatorNotifier.isNotifierOpen(): pass else: self.fsm.request('walk') elif where == 'exit': self.fsm.request('walk') elif where == 'factoryInterior' or where == 'suitInterior': self.doneStatus = doneStatus self.doneEvent = 'lawOfficeFloorDone' messenger.send(self.doneEvent) else: self.notify.error('Unknown mode: ' + where + ' in handleElevatorDone')
class FactoryInterior(BattlePlace.BattlePlace): notify = DirectNotifyGlobal.directNotify.newCategory('FactoryInterior') def __init__(self, loader, parentFSM, doneEvent): BattlePlace.BattlePlace.__init__(self, loader, doneEvent) self.parentFSM = parentFSM self.zoneId = ToontownGlobals.SellbotFactoryInt self.elevatorDoneEvent = 'elevatorDone' def load(self): self.fsm = ClassicFSM.ClassicFSM('FactoryInterior', [State.State('start', self.enterStart, self.exitStart, ['walk', 'teleportIn', 'fallDown']), State.State('walk', self.enterWalk, self.exitWalk, ['push', 'sit', 'stickerBook', 'WaitForBattle', 'battle', 'died', 'teleportOut', 'squished', 'DFA', 'fallDown', 'elevator']), State.State('stopped', self.enterStopped, self.exitStopped, ['walk', 'teleportOut']), State.State('sit', self.enterSit, self.exitSit, ['walk', 'died', 'teleportOut']), State.State('push', self.enterPush, self.exitPush, ['walk', 'died', 'teleportOut']), State.State('stickerBook', self.enterStickerBook, self.exitStickerBook, ['walk', 'battle', 'DFA', 'WaitForBattle', 'died', 'teleportOut']), State.State('WaitForBattle', self.enterWaitForBattle, self.exitWaitForBattle, ['battle', 'walk', 'died', 'teleportOut']), State.State('battle', self.enterBattle, self.exitBattle, ['walk', 'teleportOut', 'died']), State.State('fallDown', self.enterFallDown, self.exitFallDown, ['walk', 'died', 'teleportOut']), State.State('squished', self.enterSquished, self.exitSquished, ['walk', 'died', 'teleportOut']), State.State('teleportIn', self.enterTeleportIn, self.exitTeleportIn, ['walk', 'teleportOut', 'quietZone', 'died']), State.State('teleportOut', self.enterTeleportOut, self.exitTeleportOut, ['teleportIn', 'FLA', 'quietZone', 'WaitForBattle']), State.State('DFA', self.enterDFA, self.exitDFA, ['DFAReject', 'teleportOut']), State.State('DFAReject', self.enterDFAReject, self.exitDFAReject, ['walkteleportOut']), State.State('died', self.enterDied, self.exitDied, ['teleportOut']), State.State('FLA', self.enterFLA, self.exitFLA, ['quietZone']), State.State('quietZone', self.enterQuietZone, self.exitQuietZone, ['teleportIn']), State.State('elevator', self.enterElevator, self.exitElevator, ['walk']), State.State('final', self.enterFinal, self.exitFinal, ['start'])], 'start', 'final') self.parentFSM.getStateNamed('factoryInterior').addChild(self.fsm) BattlePlace.BattlePlace.load(self) self.music = base.loadMusic('phase_9/audio/bgm/CHQ_FACT_bg.ogg') def unload(self): self.parentFSM.getStateNamed('factoryInterior').removeChild(self.fsm) del self.fsm del self.music BattlePlace.BattlePlace.unload(self) def enter(self, requestStatus): self.fsm.enterInitialState() base.transitions.fadeOut(t=0) base.localAvatar.inventory.setRespectInvasions(0) self._telemLimiter = TLGatherAllAvs('FactoryInterior', RotationLimitToH) def commence(self = self): NametagGlobals.setMasterArrowsOn(1) self.fsm.request(requestStatus['how'], [requestStatus]) base.playMusic(self.music, looping=1, volume=0.8) base.transitions.irisIn() if hasattr(base, 'factoryReady'): commence() else: self.acceptOnce('FactoryReady', commence) self.factoryDefeated = 0 self.acceptOnce('FactoryWinEvent', self.handleFactoryWinEvent) if __debug__ and 0: self.accept('f10', lambda : messenger.send('FactoryWinEvent')) self.confrontedForeman = 0 def handleConfrontedForeman(self = self): self.confrontedForeman = 1 self.acceptOnce('localToonConfrontedForeman', handleConfrontedForeman) def exit(self): NametagGlobals.setMasterArrowsOn(0) self._telemLimiter.destroy() del self._telemLimiter if hasattr(base, 'factoryReady'): del base.factoryReady base.localAvatar.inventory.setRespectInvasions(1) self.fsm.requestFinalState() self.loader.music.stop() self.music.stop() self.ignoreAll() def enterWalk(self, teleportIn = 0): BattlePlace.BattlePlace.enterWalk(self, teleportIn) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterPush(self): BattlePlace.BattlePlace.enterPush(self) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterWaitForBattle(self): FactoryInterior.notify.info('enterWaitForBattle') BattlePlace.BattlePlace.enterWaitForBattle(self) if base.localAvatar.getParent() != render: base.localAvatar.wrtReparentTo(render) base.localAvatar.b_setParent(ToontownGlobals.SPRender) def exitWaitForBattle(self): FactoryInterior.notify.info('exitWaitForBattle') BattlePlace.BattlePlace.exitWaitForBattle(self) def enterBattle(self, event): FactoryInterior.notify.info('enterBattle') self.music.stop() BattlePlace.BattlePlace.enterBattle(self, event) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterTownBattle(self, event): mult = ToontownBattleGlobals.getFactoryCreditMultiplier(self.zoneId) base.localAvatar.inventory.setBattleCreditMultiplier(mult) self.loader.townBattle.enter(event, self.fsm.getStateNamed('battle'), bldg=1, creditMultiplier=mult) def exitBattle(self): FactoryInterior.notify.info('exitBattle') BattlePlace.BattlePlace.exitBattle(self) self.loader.music.stop() base.playMusic(self.music, looping=1, volume=0.8) def enterStickerBook(self, page = None): BattlePlace.BattlePlace.enterStickerBook(self, page) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterSit(self): BattlePlace.BattlePlace.enterSit(self) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterZone(self, zoneId): pass def enterTeleportOut(self, requestStatus): FactoryInterior.notify.info('enterTeleportOut()') BattlePlace.BattlePlace.enterTeleportOut(self, requestStatus, self.__teleportOutDone) def __processLeaveRequest(self, requestStatus): hoodId = requestStatus['hoodId'] if hoodId == ToontownGlobals.MyEstate: self.getEstateZoneAndGoHome(requestStatus) else: self.doneStatus = requestStatus messenger.send(self.doneEvent) def __teleportOutDone(self, requestStatus): FactoryInterior.notify.info('__teleportOutDone()') messenger.send('leavingFactory') messenger.send('localToonLeft') if self.factoryDefeated and not self.confrontedForeman: self.fsm.request('FLA', [requestStatus]) else: self.__processLeaveRequest(requestStatus) def exitTeleportOut(self): FactoryInterior.notify.info('exitTeleportOut()') BattlePlace.BattlePlace.exitTeleportOut(self) def detectedElevatorCollision(self, distElevator): self.fsm.request('elevator', [distElevator]) def enterElevator(self, distElevator): self.accept(self.elevatorDoneEvent, self.handleElevatorDone) self.elevator = Elevator.Elevator(self.fsm.getStateNamed('elevator'), self.elevatorDoneEvent, distElevator) distElevator.elevatorFSM = self.elevator self.elevator.load() self.elevator.enter() def exitElevator(self): self.ignore(self.elevatorDoneEvent) self.elevator.unload() self.elevator.exit() def handleElevatorDone(self, doneStatus): self.notify.debug('handling elevator done event') where = doneStatus['where'] if where == 'reject': if hasattr(base.localAvatar, 'elevatorNotifier') and base.localAvatar.elevatorNotifier.isNotifierOpen(): pass else: self.fsm.request('walk') elif where == 'exit': self.fsm.request('walk') elif where == 'factoryInterior' or where == 'suitInterior': self.doneStatus = doneStatus self.doneEvent = 'lawOfficeFloorDone' messenger.send(self.doneEvent) else: self.notify.error('Unknown mode: ' + where + ' in handleElevatorDone') def handleFactoryWinEvent(self): FactoryInterior.notify.info('handleFactoryWinEvent') if base.cr.playGame.getPlace().fsm.getCurrentState().getName() == 'died': return self.factoryDefeated = 1 if 1: zoneId = ZoneUtil.getHoodId(self.zoneId) else: zoneId = ZoneUtil.getSafeZoneId(base.localAvatar.defaultZone) self.fsm.request('teleportOut', [{ 'loader': ZoneUtil.getLoaderName(zoneId), 'where': ZoneUtil.getToonWhereName(zoneId), 'how': 'teleportIn', 'hoodId': zoneId, 'zoneId': zoneId, 'shardId': None, 'avId': -1, }]) def enterDied(self, requestStatus, callback = None): FactoryInterior.notify.info('enterDied') def diedDone(requestStatus, self = self, callback = callback): if callback is not None: callback() messenger.send('leavingFactory') self.doneStatus = requestStatus messenger.send(self.doneEvent) return BattlePlace.BattlePlace.enterDied(self, requestStatus, diedDone) def enterFLA(self, requestStatus): FactoryInterior.notify.info('enterFLA') self.flaDialog = TTDialog.TTGlobalDialog(message=TTLocalizer.ForcedLeaveFactoryAckMsg, doneEvent='FLADone', style=TTDialog.Acknowledge, fadeScreen=1) def continueExit(self = self, requestStatus = requestStatus): self.__processLeaveRequest(requestStatus) self.accept('FLADone', continueExit) self.flaDialog.show() def exitFLA(self): FactoryInterior.notify.info('exitFLA') if hasattr(self, 'flaDialog'): self.flaDialog.cleanup() del self.flaDialog
class House(Place.Place): notify = DirectNotifyGlobal.directNotify.newCategory('House') def __init__(self, loader, avId, parentFSMState, doneEvent): Place.Place.__init__(self, loader, doneEvent) self.id = ToontownGlobals.MyEstate self.ownersAvId = avId self.dnaFile = 'phase_7/models/modules/toon_interior' self.isInterior = 1 self.tfaDoneEvent = 'tfaDoneEvent' self.oldStyle = None self.fsm = ClassicFSM.ClassicFSM('House', [ State.State('start', self.enterStart, self.exitStart, ['doorIn', 'teleportIn', 'tutorial']), State.State('walk', self.enterWalk, self.exitWalk, [ 'sit', 'stickerBook', 'doorOut', 'DFA', 'teleportOut', 'quest', 'purchase', 'closet', 'banking', 'phone', 'stopped' ]), State.State('sit', self.enterSit, self.exitSit, ['walk']), State.State( 'stickerBook', self.enterStickerBook, self.exitStickerBook, [ 'walk', 'DFA', 'sit', 'doorOut', 'teleportOut', 'quest', 'purchase', 'closet', 'banking', 'phone', 'stopped' ]), State.State('DFA', self.enterDFA, self.exitDFA, ['DFAReject', 'teleportOut', 'doorOut']), State.State('DFAReject', self.enterDFAReject, self.exitDFAReject, ['walk']), State.State('doorIn', self.enterDoorIn, self.exitDoorIn, ['walk']), State.State('doorOut', self.enterDoorOut, self.exitDoorOut, ['walk']), State.State('teleportIn', self.enterTeleportIn, self.exitTeleportIn, ['walk']), State.State('teleportOut', self.enterTeleportOut, self.exitTeleportOut, ['teleportIn']), State.State('quest', self.enterQuest, self.exitQuest, ['walk', 'doorOut']), State.State('tutorial', self.enterTutorial, self.exitTutorial, ['walk', 'quest']), State.State('purchase', self.enterPurchase, self.exitPurchase, ['walk', 'doorOut']), State.State('closet', self.enterCloset, self.exitCloset, ['walk']), State.State('banking', self.enterBanking, self.exitBanking, ['walk']), State.State('phone', self.enterPhone, self.exitPhone, ['walk']), State.State('stopped', self.enterStopped, self.exitStopped, ['walk']), State.State('final', self.enterFinal, self.exitFinal, ['start', 'teleportIn']) ], 'start', 'final') self.parentFSMState = parentFSMState def load(self): Place.Place.load(self) self.parentFSMState.addChild(self.fsm) def unload(self): Place.Place.unload(self) self.parentFSMState.removeChild(self.fsm) del self.parentFSMState del self.fsm ModelPool.garbageCollect() TexturePool.garbageCollect() def enter(self, requestStatus): self.zoneId = requestStatus['zoneId'] self.fsm.enterInitialState() messenger.send('enterHouse') self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) self._telemLimiter = TLGatherAllAvs('House', RotationLimitToH) NametagGlobals.setMasterArrowsOn(1) self.fsm.request(requestStatus['how'], [requestStatus]) def exit(self): self.ignoreAll() if hasattr(self, 'fsm'): self.fsm.requestFinalState() self._telemLimiter.destroy() del self._telemLimiter messenger.send('exitHouse') NametagGlobals.setMasterArrowsOn(0) def setState(self, state): if hasattr(self, 'fsm'): self.fsm.request(state) def getZoneId(self): return self.zoneId def enterTutorial(self, requestStatus): self.fsm.request('walk') base.localAvatar.b_setParent(ToontownGlobals.SPRender) globalClock.tick() base.transitions.irisIn() messenger.send('enterTutorialInterior') def exitTutorial(self): pass def enterTeleportIn(self, requestStatus): base.localAvatar.setPosHpr(2.5, 11.5, ToontownGlobals.FloorOffset, 45.0, 0.0, 0.0) Place.Place.enterTeleportIn(self, requestStatus) def enterTeleportOut(self, requestStatus): Place.Place.enterTeleportOut(self, requestStatus, self._House__teleportOutDone) def _House__teleportOutDone(self, requestStatus): if hasattr(self, 'fsm'): self.fsm.requestFinalState() self.notify.debug('House: teleportOutDone: requestStatus = %s' % requestStatus) hoodId = requestStatus['hoodId'] zoneId = requestStatus['zoneId'] avId = requestStatus['avId'] shardId = requestStatus['shardId'] if hoodId == ToontownGlobals.MyEstate and zoneId == self.getZoneId(): self.fsm.request('teleportIn', [requestStatus]) elif hoodId == ToontownGlobals.MyEstate: self.getEstateZoneAndGoHome(requestStatus) else: self.doneStatus = requestStatus messenger.send(self.doneEvent, [self.doneStatus]) def goHomeFailed(self, task): self.notifyUserGoHomeFailed() self.ignore('setLocalEstateZone') self.doneStatus['avId'] = -1 self.doneStatus['zoneId'] = self.getZoneId() self.fsm.request('teleportIn', [self.doneStatus]) return Task.done def exitTeleportOut(self): Place.Place.exitTeleportOut(self) def enterPurchase(self): Place.Place.enterPurchase(self) def exitPurchase(self): Place.Place.exitPurchase(self) def enterCloset(self): base.localAvatar.b_setAnimState('neutral', 1) self.accept('teleportQuery', self.handleTeleportQuery) base.localAvatar.setTeleportAvailable(1) base.localAvatar.laffMeter.start() base.localAvatar.obscureMoveFurnitureButton(1) base.localAvatar.startSleepWatch( self._House__handleFallingAsleepCloset) self.enablePeriodTimer() def _House__handleFallingAsleepCloset(self, arg): if hasattr(self, 'fsm'): self.fsm.request('walk') messenger.send('closetAsleep') base.localAvatar.forceGotoSleep() def exitCloset(self): base.localAvatar.setTeleportAvailable(0) self.ignore('teleportQuery') base.localAvatar.laffMeter.stop() base.localAvatar.obscureMoveFurnitureButton(-1) base.localAvatar.stopSleepWatch() self.disablePeriodTimer() def enterBanking(self): Place.Place.enterBanking(self) def exitBanking(self): Place.Place.exitBanking(self)
class CogHQBossBattle(BattlePlace.BattlePlace): notify = DirectNotifyGlobal.directNotify.newCategory('CogHQBossBattle') def __init__(self, loader, parentFSM, doneEvent): BattlePlace.BattlePlace.__init__(self, loader, doneEvent) self.parentFSM = parentFSM self.bossCog = None self.teleportInPosHpr = (0, 0, 0, 0, 0, 0) self.fsm = ClassicFSM.ClassicFSM('CogHQBossBattle', [ State.State('start', self.enterStart, self.exitStart, ['walk', 'tunnelIn', 'teleportIn', 'movie']), State.State('battle', self.enterBattle, self.exitBattle, ['walk', 'died', 'movie']), State.State( 'finalBattle', self.enterFinalBattle, self.exitFinalBattle, [ 'walk', 'stickerBook', 'teleportOut', 'died', 'tunnelOut', 'DFA', 'battle', 'movie', 'ouch', 'crane', 'WaitForBattle', 'squished' ]), State.State( 'movie', self.enterMovie, self.exitMovie, ['walk', 'battle', 'finalBattle', 'died', 'teleportOut']), State.State('ouch', self.enterOuch, self.exitOuch, ['walk', 'battle', 'finalBattle', 'died', 'crane']), State.State( 'crane', self.enterCrane, self.exitCrane, ['walk', 'battle', 'finalBattle', 'died', 'ouch', 'squished']), State.State('walk', self.enterWalk, self.exitWalk, [ 'stickerBook', 'teleportOut', 'died', 'tunnelOut', 'DFA', 'battle', 'movie', 'ouch', 'crane', 'finalBattle', 'WaitForBattle' ]), State.State('stickerBook', self.enterStickerBook, self.exitStickerBook, ['walk', 'DFA', 'WaitForBattle', 'movie', 'battle']), State.State('WaitForBattle', self.enterWaitForBattle, self.exitWaitForBattle, ['battle', 'walk', 'movie']), State.State('DFA', self.enterDFA, self.exitDFA, ['DFAReject', 'teleportOut', 'tunnelOut']), State.State('DFAReject', self.enterDFAReject, self.exitDFAReject, ['walk']), State.State('teleportIn', self.enterTeleportIn, self.exitTeleportIn, ['walk']), State.State('teleportOut', self.enterTeleportOut, self.exitTeleportOut, ['teleportIn', 'final', 'WaitForBattle']), State.State('died', self.enterDied, self.exitDied, ['final']), State.State('tunnelIn', self.enterTunnelIn, self.exitTunnelIn, ['walk']), State.State('tunnelOut', self.enterTunnelOut, self.exitTunnelOut, ['final']), State.State('squished', self.enterSquished, self.exitSquished, ['finalBattle', 'crane', 'died', 'teleportOut']), State.State('final', self.enterFinal, self.exitFinal, ['start']) ], 'start', 'final') return def load(self): BattlePlace.BattlePlace.load(self) self.parentFSM.getStateNamed('cogHQBossBattle').addChild(self.fsm) self.townBattle = self.loader.townBattle for i in range(1, 3): Suit.loadSuits(i) def unload(self): BattlePlace.BattlePlace.unload(self) self.parentFSM.getStateNamed('cogHQBossBattle').removeChild(self.fsm) del self.parentFSM del self.fsm self.ignoreAll() for i in range(1, 3): Suit.unloadSuits(i) def getTaskZoneId(self): return base.cr.playGame.hood.id def enter(self, requestStatus, bossCog): self.zoneId = requestStatus['zoneId'] BattlePlace.BattlePlace.enter(self) self.fsm.enterInitialState() self.bossCog = bossCog if self.bossCog: self.bossCog.d_avatarEnter() self._telemLimiter = TLGatherAllAvs('CogHQBossBattle', RotationLimitToH) NametagGlobals.setMasterArrowsOn(1) base.localAvatar.inventory.setRespectInvasions(0) self.fsm.request(requestStatus['how'], [requestStatus]) def exit(self): self.fsm.requestFinalState() base.localAvatar.inventory.setRespectInvasions(1) if self.bossCog: self.bossCog.d_avatarExit() self.bossCog = None self._telemLimiter.destroy() del self._telemLimiter BattlePlace.BattlePlace.exit(self) return def enterBattle(self, event): mult = 1 if self.bossCog: mult = ToontownBattleGlobals.getBossBattleCreditMultiplier( self.bossCog.battleNumber) self.townBattle.enter(event, self.fsm.getStateNamed('battle'), bldg=1, creditMultiplier=mult) base.localAvatar.b_setAnimState('off', 1) base.localAvatar.setTeleportAvailable(0) base.localAvatar.cantLeaveGame = 1 def exitBattle(self): self.townBattle.exit() def enterFinalBattle(self): self.walkStateData.enter() self.walkStateData.fsm.request('walking') base.localAvatar.setTeleportAvailable(0) base.localAvatar.setTeleportAllowed(0) base.localAvatar.cantLeaveGame = 0 base.localAvatar.book.hideButton() self.ignore(ToontownGlobals.StickerBookHotkey) self.ignore('enterStickerBook') self.ignore(ToontownGlobals.OptionsPageHotkey) def exitFinalBattle(self): self.walkStateData.exit() base.localAvatar.setTeleportAllowed(1) def enterMovie(self, requestStatus=None): base.localAvatar.setTeleportAvailable(0) def exitMovie(self): pass def enterOuch(self): base.localAvatar.setTeleportAvailable(0) # I think this is what we need to use for the laff during battle :) base.localAvatar.laffMeter.start() def exitOuch(self): base.localAvatar.laffMeter.stop() def enterCrane(self): base.localAvatar.setTeleportAvailable(0) base.localAvatar.laffMeter.start() base.localAvatar.collisionsOn() def exitCrane(self): base.localAvatar.collisionsOff() base.localAvatar.laffMeter.stop() def enterWalk(self, teleportIn=0): BattlePlace.BattlePlace.enterWalk(self, teleportIn) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) base.localAvatar.setTeleportAllowed(0) base.localAvatar.book.hideButton() self.ignore(ToontownGlobals.StickerBookHotkey) self.ignore('enterStickerBook') self.ignore(ToontownGlobals.OptionsPageHotkey) self.ignore(self.walkDoneEvent) def exitWalk(self): BattlePlace.BattlePlace.exitWalk(self) base.localAvatar.setTeleportAllowed(1) def enterStickerBook(self, page=None): BattlePlace.BattlePlace.enterStickerBook(self, page) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterSit(self): BattlePlace.BattlePlace.enterSit(self) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterTeleportIn(self, requestStatus): base.localAvatar.detachNode() base.localAvatar.setPosHpr(*self.teleportInPosHpr) BattlePlace.BattlePlace.enterTeleportIn(self, requestStatus) def enterTeleportOut(self, requestStatus): BattlePlace.BattlePlace.enterTeleportOut(self, requestStatus, self.__teleportOutDone) def __teleportOutDone(self, requestStatus): hoodId = requestStatus['hoodId'] if hoodId == ToontownGlobals.MyEstate: self.getEstateZoneAndGoHome(requestStatus) else: self.doneStatus = requestStatus messenger.send(self.doneEvent) def enterSquished(self): base.localAvatar.laffMeter.start() base.localAvatar.b_setAnimState('Flattened') def handleSquishDone(self, extraArgs=[]): base.cr.playGame.getPlace().setState('walk') def exitSquished(self): taskMgr.remove(base.localAvatar.uniqueName('finishSquishTask')) base.localAvatar.laffMeter.stop()
class MintInterior(BattlePlace.BattlePlace): notify = DirectNotifyGlobal.directNotify.newCategory('MintInterior') def __init__(self, loader, parentFSM, doneEvent): BattlePlace.BattlePlace.__init__(self, loader, doneEvent) self.parentFSM = parentFSM self.zoneId = loader.mintId self.fsm = ClassicFSM.ClassicFSM('MintInterior', [State.State('start', self.enterStart, self.exitStart, ['walk', 'teleportIn', 'fallDown']), State.State('walk', self.enterWalk, self.exitWalk, ['push', 'sit', 'stickerBook', 'WaitForBattle', 'battle', 'died', 'teleportOut', 'squished', 'DFA', 'fallDown', 'stopped']), State.State('stopped', self.enterStopped, self.exitStopped, ['walk', 'teleportOut', 'stickerBook']), State.State('sit', self.enterSit, self.exitSit, ['walk', 'died', 'teleportOut']), State.State('push', self.enterPush, self.exitPush, ['walk', 'died', 'teleportOut']), State.State('stickerBook', self.enterStickerBook, self.exitStickerBook, ['walk', 'battle', 'DFA', 'WaitForBattle', 'died', 'teleportOut']), State.State('WaitForBattle', self.enterWaitForBattle, self.exitWaitForBattle, ['battle', 'walk', 'died', 'teleportOut']), State.State('battle', self.enterBattle, self.exitBattle, ['walk', 'teleportOut', 'died']), State.State('fallDown', self.enterFallDown, self.exitFallDown, ['walk', 'died', 'teleportOut']), State.State('squished', self.enterSquished, self.exitSquished, ['walk', 'died', 'teleportOut']), State.State('teleportIn', self.enterTeleportIn, self.exitTeleportIn, ['walk', 'teleportOut', 'quietZone', 'died']), State.State('teleportOut', self.enterTeleportOut, self.exitTeleportOut, ['teleportIn', 'FLA', 'quietZone', 'WaitForBattle']), State.State('DFA', self.enterDFA, self.exitDFA, ['DFAReject', 'teleportOut']), State.State('DFAReject', self.enterDFAReject, self.exitDFAReject, ['walkteleportOut']), State.State('died', self.enterDied, self.exitDied, ['teleportOut']), State.State('FLA', self.enterFLA, self.exitFLA, ['quietZone']), State.State('quietZone', self.enterQuietZone, self.exitQuietZone, ['teleportIn']), State.State('final', self.enterFinal, self.exitFinal, ['start'])], 'start', 'final') def load(self): self.parentFSM.getStateNamed('mintInterior').addChild(self.fsm) BattlePlace.BattlePlace.load(self) self.music = base.loader.loadMusic('phase_9/audio/bgm/CHQ_FACT_bg.ogg') def unload(self): self.parentFSM.getStateNamed('mintInterior').removeChild(self.fsm) del self.music del self.fsm del self.parentFSM BattlePlace.BattlePlace.unload(self) def enter(self, requestStatus): self.fsm.enterInitialState() base.transitions.fadeOut(t=0) base.localAvatar.inventory.setRespectInvasions(0) base.cr.forbidCheesyEffects(1) self._telemLimiter = TLGatherAllAvs('MintInterior', RotationLimitToH) def commence(self = self): NametagGlobals.setMasterArrowsOn(1) self.fsm.request(requestStatus['how'], [requestStatus]) base.playMusic(self.music, looping=1, volume=0.8) base.transitions.irisIn() mint = bboard.get(DistributedMint.DistributedMint.ReadyPost) self.loader.hood.spawnTitleText(mint.mintId, mint.floorNum) self.mintReadyWatcher = BulletinBoardWatcher.BulletinBoardWatcher('MintReady', DistributedMint.DistributedMint.ReadyPost, commence) self.mintDefeated = 0 self.acceptOnce(DistributedMint.DistributedMint.WinEvent, self.handleMintWinEvent) if __debug__ and 0: self.accept('f10', lambda : messenger.send(DistributedMint.DistributedMint.WinEvent)) self.confrontedBoss = 0 def handleConfrontedBoss(self = self): self.confrontedBoss = 1 self.acceptOnce('localToonConfrontedMintBoss', handleConfrontedBoss) def exit(self): NametagGlobals.setMasterArrowsOn(0) bboard.remove(DistributedMint.DistributedMint.ReadyPost) self._telemLimiter.destroy() del self._telemLimiter base.cr.forbidCheesyEffects(0) base.localAvatar.inventory.setRespectInvasions(1) self.fsm.requestFinalState() self.loader.music.stop() self.music.stop() self.ignoreAll() del self.mintReadyWatcher def enterWalk(self, teleportIn = 0): BattlePlace.BattlePlace.enterWalk(self, teleportIn) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterPush(self): BattlePlace.BattlePlace.enterPush(self) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterWaitForBattle(self): MintInterior.notify.debug('enterWaitForBattle') BattlePlace.BattlePlace.enterWaitForBattle(self) if base.localAvatar.getParent() != render: base.localAvatar.wrtReparentTo(render) base.localAvatar.b_setParent(ToontownGlobals.SPRender) def exitWaitForBattle(self): MintInterior.notify.debug('exitWaitForBattle') BattlePlace.BattlePlace.exitWaitForBattle(self) def enterBattle(self, event): MintInterior.notify.debug('enterBattle') self.music.stop() BattlePlace.BattlePlace.enterBattle(self, event) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterTownBattle(self, event): mult = ToontownBattleGlobals.getMintCreditMultiplier(self.zoneId) base.localAvatar.inventory.setBattleCreditMultiplier(mult) self.loader.townBattle.enter(event, self.fsm.getStateNamed('battle'), bldg=1, creditMultiplier=mult) def exitBattle(self): MintInterior.notify.debug('exitBattle') BattlePlace.BattlePlace.exitBattle(self) self.loader.music.stop() base.playMusic(self.music, looping=1, volume=0.8) def enterStickerBook(self, page = None): BattlePlace.BattlePlace.enterStickerBook(self, page) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterSit(self): BattlePlace.BattlePlace.enterSit(self) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterZone(self, zoneId): pass def enterTeleportOut(self, requestStatus): MintInterior.notify.debug('enterTeleportOut()') BattlePlace.BattlePlace.enterTeleportOut(self, requestStatus, self.__teleportOutDone) def __processLeaveRequest(self, requestStatus): hoodId = requestStatus['hoodId'] if hoodId == ToontownGlobals.Zones.MyEstate: self.getEstateZoneAndGoHome(requestStatus) else: self.doneStatus = requestStatus messenger.send(self.doneEvent) def __teleportOutDone(self, requestStatus): MintInterior.notify.debug('__teleportOutDone()') messenger.send('leavingMint') messenger.send('localToonLeft') if self.mintDefeated and not self.confrontedBoss: self.fsm.request('FLA', [requestStatus]) else: self.__processLeaveRequest(requestStatus) def exitTeleportOut(self): MintInterior.notify.debug('exitTeleportOut()') BattlePlace.BattlePlace.exitTeleportOut(self) def handleMintWinEvent(self): MintInterior.notify.debug('handleMintWinEvent') if base.cr.playGame.getPlace().fsm.getCurrentState().getName() == 'died': return self.mintDefeated = 1 if 1: zoneId = ZoneUtil.getHoodId(self.zoneId) else: zoneId = ZoneUtil.getSafeZoneId(base.localAvatar.defaultZone) self.fsm.request('teleportOut', [{'loader': ZoneUtil.getLoaderName(zoneId), 'where': ZoneUtil.getToonWhereName(zoneId), 'how': 'teleportIn', 'hoodId': zoneId, 'zoneId': zoneId, 'shardId': None, 'avId': -1}]) def enterDied(self, requestStatus, callback = None): MintInterior.notify.debug('enterDied') def diedDone(requestStatus, self = self, callback = callback): if callback is not None: callback() messenger.send('leavingMint') self.doneStatus = requestStatus messenger.send(self.doneEvent) return BattlePlace.BattlePlace.enterDied(self, requestStatus, diedDone) def enterFLA(self, requestStatus): MintInterior.notify.debug('enterFLA') self.flaDialog = TTDialog.TTGlobalDialog(message=TTLocalizer.ForcedLeaveMintAckMsg, doneEvent='FLADone', style=TTDialog.Acknowledge, fadeScreen=1) def continueExit(self = self, requestStatus = requestStatus): self.__processLeaveRequest(requestStatus) self.accept('FLADone', continueExit) self.flaDialog.show() def exitFLA(self): MintInterior.notify.debug('exitFLA') if hasattr(self, 'flaDialog'): self.flaDialog.cleanup() del self.flaDialog
class CogHQLobby(Place.Place): notify = DirectNotifyGlobal.directNotify.newCategory('CogHQLobby') def __init__(self, hood, parentFSM, doneEvent): Place.Place.__init__(self, hood, doneEvent) self.parentFSM = parentFSM self.elevatorDoneEvent = 'elevatorDone' self.fsm = ClassicFSM.ClassicFSM('CogHQLobby', [ State.State('start', self.enterStart, self.exitStart, ['walk', 'tunnelIn', 'teleportIn', 'doorIn']), State.State('walk', self.enterWalk, self.exitWalk, ['elevator', 'doorOut', 'stopped']), State.State('stopped', self.enterStopped, self.exitStopped, ['walk', 'teleportOut', 'elevator']), State.State('doorIn', self.enterDoorIn, self.exitDoorIn, ['walk', 'stopped']), State.State('doorOut', self.enterDoorOut, self.exitDoorOut, ['walk', 'stopped']), State.State('teleportIn', self.enterTeleportIn, self.exitTeleportIn, ['walk']), State.State('elevator', self.enterElevator, self.exitElevator, ['walk', 'stopped']), State.State('final', self.enterFinal, self.exitFinal, ['start']) ], 'start', 'final') def load(self): self.parentFSM.getStateNamed('cogHQLobby').addChild(self.fsm) Place.Place.load(self) def unload(self): self.parentFSM.getStateNamed('cogHQLobby').removeChild(self.fsm) Place.Place.unload(self) self.fsm = None return def enter(self, requestStatus): self.zoneId = requestStatus['zoneId'] Place.Place.enter(self) self.fsm.enterInitialState() base.playMusic(self.loader.music, looping=1, volume=0.8) self.loader.geom.reparentTo(render) self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) how = requestStatus['how'] self.fsm.request(how, [requestStatus]) self._telemLimiter = TLGatherAllAvs('CogHQLobby', RotationLimitToH) def exit(self): self._telemLimiter.destroy() del self._telemLimiter self.fsm.requestFinalState() self.ignoreAll() self.loader.music.stop() if self.loader.geom != None: self.loader.geom.reparentTo(hidden) Place.Place.exit(self) return def enterWalk(self, teleportIn=0): Place.Place.enterWalk(self, teleportIn) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterElevator(self, distElevator): self.accept(self.elevatorDoneEvent, self.handleElevatorDone) self.elevator = Elevator.Elevator(self.fsm.getStateNamed('elevator'), self.elevatorDoneEvent, distElevator) distElevator.elevatorFSM = self.elevator self.elevator.load() self.elevator.enter() def exitElevator(self): self.ignore(self.elevatorDoneEvent) self.elevator.unload() self.elevator.exit() del self.elevator def detectedElevatorCollision(self, distElevator): self.fsm.request('elevator', [distElevator]) def handleElevatorDone(self, doneStatus): self.notify.debug('handling elevator done event') where = doneStatus['where'] if where == 'reject': if hasattr( base.localAvatar, 'elevatorNotifier' ) and base.localAvatar.elevatorNotifier.isNotifierOpen(): pass else: self.fsm.request('walk') elif where == 'exit': self.fsm.request('walk') elif where == 'cogHQBossBattle': self.doneStatus = doneStatus messenger.send(self.doneEvent) else: self.notify.error('Unknown mode: ' + where + ' in handleElevatorDone') def enterTeleportIn(self, requestStatus): base.localAvatar.setPosHpr(render, 0, 0, 0, 0, 0, 0) Place.Place.enterTeleportIn(self, requestStatus)
class CogHQLobby(BattlePlace.BattlePlace): notify = DirectNotifyGlobal.directNotify.newCategory('CogHQLobby') def __init__(self, hood, parentFSM, doneEvent): BattlePlace.BattlePlace.__init__(self, hood, doneEvent) self.parentFSM = parentFSM self.elevatorDoneEvent = 'elevatorDone' self.fsm = ClassicFSM.ClassicFSM('CogHQLobby', [ State.State('start', self.enterStart, self.exitStart, ['walk', 'tunnelIn', 'teleportIn', 'doorIn']), State.State('walk', self.enterWalk, self.exitWalk, [ 'elevator', 'stickerBook', 'teleportOut', 'tunnelOut', 'DFA', 'doorOut', 'stopped', 'died', 'WaitForBattle' ]), State.State('stopped', self.enterStopped, self.exitStopped, [ 'walk', 'teleportOut', 'tunnelOut', 'stickerBook', 'elevator' ]), State.State('doorIn', self.enterDoorIn, self.exitDoorIn, ['walk']), State.State('doorOut', self.enterDoorOut, self.exitDoorOut, ['walk']), State.State( 'stickerBook', self.enterStickerBook, self.exitStickerBook, [ 'walk', 'DFA', 'WaitForBattle', 'battle', 'tunnelOut', 'doorOut', 'squished', 'died', 'died' ]), State.State('WaitForBattle', self.enterWaitForBattle, self.exitWaitForBattle, ['battle', 'walk']), State.State('battle', self.enterBattle, self.exitBattle, ['walk', 'teleportOut', 'died']), State.State('teleportIn', self.enterTeleportIn, self.exitTeleportIn, ['walk']), State.State('teleportOut', self.enterTeleportOut, self.exitTeleportOut, ['teleportIn', 'final', 'WaitForBattle']), State.State('quietZone', self.enterQuietZone, self.exitQuietZone, ['teleportIn']), State.State('died', self.enterDied, self.exitDied, ['quietZone']), State.State('tunnelIn', self.enterTunnelIn, self.exitTunnelIn, ['walk']), State.State('tunnelOut', self.enterTunnelOut, self.exitTunnelOut, ['final']), State.State('elevator', self.enterElevator, self.exitElevator, ['walk', 'stopped']), State.State('DFA', self.enterDFA, self.exitDFA, ['DFAReject', 'teleportOut', 'tunnelOut']), State.State('DFAReject', self.enterDFAReject, self.exitDFAReject, ['walk']), State.State('final', self.enterFinal, self.exitFinal, ['start']) ], 'start', 'final') def load(self): self.parentFSM.getStateNamed('cogHQLobby').addChild(self.fsm) BattlePlace.BattlePlace.load(self) def unload(self): self.parentFSM.getStateNamed('cogHQLobby').removeChild(self.fsm) BattlePlace.BattlePlace.unload(self) self.fsm = None return def enter(self, requestStatus): self.zoneId = requestStatus['zoneId'] BattlePlace.BattlePlace.enter(self) self.fsm.enterInitialState() base.playMusic(self.loader.music, looping=1, volume=0.8) self.loader.geom.reparentTo(render) self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) NametagGlobals.setMasterArrowsOn(1) how = requestStatus['how'] self.fsm.request(how, [requestStatus]) self._telemLimiter = TLGatherAllAvs('CogHQLobby', RotationLimitToH) def exit(self): self._telemLimiter.destroy() del self._telemLimiter self.fsm.requestFinalState() self.ignoreAll() self.loader.music.stop() if self.loader.geom != None: self.loader.geom.reparentTo(hidden) BattlePlace.BattlePlace.exit(self) return def enterWalk(self, teleportIn=0): BattlePlace.BattlePlace.enterWalk(self, teleportIn) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterElevator(self, distElevator, skipDFABoard=0): self.accept(self.elevatorDoneEvent, self.handleElevatorDone) self.elevator = Elevator.Elevator(self.fsm.getStateNamed('elevator'), self.elevatorDoneEvent, distElevator) if skipDFABoard: self.elevator.skipDFABoard = 1 distElevator.elevatorFSM = self.elevator self.elevator.load() self.elevator.enter() def exitElevator(self): self.ignore(self.elevatorDoneEvent) self.elevator.unload() self.elevator.exit() del self.elevator def detectedElevatorCollision(self, distElevator): self.fsm.request('elevator', [distElevator]) def handleElevatorDone(self, doneStatus): self.notify.debug('handling elevator done event') where = doneStatus['where'] if where == 'reject': if hasattr( base.localAvatar, 'elevatorNotifier' ) and base.localAvatar.elevatorNotifier.isNotifierOpen(): pass else: self.fsm.request('walk') else: if where == 'exit': self.fsm.request('walk') else: if where == 'cogHQBossBattle': self.doneStatus = doneStatus messenger.send(self.doneEvent) else: self.notify.error('Unknown mode: ' + where + ' in handleElevatorDone') def enterTeleportIn(self, requestStatus): base.localAvatar.setPosHpr(render, 0, 0, 0, 0, 0, 0) BattlePlace.BattlePlace.enterTeleportIn(self, requestStatus) def enterTeleportOut(self, requestStatus, callback=None): if requestStatus.has_key('battle'): self.__teleportOutDone(requestStatus) else: BattlePlace.BattlePlace.enterTeleportOut(self, requestStatus, self.__teleportOutDone) def __teleportOutDone(self, requestStatus): hoodId = requestStatus['hoodId'] zoneId = requestStatus['zoneId'] avId = requestStatus['avId'] shardId = requestStatus['shardId'] if hoodId == self.loader.hood.hoodId and zoneId == self.loader.hood.hoodId and shardId == None: self.fsm.request('teleportIn', [requestStatus]) else: if hoodId == ToontownGlobals.MyEstate: self.getEstateZoneAndGoHome(requestStatus) else: self.doneStatus = requestStatus messenger.send(self.doneEvent) return def exitTeleportOut(self): BattlePlace.BattlePlace.exitTeleportOut(self) def enterTunnelOut(self, requestStatus): fromZoneId = self.zoneId - self.zoneId % 100 tunnelName = base.cr.hoodMgr.makeLinkTunnelName( self.loader.hood.id, fromZoneId) requestStatus['tunnelName'] = tunnelName BattlePlace.BattlePlace.enterTunnelOut(self, requestStatus)
class Street(BattlePlace.BattlePlace): notify = DirectNotifyGlobal.directNotify.newCategory('Street') def __init__(self, loader, parentFSM, doneEvent): BattlePlace.BattlePlace.__init__(self, loader, doneEvent) self.fsm = ClassicFSM.ClassicFSM('Street', [ State.State( 'start', self.enterStart, self.exitStart, ['walk', 'tunnelIn', 'doorIn', 'teleportIn', 'elevatorIn']), State.State('walk', self.enterWalk, self.exitWalk, [ 'push', 'sit', 'stickerBook', 'WaitForBattle', 'battle', 'DFA', 'trialerFA', 'doorOut', 'elevator', 'tunnelIn', 'tunnelOut', 'teleportOut', 'quest', 'stopped', 'fishing', 'purchase', 'died' ]), State.State('sit', self.enterSit, self.exitSit, ['walk']), State.State('push', self.enterPush, self.exitPush, ['walk']), State.State( 'stickerBook', self.enterStickerBook, self.exitStickerBook, [ 'walk', 'push', 'sit', 'battle', 'DFA', 'trialerFA', 'doorOut', 'elevator', 'tunnelIn', 'tunnelOut', 'WaitForBattle', 'teleportOut', 'quest', 'stopped', 'fishing', 'purchase' ]), State.State('WaitForBattle', self.enterWaitForBattle, self.exitWaitForBattle, ['battle', 'walk']), State.State('battle', self.enterBattle, self.exitBattle, ['walk', 'teleportOut', 'died']), State.State('doorIn', self.enterDoorIn, self.exitDoorIn, ['walk', 'stopped']), State.State('doorOut', self.enterDoorOut, self.exitDoorOut, ['walk', 'stopped']), State.State('elevatorIn', self.enterElevatorIn, self.exitElevatorIn, ['walk']), State.State('elevator', self.enterElevator, self.exitElevator, ['walk']), State.State('trialerFA', self.enterTrialerFA, self.exitTrialerFA, ['trialerFAReject', 'DFA']), State.State('trialerFAReject', self.enterTrialerFAReject, self.exitTrialerFAReject, ['walk']), State.State('DFA', self.enterDFA, self.exitDFA, ['DFAReject', 'teleportOut', 'tunnelOut']), State.State('DFAReject', self.enterDFAReject, self.exitDFAReject, ['walk']), State.State( 'teleportIn', self.enterTeleportIn, self.exitTeleportIn, [ 'walk', 'teleportOut', 'quietZone', 'WaitForBattle', 'battle' ]), State.State('teleportOut', self.enterTeleportOut, self.exitTeleportOut, ['teleportIn', 'quietZone', 'WaitForBattle']), State.State('died', self.enterDied, self.exitDied, ['quietZone']), State.State('tunnelIn', self.enterTunnelIn, self.exitTunnelIn, ['walk']), State.State('tunnelOut', self.enterTunnelOut, self.exitTunnelOut, ['final']), State.State('quietZone', self.enterQuietZone, self.exitQuietZone, ['teleportIn']), State.State('quest', self.enterQuest, self.exitQuest, ['walk', 'stopped']), State.State('stopped', self.enterStopped, self.exitStopped, ['walk']), State.State('stopped', self.enterStopped, self.exitStopped, ['walk']), State.State('fishing', self.enterFishing, self.exitFishing, ['walk']), State.State('purchase', self.enterPurchase, self.exitPurchase, ['walk']), State.State('final', self.enterFinal, self.exitFinal, ['start']) ], 'start', 'final') self.parentFSM = parentFSM self.tunnelOriginList = [] self.elevatorDoneEvent = 'elevatorDone' self.eventLights = [] self.zone = 0 def enter(self, requestStatus, visibilityFlag=1, arrowsOn=1): teleportDebug(requestStatus, 'Street.enter(%s)' % (requestStatus, )) self._ttfToken = None self.fsm.enterInitialState() base.playMusic(self.loader.music, looping=1, volume=0.8) self.loader.geom.reparentTo(render) if visibilityFlag: self.visibilityOn() base.localAvatar.setGeom(self.loader.geom) base.localAvatar.setOnLevelGround(1) self._telemLimiter = TLGatherAllAvs('Street', RotationLimitToH) NametagGlobals.setMasterArrowsOn(arrowsOn) self.zone = ZoneUtil.getBranchZone(requestStatus['zoneId']) def __lightDecorationOn__(): try: geom = base.cr.playGame.getPlace().loader.geom except: loaderId = ZoneUtil.getBranchLoaderName( 2000) # TEMP hack. This will port you to ttc if ^ fails whereId = ZoneUtil.getToonWhereName(200) how = 'teleportIn' print("This Should not happen.") requestStatus = [{ 'loader': loaderId, 'where': whereId, 'how': how, 'hoodId': 2000, 'zoneId': 2000, 'shardId': None, 'avId': -1 }] base.cr.playGame.getPlace().fsm.forceTransition( 'teleportOut', requestStatus) self.loader.hood.eventLights = geom.findAllMatches('**/*light*') self.loader.hood.eventLights += geom.findAllMatches('**/*lamp*') self.loader.hood.eventLights += geom.findAllMatches( '**/prop_snow_tree*') self.loader.hood.eventLights += geom.findAllMatches( '**/prop_tree*') self.loader.hood.eventLights += geom.findAllMatches( '**/*christmas*') for light in self.loader.hood.eventLights: light.setColorScaleOff(1) newsManager = base.cr.newsManager if newsManager: holidayIds = base.cr.newsManager.getDecorationHolidayId() #Halloween Event if (ToontownGlobals.HALLOWEEN_COSTUMES in holidayIds or ToontownGlobals.SPOOKY_COSTUMES in holidayIds) and self.loader.hood.spookySkyFile: lightsOff = Sequence( LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.1, Vec4(0.55, 0.55, 0.65, 1)), Func(self.loader.hood.startSpookySky)) lightsOff.start() else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval( base.cr.playGame.hood.loader.geom, 0.1, Vec4(1, 1, 1, 1)) lightsOn.start() #Christmas Event if (ToontownGlobals.WINTER_DECORATIONS in holidayIds or ToontownGlobals.WACKY_WINTER_DECORATIONS in holidayIds) and self.loader.hood.snowySkyFile: lightsOff = Sequence( LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.1, Vec4(0.7, 0.7, 0.8, 1)), Func(self.loader.hood.startSnowySky), Func(__lightDecorationOn__)) lightsOff.start() self.snowEvent = BattleParticles.loadParticleFile( 'snowdisk.ptf') self.snowEvent.setPos(0, 30, 10) #2 and 3 are only for the blizzard event and should be removed self.snowEvent2 = BattleParticles.loadParticleFile( 'snowdisk.ptf') self.snowEvent2.setPos(0, 10, 10) self.snowEvent3 = BattleParticles.loadParticleFile( 'snowdisk.ptf') self.snowEvent3.setPos(0, 20, 5) self.snowEventRender = base.cr.playGame.hood.loader.geom.attachNewNode( 'snowRender') self.snowEventRender.setDepthWrite(2) self.snowEventRender.setBin('fixed', 1) self.snowEventFade = None self.snowEvent.start(camera, self.snowEventRender) #2 and 3 are only for the blizzard event and should be removed self.snowEvent2.start(camera, self.snowEventRender) self.snowEvent3.start(camera, self.snowEventRender) else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval( base.cr.playGame.hood.loader.geom, 0.1, Vec4(1, 1, 1, 1)) lightsOn.start() else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval( base.cr.playGame.hood.loader.geom, 0.1, Vec4(1, 1, 1, 1)) lightsOn.start() self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) self.enterZone(requestStatus['zoneId']) self.tunnelOriginList = base.cr.hoodMgr.addLinkTunnelHooks( self, self.loader.nodeList, self.zoneId) self.fsm.request(requestStatus['how'], [requestStatus]) def exit(self, visibilityFlag=1): if visibilityFlag: self.visibilityOff() self.loader.geom.reparentTo(hidden) self._telemLimiter.destroy() del self._telemLimiter def __lightDecorationOff__(): for light in self.eventLights: light.reparentTo(hidden) newsManager = base.cr.newsManager NametagGlobals.setMasterArrowsOn(0) self.loader.hood.stopSky() self.loader.music.stop() base.localAvatar.setGeom(render) base.localAvatar.setOnLevelGround(0) def load(self): BattlePlace.BattlePlace.load(self) self.parentFSM.getStateNamed('street').addChild(self.fsm) def unload(self): self.parentFSM.getStateNamed('street').removeChild(self.fsm) del self.parentFSM del self.fsm self.enterZone(None) cleanupDialog('globalDialog') self.ignoreAll() BattlePlace.BattlePlace.unload(self) return def enterElevatorIn(self, requestStatus): self._eiwbTask = taskMgr.add( Functor(self._elevInWaitBldgTask, requestStatus['bldgDoId']), uniqueName('elevInWaitBldg')) def _elevInWaitBldgTask(self, bldgDoId, task): bldg = base.cr.doId2do.get(bldgDoId) if bldg: if bldg.elevatorNodePath is not None: if self._enterElevatorGotElevator(): return Task.done return Task.cont def _enterElevatorGotElevator(self): if not messenger.whoAccepts('insideVictorElevator'): return False messenger.send('insideVictorElevator') return True def exitElevatorIn(self): taskMgr.remove(self._eiwbTask) def enterElevator(self, distElevator): base.localAvatar.cantLeaveGame = 1 self.accept(self.elevatorDoneEvent, self.handleElevatorDone) self.elevator = Elevator.Elevator(self.fsm.getStateNamed('elevator'), self.elevatorDoneEvent, distElevator) self.elevator.load() self.elevator.enter() def exitElevator(self): base.localAvatar.cantLeaveGame = 0 self.ignore(self.elevatorDoneEvent) self.elevator.unload() self.elevator.exit() del self.elevator def detectedElevatorCollision(self, distElevator): self.fsm.request('elevator', [distElevator]) return None def handleElevatorDone(self, doneStatus): self.notify.debug('handling elevator done event') where = doneStatus['where'] if where == 'reject': if hasattr( base.localAvatar, 'elevatorNotifier' ) and base.localAvatar.elevatorNotifier.isNotifierOpen(): pass else: self.fsm.request('walk') elif where == 'exit': self.fsm.request('walk') elif where in ('suitInterior', 'cogdoInterior'): self.doneStatus = doneStatus messenger.send(self.doneEvent) else: self.notify.error('Unknown mode: ' + where + ' in handleElevatorDone') def enterTunnelIn(self, requestStatus): self.enterZone(requestStatus['zoneId']) BattlePlace.BattlePlace.enterTunnelIn(self, requestStatus) def enterTeleportIn(self, requestStatus): teleportDebug(requestStatus, 'Street.enterTeleportIn(%s)' % (requestStatus, )) zoneId = requestStatus['zoneId'] self._ttfToken = self.addSetZoneCompleteCallback( Functor(self._teleportToFriend, requestStatus)) self.enterZone(zoneId) BattlePlace.BattlePlace.enterTeleportIn(self, requestStatus) def _teleportToFriend(self, requestStatus): avId = requestStatus['avId'] hoodId = requestStatus['hoodId'] zoneId = requestStatus['zoneId'] if avId != -1: if avId not in base.cr.doId2do: friend = base.cr.identifyAvatar(avId) if friend == None: teleportDebug(requestStatus, "couldn't find friend %s" % avId) handle = base.cr.identifyFriend(avId) requestStatus = { 'how': 'teleportIn', 'hoodId': hoodId, 'zoneId': hoodId, 'shardId': None, 'loader': 'safeZoneLoader', 'where': 'playground', 'avId': avId } self.fsm.request('final') self.__teleportOutDone(requestStatus) return def exitTeleportIn(self): self.removeSetZoneCompleteCallback(self._ttfToken) self._ttfToken = None BattlePlace.BattlePlace.exitTeleportIn(self) return def enterTeleportOut(self, requestStatus): if 'battle' in requestStatus: self.__teleportOutDone(requestStatus) else: BattlePlace.BattlePlace.enterTeleportOut(self, requestStatus, self.__teleportOutDone) def __teleportOutDone(self, requestStatus): hoodId = requestStatus['hoodId'] zoneId = requestStatus['zoneId'] shardId = requestStatus['shardId'] if hoodId == self.loader.hood.id and shardId == None: if zoneId == self.zoneId: self.fsm.request('teleportIn', [requestStatus]) elif requestStatus['where'] == 'street' and ZoneUtil.getBranchZone( zoneId) == self.loader.branchZone: self.fsm.request('quietZone', [requestStatus]) else: self.doneStatus = requestStatus messenger.send(self.doneEvent) elif hoodId == ToontownGlobals.MyEstate: self.getEstateZoneAndGoHome(requestStatus) else: self.doneStatus = requestStatus messenger.send(self.doneEvent) return def exitTeleportOut(self): BattlePlace.BattlePlace.exitTeleportOut(self) def goHomeFailed(self, task): self.notifyUserGoHomeFailed() self.ignore('setLocalEstateZone') self.doneStatus['avId'] = -1 self.doneStatus['zoneId'] = self.getZoneId() self.fsm.request('teleportIn', [self.doneStatus]) return Task.done def renameFloorPolys(self, nodeList): for i in nodeList: collNodePaths = i.findAllMatches('**/+CollisionNode') numCollNodePaths = collNodePaths.getNumPaths() visGroupName = i.node().getName() for j in xrange(numCollNodePaths): collNodePath = collNodePaths.getPath(j) bitMask = collNodePath.node().getIntoCollideMask() if bitMask.getBit(1): collNodePath.node().setName(visGroupName) def hideAllVisibles(self): for i in self.loader.nodeList: i.stash() def showAllVisibles(self): for i in self.loader.nodeList: i.unstash() def visibilityOn(self): self.hideAllVisibles() self.accept('on-floor', self.enterZone) def visibilityOff(self): self.ignore('on-floor') self.showAllVisibles() def doEnterZone(self, newZoneId): if self.zoneId != None: for i in self.loader.nodeDict[self.zoneId]: if newZoneId: if i not in self.loader.nodeDict[newZoneId]: self.loader.fadeOutDict[i].start() self.loader.exitAnimatedProps(i) else: i.stash() self.loader.exitAnimatedProps(i) if newZoneId != None: for i in self.loader.nodeDict[newZoneId]: if self.zoneId: if i not in self.loader.nodeDict[self.zoneId]: self.loader.fadeInDict[i].start() self.loader.enterAnimatedProps(i) i.unstash() else: if self.loader.fadeOutDict[i].isPlaying(): self.loader.fadeOutDict[i].finish() if self.loader.fadeInDict[i].isPlaying(): self.loader.fadeInDict[i].finish() self.loader.enterAnimatedProps(i) i.unstash() if newZoneId != self.zoneId: if visualizeZones: if self.zoneId != None: self.loader.zoneDict[self.zoneId].clearColor() if newZoneId != None: self.loader.zoneDict[newZoneId].setColor(0, 0, 1, 1, 100) if newZoneId is not None: loader = base.cr.playGame.getPlace().loader if newZoneId != None: visZones = [ self.loader.nodeToZone[x] for x in self.loader.nodeDict[newZoneId] ] visZones.append(ZoneUtil.getBranchZone(newZoneId)) base.cr.sendSetZoneMsg(newZoneId, visZones) self.notify.debug('Entering Zone %d' % newZoneId) self.zoneId = newZoneId geom = base.cr.playGame.getPlace().loader.geom self.eventLights = geom.findAllMatches('**/*light*') self.eventLights += geom.findAllMatches('**/*lamp*') self.eventLights += geom.findAllMatches('**/prop_snow_tree*') self.eventLights += geom.findAllMatches('**/prop_tree*') self.eventLights += geom.findAllMatches('**/*christmas*') for light in self.eventLights: light.setColorScaleOff(1)
def enter(self, requestStatus, visibilityFlag=1, arrowsOn=1): teleportDebug(requestStatus, 'Street.enter(%s)' % (requestStatus, )) self._ttfToken = None self.fsm.enterInitialState() base.playMusic(self.loader.music, looping=1, volume=0.8) self.loader.geom.reparentTo(render) if visibilityFlag: self.visibilityOn() base.localAvatar.setGeom(self.loader.geom) base.localAvatar.setOnLevelGround(1) self._telemLimiter = TLGatherAllAvs('Street', RotationLimitToH) NametagGlobals.setMasterArrowsOn(arrowsOn) self.zone = ZoneUtil.getBranchZone(requestStatus['zoneId']) def __lightDecorationOn__(): try: geom = base.cr.playGame.getPlace().loader.geom except: loaderId = ZoneUtil.getBranchLoaderName( 2000) # TEMP hack. This will port you to ttc if ^ fails whereId = ZoneUtil.getToonWhereName(200) how = 'teleportIn' print("This Should not happen.") requestStatus = [{ 'loader': loaderId, 'where': whereId, 'how': how, 'hoodId': 2000, 'zoneId': 2000, 'shardId': None, 'avId': -1 }] base.cr.playGame.getPlace().fsm.forceTransition( 'teleportOut', requestStatus) self.loader.hood.eventLights = geom.findAllMatches('**/*light*') self.loader.hood.eventLights += geom.findAllMatches('**/*lamp*') self.loader.hood.eventLights += geom.findAllMatches( '**/prop_snow_tree*') self.loader.hood.eventLights += geom.findAllMatches( '**/prop_tree*') self.loader.hood.eventLights += geom.findAllMatches( '**/*christmas*') for light in self.loader.hood.eventLights: light.setColorScaleOff(1) newsManager = base.cr.newsManager if newsManager: holidayIds = base.cr.newsManager.getDecorationHolidayId() #Halloween Event if (ToontownGlobals.HALLOWEEN_COSTUMES in holidayIds or ToontownGlobals.SPOOKY_COSTUMES in holidayIds) and self.loader.hood.spookySkyFile: lightsOff = Sequence( LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.1, Vec4(0.55, 0.55, 0.65, 1)), Func(self.loader.hood.startSpookySky)) lightsOff.start() else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval( base.cr.playGame.hood.loader.geom, 0.1, Vec4(1, 1, 1, 1)) lightsOn.start() #Christmas Event if (ToontownGlobals.WINTER_DECORATIONS in holidayIds or ToontownGlobals.WACKY_WINTER_DECORATIONS in holidayIds) and self.loader.hood.snowySkyFile: lightsOff = Sequence( LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.1, Vec4(0.7, 0.7, 0.8, 1)), Func(self.loader.hood.startSnowySky), Func(__lightDecorationOn__)) lightsOff.start() self.snowEvent = BattleParticles.loadParticleFile( 'snowdisk.ptf') self.snowEvent.setPos(0, 30, 10) #2 and 3 are only for the blizzard event and should be removed self.snowEvent2 = BattleParticles.loadParticleFile( 'snowdisk.ptf') self.snowEvent2.setPos(0, 10, 10) self.snowEvent3 = BattleParticles.loadParticleFile( 'snowdisk.ptf') self.snowEvent3.setPos(0, 20, 5) self.snowEventRender = base.cr.playGame.hood.loader.geom.attachNewNode( 'snowRender') self.snowEventRender.setDepthWrite(2) self.snowEventRender.setBin('fixed', 1) self.snowEventFade = None self.snowEvent.start(camera, self.snowEventRender) #2 and 3 are only for the blizzard event and should be removed self.snowEvent2.start(camera, self.snowEventRender) self.snowEvent3.start(camera, self.snowEventRender) else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval( base.cr.playGame.hood.loader.geom, 0.1, Vec4(1, 1, 1, 1)) lightsOn.start() else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval( base.cr.playGame.hood.loader.geom, 0.1, Vec4(1, 1, 1, 1)) lightsOn.start() self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) self.enterZone(requestStatus['zoneId']) self.tunnelOriginList = base.cr.hoodMgr.addLinkTunnelHooks( self, self.loader.nodeList, self.zoneId) self.fsm.request(requestStatus['how'], [requestStatus])
def getTelemetryLimiter(self): return TLGatherAllAvs('Minigame', RotationLimitToH)
def getTelemetryLimiter(self): return TLGatherAllAvs('DivingGame', Functor(DivingGameRotationLimiter, 180, 180))
class Street(BattlePlace.BattlePlace): notify = DirectNotifyGlobal.directNotify.newCategory("Street") def __init__(self, loader, parentFSM, doneEvent): BattlePlace.BattlePlace.__init__(self, loader, doneEvent) self.fsm = ClassicFSM.ClassicFSM( "Street", [ State.State( "start", self.enterStart, self.exitStart, ["walk", "tunnelIn", "doorIn", "teleportIn", "elevatorIn"] ), State.State( "walk", self.enterWalk, self.exitWalk, [ "push", "sit", "stickerBook", "WaitForBattle", "battle", "DFA", "trialerFA", "doorOut", "elevator", "tunnelIn", "tunnelOut", "teleportOut", "quest", "stopped", "fishing", "purchase", "died", ], ), State.State("sit", self.enterSit, self.exitSit, ["walk"]), State.State("push", self.enterPush, self.exitPush, ["walk"]), State.State( "stickerBook", self.enterStickerBook, self.exitStickerBook, [ "walk", "push", "sit", "battle", "DFA", "trialerFA", "doorOut", "elevator", "tunnelIn", "tunnelOut", "WaitForBattle", "teleportOut", "quest", "stopped", "fishing", "purchase", ], ), State.State("WaitForBattle", self.enterWaitForBattle, self.exitWaitForBattle, ["battle", "walk"]), State.State("battle", self.enterBattle, self.exitBattle, ["walk", "teleportOut", "died"]), State.State("doorIn", self.enterDoorIn, self.exitDoorIn, ["walk"]), State.State("doorOut", self.enterDoorOut, self.exitDoorOut, ["walk"]), State.State("elevatorIn", self.enterElevatorIn, self.exitElevatorIn, ["walk"]), State.State("elevator", self.enterElevator, self.exitElevator, ["walk"]), State.State("trialerFA", self.enterTrialerFA, self.exitTrialerFA, ["trialerFAReject", "DFA"]), State.State("trialerFAReject", self.enterTrialerFAReject, self.exitTrialerFAReject, ["walk"]), State.State("DFA", self.enterDFA, self.exitDFA, ["DFAReject", "teleportOut", "tunnelOut"]), State.State("DFAReject", self.enterDFAReject, self.exitDFAReject, ["walk"]), State.State( "teleportIn", self.enterTeleportIn, self.exitTeleportIn, ["walk", "teleportOut", "quietZone", "WaitForBattle", "battle"], ), State.State( "teleportOut", self.enterTeleportOut, self.exitTeleportOut, ["teleportIn", "quietZone", "WaitForBattle"], ), State.State("died", self.enterDied, self.exitDied, ["quietZone"]), State.State("tunnelIn", self.enterTunnelIn, self.exitTunnelIn, ["walk"]), State.State("tunnelOut", self.enterTunnelOut, self.exitTunnelOut, ["final"]), State.State("quietZone", self.enterQuietZone, self.exitQuietZone, ["teleportIn"]), State.State("quest", self.enterQuest, self.exitQuest, ["walk", "stopped"]), State.State("stopped", self.enterStopped, self.exitStopped, ["walk"]), State.State("stopped", self.enterStopped, self.exitStopped, ["walk"]), State.State("fishing", self.enterFishing, self.exitFishing, ["walk"]), State.State("purchase", self.enterPurchase, self.exitPurchase, ["walk"]), State.State("final", self.enterFinal, self.exitFinal, ["start"]), ], "start", "final", ) self.parentFSM = parentFSM self.tunnelOriginList = [] self.elevatorDoneEvent = "elevatorDone" self.halloweenLights = [] def enter(self, requestStatus, visibilityFlag=1, arrowsOn=1): teleportDebug(requestStatus, "Street.enter(%s)" % (requestStatus,)) self._ttfToken = None self.fsm.enterInitialState() base.playMusic(self.loader.music, looping=1, volume=0.80000000000000004) self.loader.geom.reparentTo(render) if visibilityFlag: self.visibilityOn() base.localAvatar.setGeom(self.loader.geom) base.localAvatar.setOnLevelGround(1) self._telemLimiter = TLGatherAllAvs("Street", RotationLimitToH) NametagGlobals.setMasterArrowsOn(arrowsOn) def __lightDecorationOn__(): geom = base.cr.playGame.getPlace().loader.geom self.halloweenLights = geom.findAllMatches("**/*light*") self.halloweenLights += geom.findAllMatches("**/*lamp*") self.halloweenLights += geom.findAllMatches("**/prop_snow_tree*") for light in self.halloweenLights: light.setColorScaleOff(1) newsManager = base.cr.newsManager if newsManager: holidayIds = base.cr.newsManager.getDecorationHolidayId() if ( ToontownGlobals.HALLOWEEN_COSTUMES in holidayIds or ToontownGlobals.SPOOKY_COSTUMES in holidayIds ) and self.loader.hood.spookySkyFile: lightsOff = Sequence( LerpColorScaleInterval( base.cr.playGame.hood.loader.geom, 0.10000000000000001, Vec4(0.55000000000000004, 0.55000000000000004, 0.65000000000000002, 1), ), Func(self.loader.hood.startSpookySky), ) lightsOff.start() else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval( base.cr.playGame.hood.loader.geom, 0.10000000000000001, Vec4(1, 1, 1, 1) ) lightsOn.start() else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.10000000000000001, Vec4(1, 1, 1, 1)) lightsOn.start() self.accept("doorDoneEvent", self.handleDoorDoneEvent) self.accept("DistributedDoor_doorTrigger", self.handleDoorTrigger) self.enterZone(requestStatus["zoneId"]) self.tunnelOriginList = base.cr.hoodMgr.addLinkTunnelHooks(self, self.loader.nodeList, self.zoneId) self.fsm.request(requestStatus["how"], [requestStatus]) self.replaceStreetSignTextures() def exit(self, visibilityFlag=1): if visibilityFlag: self.visibilityOff() self.loader.geom.reparentTo(hidden) self._telemLimiter.destroy() del self._telemLimiter def __lightDecorationOff__(): for light in self.halloweenLights: light.reparentTo(hidden) newsManager = base.cr.newsManager NametagGlobals.setMasterArrowsOn(0) self.loader.hood.stopSky() self.loader.music.stop() base.localAvatar.setGeom(render) base.localAvatar.setOnLevelGround(0) def load(self): BattlePlace.BattlePlace.load(self) self.parentFSM.getStateNamed("street").addChild(self.fsm) def unload(self): self.parentFSM.getStateNamed("street").removeChild(self.fsm) del self.parentFSM del self.fsm self.enterZone(None) cleanupDialog("globalDialog") self.ignoreAll() BattlePlace.BattlePlace.unload(self) def enterElevatorIn(self, requestStatus): self._eiwbTask = taskMgr.add( Functor(self._elevInWaitBldgTask, requestStatus["bldgDoId"]), uniqueName("elevInWaitBldg") ) def _elevInWaitBldgTask(self, bldgDoId, task): bldg = base.cr.doId2do.get(bldgDoId) if bldg: if bldg.elevatorNodePath is not None: self._enterElevatorGotElevator() return Task.done return Task.cont def _enterElevatorGotElevator(self): messenger.send("insideVictorElevator") def exitElevatorIn(self): taskMgr.remove(self._eiwbTask) def enterElevator(self, distElevator): base.localAvatar.cantLeaveGame = 1 self.accept(self.elevatorDoneEvent, self.handleElevatorDone) self.elevator = Elevator.Elevator(self.fsm.getStateNamed("elevator"), self.elevatorDoneEvent, distElevator) self.elevator.load() self.elevator.enter() def exitElevator(self): base.localAvatar.cantLeaveGame = 0 self.ignore(self.elevatorDoneEvent) self.elevator.unload() self.elevator.exit() del self.elevator def detectedElevatorCollision(self, distElevator): self.fsm.request("elevator", [distElevator]) def handleElevatorDone(self, doneStatus): self.notify.debug("handling elevator done event") where = doneStatus["where"] if where == "reject": if hasattr(base.localAvatar, "elevatorNotifier") and base.localAvatar.elevatorNotifier.isNotifierOpen(): pass else: self.fsm.request("walk") elif where == "exit": self.fsm.request("walk") elif where in ("suitInterior", "cogdoInterior"): self.doneStatus = doneStatus messenger.send(self.doneEvent) else: self.notify.error("Unknown mode: " + where + " in handleElevatorDone") def enterTunnelIn(self, requestStatus): self.enterZone(requestStatus["zoneId"]) BattlePlace.BattlePlace.enterTunnelIn(self, requestStatus) def enterTeleportIn(self, requestStatus): teleportDebug(requestStatus, "Street.enterTeleportIn(%s)" % (requestStatus,)) zoneId = requestStatus["zoneId"] self._ttfToken = self.addSetZoneCompleteCallback(Functor(self._teleportToFriend, requestStatus)) self.enterZone(zoneId) BattlePlace.BattlePlace.enterTeleportIn(self, requestStatus) def _teleportToFriend(self, requestStatus): avId = requestStatus["avId"] hoodId = requestStatus["hoodId"] zoneId = requestStatus["zoneId"] if avId != -1: if not base.cr.doId2do.has_key(avId): teleportDebug(requestStatus, "couldn't find friend %s" % avId) handle = base.cr.identifyFriend(avId) requestStatus = { "how": "teleportIn", "hoodId": hoodId, "zoneId": hoodId, "shardId": None, "loader": "safeZoneLoader", "where": "playground", "avId": avId, } self.fsm.request("final") self._Street__teleportOutDone(requestStatus) def exitTeleportIn(self): self.removeSetZoneCompleteCallback(self._ttfToken) self._ttfToken = None BattlePlace.BattlePlace.exitTeleportIn(self) def enterTeleportOut(self, requestStatus): if requestStatus.has_key("battle"): self._Street__teleportOutDone(requestStatus) else: BattlePlace.BattlePlace.enterTeleportOut(self, requestStatus, self._Street__teleportOutDone) def _Street__teleportOutDone(self, requestStatus): hoodId = requestStatus["hoodId"] zoneId = requestStatus["zoneId"] shardId = requestStatus["shardId"] if hoodId == self.loader.hood.id and shardId == None: if zoneId == self.zoneId: self.fsm.request("teleportIn", [requestStatus]) elif requestStatus["where"] == "street" and ZoneUtil.getBranchZone(zoneId) == self.loader.branchZone: self.fsm.request("quietZone", [requestStatus]) else: self.doneStatus = requestStatus messenger.send(self.doneEvent) elif hoodId == ToontownGlobals.MyEstate: self.getEstateZoneAndGoHome(requestStatus) else: self.doneStatus = requestStatus messenger.send(self.doneEvent) def exitTeleportOut(self): BattlePlace.BattlePlace.exitTeleportOut(self) def goHomeFailed(self, task): self.notifyUserGoHomeFailed() self.ignore("setLocalEstateZone") self.doneStatus["avId"] = -1 self.doneStatus["zoneId"] = self.getZoneId() self.fsm.request("teleportIn", [self.doneStatus]) return Task.done def renameFloorPolys(self, nodeList): for i in nodeList: collNodePaths = i.findAllMatches("**/+CollisionNode") numCollNodePaths = collNodePaths.getNumPaths() visGroupName = i.node().getName() for j in range(numCollNodePaths): collNodePath = collNodePaths.getPath(j) bitMask = collNodePath.node().getIntoCollideMask() if bitMask.getBit(1): collNodePath.node().setName(visGroupName) continue def hideAllVisibles(self): for i in self.loader.nodeList: i.stash() def showAllVisibles(self): for i in self.loader.nodeList: i.unstash() def visibilityOn(self): self.hideAllVisibles() self.accept("on-floor", self.enterZone) def visibilityOff(self): self.ignore("on-floor") self.showAllVisibles() def doEnterZone(self, newZoneId): if self.zoneId != None: for i in self.loader.nodeDict[self.zoneId]: if newZoneId: if i not in self.loader.nodeDict[newZoneId]: self.loader.fadeOutDict[i].start() self.loader.exitAnimatedProps(i) i not in self.loader.nodeDict[newZoneId] i.stash() self.loader.exitAnimatedProps(i) if newZoneId != None: for i in self.loader.nodeDict[newZoneId]: if self.zoneId: if i not in self.loader.nodeDict[self.zoneId]: self.loader.fadeInDict[i].start() self.loader.enterAnimatedProps(i) i not in self.loader.nodeDict[self.zoneId] if self.loader.fadeOutDict[i].isPlaying(): self.loader.fadeOutDict[i].finish() if self.loader.fadeInDict[i].isPlaying(): self.loader.fadeInDict[i].finish() self.loader.enterAnimatedProps(i) i.unstash() if newZoneId != self.zoneId: if visualizeZones: if self.zoneId != None: self.loader.zoneDict[self.zoneId].clearColor() if newZoneId != None: self.loader.zoneDict[newZoneId].setColor(0, 0, 1, 1, 100) if newZoneId != None: base.cr.sendSetZoneMsg(newZoneId) self.notify.debug("Entering Zone %d" % newZoneId) self.zoneId = newZoneId geom = base.cr.playGame.getPlace().loader.geom self.halloweenLights = geom.findAllMatches("**/*light*") self.halloweenLights += geom.findAllMatches("**/*lamp*") self.halloweenLights += geom.findAllMatches("**/prop_snow_tree*") for light in self.halloweenLights: light.setColorScaleOff(1) def replaceStreetSignTextures(self): if not hasattr(base.cr, "playGame"): return None place = base.cr.playGame.getPlace() if place is None: return None geom = base.cr.playGame.getPlace().loader.geom signs = geom.findAllMatches("**/*tunnelAheadSign*;+s") if signs.getNumPaths() > 0: streetSign = base.cr.streetSign signTexturePath = streetSign.StreetSignBaseDir + "/" + streetSign.StreetSignFileName loaderTexturePath = Filename(str(signTexturePath)) alphaPath = "phase_4/maps/tt_t_ara_gen_tunnelAheadSign_a.rgb" inDreamland = False if place.zoneId and ZoneUtil.getCanonicalHoodId(place.zoneId) == ToontownGlobals.DonaldsDreamland: inDreamland = True alphaPath = "phase_4/maps/tt_t_ara_gen_tunnelAheadSign_a.rgb" if Filename(signTexturePath).exists(): signTexture = loader.loadTexture(loaderTexturePath, alphaPath) for sign in signs: if Filename(signTexturePath).exists(): sign.setTexture(signTexture, 1) if inDreamland: sign.setColorScale(0.52500000000000002, 0.52500000000000002, 0.52500000000000002, 1) continue
class ToonInterior(Place.Place): notify = DirectNotifyGlobal.directNotify.newCategory('ToonInterior') def __init__(self, loader, parentFSMState, doneEvent): Place.Place.__init__(self, loader, doneEvent) self.dnaFile = 'phase_7/models/modules/toon_interior' self.isInterior = 1 self.tfaDoneEvent = 'tfaDoneEvent' self.hfaDoneEvent = 'hfaDoneEvent' self.npcfaDoneEvent = 'npcfaDoneEvent' self.fsm = ClassicFSM.ClassicFSM('ToonInterior', [ State.State('start', self.enterStart, self.exitStart, ['doorIn', 'teleportIn', 'tutorial']), State.State('walk', self.enterWalk, self.exitWalk, [ 'sit', 'stickerBook', 'doorOut', 'DFA', 'trialerFA', 'teleportOut', 'quest', 'purchase', 'phone', 'stopped', 'pet' ]), State.State('sit', self.enterSit, self.exitSit, ['walk']), State.State( 'stickerBook', self.enterStickerBook, self.exitStickerBook, [ 'walk', 'DFA', 'trialerFA', 'sit', 'doorOut', 'teleportOut', 'quest', 'purchase', 'phone', 'stopped', 'pet' ]), State.State('trialerFA', self.enterTrialerFA, self.exitTrialerFA, ['trialerFAReject', 'DFA']), State.State('trialerFAReject', self.enterTrialerFAReject, self.exitTrialerFAReject, ['walk']), State.State( 'DFA', self.enterDFA, self.exitDFA, ['DFAReject', 'HFA', 'NPCFA', 'teleportOut', 'doorOut']), State.State('DFAReject', self.enterDFAReject, self.exitDFAReject, ['walk']), State.State('NPCFA', self.enterNPCFA, self.exitNPCFA, ['NPCFAReject', 'HFA', 'teleportOut']), State.State('NPCFAReject', self.enterNPCFAReject, self.exitNPCFAReject, ['walk']), State.State('HFA', self.enterHFA, self.exitHFA, ['HFAReject', 'teleportOut', 'tunnelOut']), State.State('HFAReject', self.enterHFAReject, self.exitHFAReject, ['walk']), State.State('doorIn', self.enterDoorIn, self.exitDoorIn, ['walk']), State.State('doorOut', self.enterDoorOut, self.exitDoorOut, ['walk']), State.State('teleportIn', self.enterTeleportIn, self.exitTeleportIn, ['walk']), State.State('teleportOut', self.enterTeleportOut, self.exitTeleportOut, ['teleportIn']), State.State('quest', self.enterQuest, self.exitQuest, ['walk', 'doorOut']), State.State('tutorial', self.enterTutorial, self.exitTutorial, ['walk', 'quest']), State.State('purchase', self.enterPurchase, self.exitPurchase, ['walk', 'doorOut']), State.State('pet', self.enterPet, self.exitPet, ['walk']), State.State('phone', self.enterPhone, self.exitPhone, ['walk', 'doorOut']), State.State('stopped', self.enterStopped, self.exitStopped, ['walk', 'doorOut']), State.State('final', self.enterFinal, self.exitFinal, ['start']) ], 'start', 'final') self.parentFSMState = parentFSMState def load(self): Place.Place.load(self) self.parentFSMState.addChild(self.fsm) def unload(self): Place.Place.unload(self) self.parentFSMState.removeChild(self.fsm) del self.parentFSMState del self.fsm ModelPool.garbageCollect() TexturePool.garbageCollect() def enter(self, requestStatus): self.zoneId = requestStatus['zoneId'] self.fsm.enterInitialState() messenger.send('enterToonInterior') self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) volume = requestStatus.get('musicVolume', 0.7) base.playMusic(self.loader.activityMusic, looping=1, volume=volume) self._telemLimiter = TLGatherAllAvs('ToonInterior', RotationLimitToH) NametagGlobals.setMasterArrowsOn(1) self.fsm.request(requestStatus['how'], [requestStatus]) def exit(self): self.ignoreAll() messenger.send('exitToonInterior') self._telemLimiter.destroy() del self._telemLimiter NametagGlobals.setMasterArrowsOn(0) self.loader.activityMusic.stop() def setState(self, state): self.fsm.request(state) def enterTutorial(self, requestStatus): self.fsm.request('walk') base.localAvatar.b_setParent(ToontownGlobals.SPRender) globalClock.tick() base.transitions.irisIn() messenger.send('enterTutorialInterior') def exitTutorial(self): pass def doRequestLeave(self, requestStatus): self.fsm.request('trialerFA', [requestStatus]) def enterDFACallback(self, requestStatus, doneStatus): self.dfa.exit() del self.dfa ds = doneStatus['mode'] if ds == 'complete': self.fsm.request('NPCFA', [requestStatus]) elif ds == 'incomplete': self.fsm.request('DFAReject') else: self.notify.error( 'Unknown done status for DownloadForceAcknowledge: ' + repr(doneStatus)) def enterNPCFA(self, requestStatus): self.acceptOnce(self.npcfaDoneEvent, self.enterNPCFACallback, [requestStatus]) self.npcfa = NPCForceAcknowledge.NPCForceAcknowledge( self.npcfaDoneEvent) self.npcfa.enter() def exitNPCFA(self): self.ignore(self.npcfaDoneEvent) def enterNPCFACallback(self, requestStatus, doneStatus): self.npcfa.exit() del self.npcfa if doneStatus['mode'] == 'complete': outHow = { 'teleportIn': 'teleportOut', 'tunnelIn': 'tunnelOut', 'doorIn': 'doorOut' } self.fsm.request(outHow[requestStatus['how']], [requestStatus]) elif doneStatus['mode'] == 'incomplete': self.fsm.request('NPCFAReject') else: self.notify.error('Unknown done status for NPCForceAcknowledge: ' + repr(doneStatus)) def enterNPCFAReject(self): self.fsm.request('walk') def exitNPCFAReject(self): pass def enterHFA(self, requestStatus): self.acceptOnce(self.hfaDoneEvent, self.enterHFACallback, [requestStatus]) self.hfa = HealthForceAcknowledge.HealthForceAcknowledge( self.hfaDoneEvent) self.hfa.enter(1) def exitHFA(self): self.ignore(self.hfaDoneEvent) def enterHFACallback(self, requestStatus, doneStatus): self.hfa.exit() del self.hfa if doneStatus['mode'] == 'complete': outHow = { 'teleportIn': 'teleportOut', 'tunnelIn': 'tunnelOut', 'doorIn': 'doorOut' } self.fsm.request(outHow[requestStatus['how']], [requestStatus]) elif doneStatus['mode'] == 'incomplete': self.fsm.request('HFAReject') else: self.notify.error( 'Unknown done status for HealthForceAcknowledge: ' + repr(doneStatus)) def enterHFAReject(self): self.fsm.request('walk') def exitHFAReject(self): pass def enterTeleportIn(self, requestStatus): if ZoneUtil.isPetshop(self.zoneId): base.localAvatar.setPosHpr(0, 0, ToontownGlobals.FloorOffset, 45.0, 0.0, 0.0) else: base.localAvatar.setPosHpr(2.5, 11.5, ToontownGlobals.FloorOffset, 45.0, 0.0, 0.0) Place.Place.enterTeleportIn(self, requestStatus) def enterTeleportOut(self, requestStatus): Place.Place.enterTeleportOut(self, requestStatus, self.__teleportOutDone) def __teleportOutDone(self, requestStatus): hoodId = requestStatus['hoodId'] zoneId = requestStatus['zoneId'] shardId = requestStatus['shardId'] if hoodId == self.loader.hood.id and zoneId == self.zoneId and shardId == None: self.fsm.request('teleportIn', [requestStatus]) elif hoodId == ToontownGlobals.MyEstate: self.getEstateZoneAndGoHome(requestStatus) else: self.doneStatus = requestStatus messenger.send(self.doneEvent) return def goHomeFailed(self, task): self.notifyUserGoHomeFailed() self.ignore('setLocalEstateZone') self.doneStatus['avId'] = -1 self.doneStatus['zoneId'] = self.getZoneId() self.fsm.request('teleportIn', [self.doneStatus]) return Task.done def exitTeleportOut(self): Place.Place.exitTeleportOut(self)
class Playground(Place.Place): notify = DirectNotifyGlobal.directNotify.newCategory('Playground') def __init__(self, loader, parentFSM, doneEvent): Place.Place.__init__(self, loader, doneEvent) self.tfaDoneEvent = 'tfaDoneEvent' self.fsm = ClassicFSM.ClassicFSM('Playground', [ State.State('start', self.enterStart, self.exitStart, ['walk', 'deathAck', 'doorIn', 'tunnelIn']), State.State('walk', self.enterWalk, self.exitWalk, [ 'drive', 'sit', 'stickerBook', 'TFA', 'DFA', 'trialerFA', 'trolley', 'final', 'doorOut', 'options', 'quest', 'purchase', 'stopped', 'fishing' ]), State.State( 'stickerBook', self.enterStickerBook, self.exitStickerBook, [ 'walk', 'DFA', 'TFA', 'trolley', 'final', 'doorOut', 'quest', 'purchase', 'stopped', 'fishing', 'trialerFA' ]), State.State('sit', self.enterSit, self.exitSit, ['walk', 'DFA', 'trialerFA']), State.State('drive', self.enterDrive, self.exitDrive, ['walk', 'DFA', 'trialerFA']), State.State('trolley', self.enterTrolley, self.exitTrolley, ['walk']), State.State('doorIn', self.enterDoorIn, self.exitDoorIn, ['walk']), State.State('doorOut', self.enterDoorOut, self.exitDoorOut, ['walk']), State.State('TFA', self.enterTFA, self.exitTFA, ['TFAReject', 'DFA']), State.State('TFAReject', self.enterTFAReject, self.exitTFAReject, ['walk']), State.State('trialerFA', self.enterTrialerFA, self.exitTrialerFA, ['trialerFAReject', 'DFA']), State.State('trialerFAReject', self.enterTrialerFAReject, self.exitTrialerFAReject, ['walk']), State.State('DFA', self.enterDFA, self.exitDFA, ['DFAReject', 'NPCFA', 'HFA']), State.State('DFAReject', self.enterDFAReject, self.exitDFAReject, ['walk']), State.State('NPCFA', self.enterNPCFA, self.exitNPCFA, ['NPCFAReject', 'HFA']), State.State('NPCFAReject', self.enterNPCFAReject, self.exitNPCFAReject, ['walk']), State.State('HFA', self.enterHFA, self.exitHFA, ['HFAReject', 'teleportOut', 'tunnelOut']), State.State('HFAReject', self.enterHFAReject, self.exitHFAReject, ['walk']), State.State('deathAck', self.enterDeathAck, self.exitDeathAck, ['teleportIn']), State.State('teleportIn', self.enterTeleportIn, self.exitTeleportIn, ['walk', 'popup']), State.State('popup', self.enterPopup, self.exitPopup, ['walk']), State.State('teleportOut', self.enterTeleportOut, self.exitTeleportOut, ['deathAck', 'teleportIn']), State.State('died', self.enterDied, self.exitDied, ['final']), State.State('tunnelIn', self.enterTunnelIn, self.exitTunnelIn, ['walk']), State.State('tunnelOut', self.enterTunnelOut, self.exitTunnelOut, ['final']), State.State('quest', self.enterQuest, self.exitQuest, ['walk']), State.State('purchase', self.enterPurchase, self.exitPurchase, ['walk']), State.State('stopped', self.enterStopped, self.exitStopped, ['walk']), State.State('fishing', self.enterFishing, self.exitFishing, ['walk']), State.State('final', self.enterFinal, self.exitFinal, ['start']) ], 'start', 'final') self.parentFSM = parentFSM self.tunnelOriginList = [] self.trolleyDoneEvent = 'trolleyDone' self.hfaDoneEvent = 'hfaDoneEvent' self.npcfaDoneEvent = 'npcfaDoneEvent' self.dialog = None self.deathAckBox = None return def enter(self, requestStatus): self.fsm.enterInitialState() messenger.send('enterPlayground') self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) base.playMusic(self.loader.music, looping=1, volume=0.8) self.loader.geom.reparentTo(render) for i in self.loader.nodeList: self.loader.enterAnimatedProps(i) self._telemLimiter = TLGatherAllAvs('Playground', RotationLimitToH) def __lightDecorationOn__(): geom = base.cr.playGame.hood.loader.geom self.loader.hood.halloweenLights = geom.findAllMatches( '**/*light*') self.loader.hood.halloweenLights += geom.findAllMatches( '**/*lamp*') self.loader.hood.halloweenLights += geom.findAllMatches( '**/prop_snow_tree*') for light in self.loader.hood.halloweenLights: light.setColorScaleOff(0) newsManager = base.cr.newsManager if newsManager: holidayIds = base.cr.newsManager.getDecorationHolidayId() if (ToontownGlobals.HALLOWEEN_COSTUMES in holidayIds or ToontownGlobals.SPOOKY_COSTUMES in holidayIds) and self.loader.hood.spookySkyFile: lightsOff = Sequence( LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.1, Vec4(0.55, 0.55, 0.65, 1)), Func(self.loader.hood.startSpookySky), Func(__lightDecorationOn__)) lightsOff.start() else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval( base.cr.playGame.hood.loader.geom, 0.1, Vec4(1, 1, 1, 1)) lightsOn.start() else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval( base.cr.playGame.hood.loader.geom, 0.1, Vec4(1, 1, 1, 1)) lightsOn.start() NametagGlobals.setMasterArrowsOn(1) self.zoneId = requestStatus['zoneId'] self.tunnelOriginList = base.cr.hoodMgr.addLinkTunnelHooks( self, self.loader.nodeList, self.zoneId) how = requestStatus['how'] if how == 'teleportIn': how = 'deathAck' self.fsm.request(how, [requestStatus]) def exit(self): self.ignoreAll() messenger.send('exitPlayground') self._telemLimiter.destroy() del self._telemLimiter for node in self.tunnelOriginList: node.removeNode() del self.tunnelOriginList self.loader.geom.reparentTo(hidden) def __lightDecorationOff__(): for light in self.loader.hood.halloweenLights: light.reparentTo(hidden) newsManager = base.cr.newsManager NametagGlobals.setMasterArrowsOn(0) for i in self.loader.nodeList: self.loader.exitAnimatedProps(i) self.loader.hood.stopSky() self.loader.music.stop() def load(self): Place.Place.load(self) self.parentFSM.getStateNamed('playground').addChild(self.fsm) def unload(self): self.parentFSM.getStateNamed('playground').removeChild(self.fsm) del self.parentFSM del self.fsm if self.dialog: self.dialog.cleanup() self.dialog = None if self.deathAckBox: self.deathAckBox.cleanup() self.deathAckBox = None TTDialog.cleanupDialog('globalDialog') self.ignoreAll() Place.Place.unload(self) return def showTreasurePoints(self, points): self.hideDebugPointText() for i in range(len(points)): p = points[i] self.showDebugPointText(str(i), p) def showDropPoints(self, points): self.hideDebugPointText() for i in range(len(points)): p = points[i] self.showDebugPointText(str(i), p) def showPaths(self): pass def hidePaths(self): self.hideDebugPointText() def showPathPoints(self, paths, waypoints=None): self.hideDebugPointText() lines = LineSegs() lines.setColor(1, 0, 0, 1) from toontown.classicchars import CCharPaths for name, pointDef in paths.items(): self.showDebugPointText(name, pointDef[0]) for connectTo in pointDef[1]: toDef = paths[connectTo] fromP = pointDef[0] toP = toDef[0] lines.moveTo(fromP[0], fromP[1], fromP[2] + 2.0) wpList = CCharPaths.getWayPoints(name, connectTo, paths, waypoints) for wp in wpList: lines.drawTo(wp[0], wp[1], wp[2] + 2.0) self.showDebugPointText('*', wp) lines.drawTo(toP[0], toP[1], toP[2] + 2.0) self.debugText.attachNewNode(lines.create()) def hideDebugPointText(self): if hasattr(self, 'debugText'): children = self.debugText.getChildren() for i in range(children.getNumPaths()): children[i].removeNode() def showDebugPointText(self, text, point): if not hasattr(self, 'debugText'): self.debugText = self.loader.geom.attachNewNode('debugText') self.debugTextNode = TextNode('debugTextNode') self.debugTextNode.setTextColor(1, 0, 0, 1) self.debugTextNode.setAlign(TextNode.ACenter) self.debugTextNode.setFont(ToontownGlobals.getSignFont()) self.debugTextNode.setText(text) np = self.debugText.attachNewNode(self.debugTextNode.generate()) np.setPos(point[0], point[1], point[2]) np.setScale(4.0) np.setBillboardPointEye() def enterTrolley(self): base.localAvatar.laffMeter.start() base.localAvatar.b_setAnimState('off', 1) base.localAvatar.cantLeaveGame = 1 self.accept(self.trolleyDoneEvent, self.handleTrolleyDone) self.trolley = Trolley.Trolley(self, self.fsm, self.trolleyDoneEvent) self.trolley.load() self.trolley.enter() def exitTrolley(self): base.localAvatar.laffMeter.stop() base.localAvatar.cantLeaveGame = 0 self.ignore(self.trolleyDoneEvent) self.trolley.unload() self.trolley.exit() del self.trolley def detectedTrolleyCollision(self): self.fsm.request('trolley') def handleTrolleyDone(self, doneStatus): self.notify.debug('handling trolley done event') mode = doneStatus['mode'] if mode == 'reject': self.fsm.request('walk') elif mode == 'exit': self.fsm.request('walk') elif mode == 'minigame': self.doneStatus = { 'loader': 'minigame', 'where': 'minigame', 'hoodId': self.loader.hood.id, 'zoneId': doneStatus['zoneId'], 'shardId': None, 'minigameId': doneStatus['minigameId'] } messenger.send(self.doneEvent) else: self.notify.error('Unknown mode: ' + mode + ' in handleTrolleyDone') return def debugStartMinigame(self, zoneId, minigameId): self.doneStatus = { 'loader': 'minigame', 'where': 'minigame', 'hoodId': self.loader.hood.id, 'zoneId': zoneId, 'shardId': None, 'minigameId': minigameId } messenger.send(self.doneEvent) return def enterTFACallback(self, requestStatus, doneStatus): self.tfa.exit() del self.tfa doneStatusMode = doneStatus['mode'] if doneStatusMode == 'complete': self.requestLeave(requestStatus) elif doneStatusMode == 'incomplete': self.fsm.request('TFAReject') else: self.notify.error('Unknown mode: %s' % doneStatusMode) def enterDFACallback(self, requestStatus, doneStatus): self.dfa.exit() del self.dfa ds = doneStatus['mode'] if ds == 'complete': self.fsm.request('NPCFA', [requestStatus]) elif ds == 'incomplete': self.fsm.request('DFAReject') else: self.notify.error( 'Unknown done status for DownloadForceAcknowledge: ' + ` doneStatus `) def enterHFA(self, requestStatus): self.acceptOnce(self.hfaDoneEvent, self.enterHFACallback, [requestStatus]) self.hfa = HealthForceAcknowledge.HealthForceAcknowledge( self.hfaDoneEvent) self.hfa.enter(1) def exitHFA(self): self.ignore(self.hfaDoneEvent) def enterHFACallback(self, requestStatus, doneStatus): self.hfa.exit() del self.hfa if doneStatus['mode'] == 'complete': if requestStatus.get('partyHat', 0): outHow = {'teleportIn': 'tunnelOut'} else: outHow = { 'teleportIn': 'teleportOut', 'tunnelIn': 'tunnelOut', 'doorIn': 'doorOut' } self.fsm.request(outHow[requestStatus['how']], [requestStatus]) elif doneStatus['mode'] == 'incomplete': self.fsm.request('HFAReject') else: self.notify.error( 'Unknown done status for HealthForceAcknowledge: ' + ` doneStatus `) def enterHFAReject(self): self.fsm.request('walk') def exitHFAReject(self): pass def enterNPCFA(self, requestStatus): self.acceptOnce(self.npcfaDoneEvent, self.enterNPCFACallback, [requestStatus]) self.npcfa = NPCForceAcknowledge.NPCForceAcknowledge( self.npcfaDoneEvent) self.npcfa.enter() def exitNPCFA(self): self.ignore(self.npcfaDoneEvent) def enterNPCFACallback(self, requestStatus, doneStatus): self.npcfa.exit() del self.npcfa if doneStatus['mode'] == 'complete': self.fsm.request('HFA', [requestStatus]) elif doneStatus['mode'] == 'incomplete': self.fsm.request('NPCFAReject') else: self.notify.error('Unknown done status for NPCForceAcknowledge: ' + ` doneStatus `) def enterNPCFAReject(self): self.fsm.request('walk') def exitNPCFAReject(self): pass def enterWalk(self, teleportIn=0): if self.deathAckBox: self.ignore('deathAck') self.deathAckBox.cleanup() self.deathAckBox = None Place.Place.enterWalk(self, teleportIn) return def enterDeathAck(self, requestStatus): self.deathAckBox = None self.fsm.request('teleportIn', [requestStatus]) return def exitDeathAck(self): if self.deathAckBox: self.ignore('deathAck') self.deathAckBox.cleanup() self.deathAckBox = None return def enterTeleportIn(self, requestStatus): imgScale = 0.25 if self.dialog: x, y, z, h, p, r = base.cr.hoodMgr.getPlaygroundCenterFromId( self.loader.hood.id) elif base.localAvatar.hp < 1: requestStatus['nextState'] = 'popup' x, y, z, h, p, r = base.cr.hoodMgr.getPlaygroundCenterFromId( self.loader.hood.id) self.accept('deathAck', self.__handleDeathAck, extraArgs=[requestStatus]) self.deathAckBox = DeathForceAcknowledge.DeathForceAcknowledge( doneEvent='deathAck') elif base.localAvatar.hp > 0 and ( Quests.avatarHasTrolleyQuest(base.localAvatar) or Quests.avatarHasFirstCogQuest(base.localAvatar) or Quests.avatarHasFriendQuest(base.localAvatar) or Quests.avatarHasPhoneQuest(base.localAvatar) and Quests.avatarHasCompletedPhoneQuest(base.localAvatar) ) and self.loader.hood.id == ToontownGlobals.ToontownCentral: requestStatus['nextState'] = 'popup' imageModel = loader.loadModel('phase_4/models/gui/tfa_images') if base.localAvatar.quests[0][0] == Quests.TROLLEY_QUEST_ID: if not Quests.avatarHasCompletedTrolleyQuest(base.localAvatar): x, y, z, h, p, r = base.cr.hoodMgr.getDropPoint( base.cr.hoodMgr.ToontownCentralInitialDropPoints) msg = TTLocalizer.NPCForceAcknowledgeMessage3 imgNodePath = imageModel.find('**/trolley-dialog-image') imgPos = (0, 0, 0.04) imgScale = 0.5 else: x, y, z, h, p, r = base.cr.hoodMgr.getDropPoint( base.cr.hoodMgr.ToontownCentralHQDropPoints) msg = TTLocalizer.NPCForceAcknowledgeMessage4 imgNodePath = imageModel.find('**/hq-dialog-image') imgPos = (0, 0, -0.02) imgScale = 0.5 elif base.localAvatar.quests[0][0] == Quests.FIRST_COG_QUEST_ID: if not Quests.avatarHasCompletedFirstCogQuest( base.localAvatar): x, y, z, h, p, r = base.cr.hoodMgr.getDropPoint( base.cr.hoodMgr.ToontownCentralTunnelDropPoints) msg = TTLocalizer.NPCForceAcknowledgeMessage5 imgNodePath = imageModel.find('**/tunnelSignA') imgPos = (0, 0, 0.04) imgScale = 0.5 else: x, y, z, h, p, r = base.cr.hoodMgr.getDropPoint( base.cr.hoodMgr.ToontownCentralHQDropPoints) msg = TTLocalizer.NPCForceAcknowledgeMessage6 imgNodePath = imageModel.find('**/hq-dialog-image') imgPos = (0, 0, 0.05) imgScale = 0.5 elif base.localAvatar.quests[0][0] == Quests.FRIEND_QUEST_ID: if not Quests.avatarHasCompletedFriendQuest(base.localAvatar): x, y, z, h, p, r = base.cr.hoodMgr.getDropPoint( base.cr.hoodMgr.ToontownCentralInitialDropPoints) msg = TTLocalizer.NPCForceAcknowledgeMessage7 gui = loader.loadModel( 'phase_3.5/models/gui/friendslist_gui') imgNodePath = gui.find('**/FriendsBox_Closed') imgPos = (0, 0, 0.04) imgScale = 1.0 gui.removeNode() else: x, y, z, h, p, r = base.cr.hoodMgr.getDropPoint( base.cr.hoodMgr.ToontownCentralHQDropPoints) msg = TTLocalizer.NPCForceAcknowledgeMessage8 imgNodePath = imageModel.find('**/hq-dialog-image') imgPos = (0, 0, 0.05) imgScale = 0.5 elif base.localAvatar.quests[0][0] == Quests.PHONE_QUEST_ID: if Quests.avatarHasCompletedPhoneQuest(base.localAvatar): x, y, z, h, p, r = base.cr.hoodMgr.getDropPoint( base.cr.hoodMgr.ToontownCentralHQDropPoints) msg = TTLocalizer.NPCForceAcknowledgeMessage9 imgNodePath = imageModel.find('**/hq-dialog-image') imgPos = (0, 0, 0.05) imgScale = 0.5 self.dialog = TTDialog.TTDialog(text=msg, command=self.__cleanupDialog, style=TTDialog.Acknowledge) imgLabel = DirectLabel.DirectLabel(parent=self.dialog, relief=None, pos=imgPos, scale=TTLocalizer.PimgLabel, image=imgNodePath, image_scale=imgScale) imageModel.removeNode() else: requestStatus['nextState'] = 'walk' x, y, z, h, p, r = base.cr.hoodMgr.getPlaygroundCenterFromId( self.loader.hood.id) base.localAvatar.detachNode() base.localAvatar.setPosHpr(render, x, y, z, h, p, r) Place.Place.enterTeleportIn(self, requestStatus) return def __cleanupDialog(self, value): if self.dialog: self.dialog.cleanup() self.dialog = None if hasattr(self, 'fsm'): self.fsm.request('walk', [1]) return def __handleDeathAck(self, requestStatus): if self.deathAckBox: self.ignore('deathAck') self.deathAckBox.cleanup() self.deathAckBox = None self.fsm.request('walk', [1]) return def enterPopup(self, teleportIn=0): if base.localAvatar.hp < 1: base.localAvatar.b_setAnimState('Sad', 1) else: base.localAvatar.b_setAnimState('neutral', 1.0) self.accept('teleportQuery', self.handleTeleportQuery) base.localAvatar.setTeleportAvailable(1) base.localAvatar.startSleepWatch(self.__handleFallingAsleepPopup) def exitPopup(self): base.localAvatar.stopSleepWatch() base.localAvatar.setTeleportAvailable(0) self.ignore('teleportQuery') def __handleFallingAsleepPopup(self, task): if hasattr(self, 'fsm'): self.fsm.request('walk') base.localAvatar.forceGotoSleep() return Task.done def enterTeleportOut(self, requestStatus): Place.Place.enterTeleportOut(self, requestStatus, self.__teleportOutDone) def __teleportOutDone(self, requestStatus): teleportDebug(requestStatus, 'Playground.__teleportOutDone(%s)' % (requestStatus, )) if hasattr(self, 'activityFsm'): self.activityFsm.requestFinalState() hoodId = requestStatus['hoodId'] zoneId = requestStatus['zoneId'] avId = requestStatus['avId'] shardId = requestStatus['shardId'] if hoodId == self.loader.hood.hoodId and zoneId == self.loader.hood.hoodId and shardId == None: teleportDebug(requestStatus, 'same playground') self.fsm.request('deathAck', [requestStatus]) elif hoodId == ToontownGlobals.MyEstate: teleportDebug(requestStatus, 'estate') self.getEstateZoneAndGoHome(requestStatus) else: teleportDebug(requestStatus, 'different hood/zone') self.doneStatus = requestStatus messenger.send(self.doneEvent) return def exitTeleportOut(self): Place.Place.exitTeleportOut(self) def createPlayground(self, dnaFile): loader.loadDNAFile(self.loader.dnaStore, self.safeZoneStorageDNAFile) node = loader.loadDNAFile(self.loader.dnaStore, dnaFile) if node.getNumParents() == 1: self.geom = NodePath(node.getParent(0)) self.geom.reparentTo(hidden) else: self.geom = hidden.attachNewNode(node) self.makeDictionaries(self.loader.dnaStore) self.tunnelOriginList = base.cr.hoodMgr.addLinkTunnelHooks( self, self.nodeList, self.zoneId) self.geom.flattenMedium() gsg = base.win.getGsg() if gsg: self.geom.prepareScene(gsg) def makeDictionaries(self, dnaStore): self.nodeList = [] for i in range(dnaStore.getNumDNAVisGroups()): groupFullName = dnaStore.getDNAVisGroupName(i) groupName = base.cr.hoodMgr.extractGroupName(groupFullName) groupNode = self.geom.find('**/' + groupFullName) if groupNode.isEmpty(): self.notify.error('Could not find visgroup') self.nodeList.append(groupNode) self.removeLandmarkBlockNodes() self.loader.dnaStore.resetPlaceNodes() self.loader.dnaStore.resetDNAGroups() self.loader.dnaStore.resetDNAVisGroups() self.loader.dnaStore.resetDNAVisGroupsAI() def removeLandmarkBlockNodes(self): npc = self.geom.findAllMatches('**/suit_building_origin') for i in range(npc.getNumPaths()): npc.getPath(i).removeNode() def enterTFA(self, requestStatus): self.acceptOnce(self.tfaDoneEvent, self.enterTFACallback, [requestStatus]) self.tfa = TutorialForceAcknowledge.TutorialForceAcknowledge( self.tfaDoneEvent) self.tfa.enter() def exitTFA(self): self.ignore(self.tfaDoneEvent) def enterTFAReject(self): self.fsm.request('walk') def exitTFAReject(self): pass
class SuitInterior(Place.Place): __module__ = __name__ notify = DirectNotifyGlobal.directNotify.newCategory('SuitInterior') def __init__(self, loader, parentFSM, doneEvent): Place.Place.__init__(self, loader, doneEvent) self.fsm = ClassicFSM.ClassicFSM('SuitInterior', [ State.State('entrance', self.enterEntrance, self.exitEntrance, ['battle', 'walk']), State.State('Elevator', self.enterElevator, self.exitElevator, ['battle', 'walk']), State.State('battle', self.enterBattle, self.exitBattle, ['walk', 'died']), State.State('walk', self.enterWalk, self.exitWalk, [ 'stickerBook', 'stopped', 'sit', 'died', 'teleportOut', 'Elevator', 'DFA', 'trialerFA' ]), State.State('sit', self.enterSit, self.exitSit, ['walk']), State.State( 'stickerBook', self.enterStickerBook, self.exitStickerBook, [ 'walk', 'stopped', 'sit', 'died', 'DFA', 'trialerFA', 'teleportOut', 'Elevator' ]), State.State('trialerFA', self.enterTrialerFA, self.exitTrialerFA, ['trialerFAReject', 'DFA']), State.State('trialerFAReject', self.enterTrialerFAReject, self.exitTrialerFAReject, ['walk']), State.State('DFA', self.enterDFA, self.exitDFA, ['DFAReject', 'teleportOut']), State.State('DFAReject', self.enterDFAReject, self.exitDFAReject, ['walk']), State.State('teleportIn', self.enterTeleportIn, self.exitTeleportIn, ['walk']), State.State('teleportOut', self.enterTeleportOut, self.exitTeleportOut, ['teleportIn']), State.State('stopped', self.enterStopped, self.exitStopped, ['walk', 'elevatorOut']), State.State('died', self.enterDied, self.exitDied, []), State.State('elevatorOut', self.enterElevatorOut, self.exitElevatorOut, []) ], 'entrance', 'elevatorOut') self.parentFSM = parentFSM self.elevatorDoneEvent = 'elevatorDoneSI' self.currentFloor = 0 def enter(self, requestStatus): self.fsm.enterInitialState() self._telemLimiter = TLGatherAllAvs('SuitInterior', RotationLimitToH) self.zoneId = requestStatus['zoneId'] self.accept('DSIDoneEvent', self.handleDSIDoneEvent) def exit(self): self.ignoreAll() self._telemLimiter.destroy() del self._telemLimiter def load(self): Place.Place.load(self) self.parentFSM.getStateNamed('suitInterior').addChild(self.fsm) self.townBattle = TownBattle.TownBattle('town-battle-done') self.townBattle.load() for i in range(1, 3): Suit.loadSuits(i) def unload(self): Place.Place.unload(self) self.parentFSM.getStateNamed('suitInterior').removeChild(self.fsm) del self.parentFSM del self.fsm self.ignoreAll() ModelPool.garbageCollect() TexturePool.garbageCollect() self.townBattle.unload() self.townBattle.cleanup() del self.townBattle for i in range(1, 3): Suit.unloadSuits(i) def setState(self, state, battleEvent=None): if battleEvent: self.fsm.request(state, [battleEvent]) else: self.fsm.request(state) def getZoneId(self): return self.zoneId def enterZone(self, zoneId): pass def isPeriodTimerEffective(self): return 0 def handleDSIDoneEvent(self, requestStatus): self.doneStatus = requestStatus messenger.send(self.doneEvent) def doRequestLeave(self, requestStatus): self.fsm.request('trialerFA', [requestStatus]) def enterEntrance(self): pass def exitEntrance(self): pass def enterElevator(self, distElevator): self.accept(self.elevatorDoneEvent, self.handleElevatorDone) self.elevator = Elevator.Elevator(self.fsm.getStateNamed('Elevator'), self.elevatorDoneEvent, distElevator) self.elevator.load() self.elevator.enter() base.localAvatar.cantLeaveGame = 1 def exitElevator(self): base.localAvatar.cantLeaveGame = 0 self.ignore(self.elevatorDoneEvent) self.elevator.unload() self.elevator.exit() del self.elevator return None def detectedElevatorCollision(self, distElevator): self.fsm.request('Elevator', [distElevator]) return None def handleElevatorDone(self, doneStatus): self.notify.debug('handling elevator done event') where = doneStatus['where'] if where == 'reject': if hasattr( base.localAvatar, 'elevatorNotifier' ) and base.localAvatar.elevatorNotifier.isNotifierOpen(): pass else: self.fsm.request('walk') elif where == 'exit': self.fsm.request('walk') elif where == 'suitInterior': pass else: self.notify.error('Unknown mode: ' + + ' in handleElevatorDone') def enterBattle(self, event): mult = ToontownBattleGlobals.getCreditMultiplier(self.currentFloor) self.townBattle.enter(event, self.fsm.getStateNamed('battle'), bldg=1, creditMultiplier=mult) base.localAvatar.b_setAnimState('off', 1) base.localAvatar.cantLeaveGame = 1 def exitBattle(self): self.townBattle.exit() base.localAvatar.cantLeaveGame = 0 def enterWalk(self, teleportIn=0): Place.Place.enterWalk(self, teleportIn) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterStickerBook(self, page=None): Place.Place.enterStickerBook(self, page) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterSit(self): Place.Place.enterSit(self) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterStopped(self): Place.Place.enterStopped(self) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterTeleportIn(self, requestStatus): base.localAvatar.setPosHpr(2.5, 11.5, ToontownGlobals.FloorOffset, 45.0, 0.0, 0.0) Place.Place.enterTeleportIn(self, requestStatus) def enterTeleportOut(self, requestStatus): Place.Place.enterTeleportOut(self, requestStatus, self.__teleportOutDone) def __teleportOutDone(self, requestStatus): hoodId = requestStatus['hoodId'] if hoodId == ToontownGlobals.MyEstate: self.getEstateZoneAndGoHome(requestStatus) else: messenger.send('localToonLeft') self.doneStatus = requestStatus messenger.send(self.doneEvent) def exitTeleportOut(self): Place.Place.exitTeleportOut(self) def goHomeFailed(self, task): self.notifyUserGoHomeFailed() self.ignore('setLocalEstateZone') self.doneStatus['avId'] = -1 self.doneStatus['zoneId'] = self.getZoneId() self.fsm.request('teleportIn', [self.doneStatus]) return Task.done def enterElevatorOut(self): return None def __elevatorOutDone(self, requestStatus): self.doneStatus = requestStatus messenger.send(self.doneEvent) def exitElevatorOut(self): return None
class ToonInterior(Place.Place): notify = DirectNotifyGlobal.directNotify.newCategory('ToonInterior') def __init__(self, loader, parentFSMState, doneEvent): Place.Place.__init__(self, loader, doneEvent) self.dnaFile = 'phase_7/models/modules/toon_interior' self.isInterior = 1 self.tfaDoneEvent = 'tfaDoneEvent' self.hfaDoneEvent = 'hfaDoneEvent' self.npcfaDoneEvent = 'npcfaDoneEvent' self.fsm = ClassicFSM.ClassicFSM('ToonInterior', [State.State('start', self.enterStart, self.exitStart, ['doorIn', 'teleportIn', 'tutorial']), State.State('walk', self.enterWalk, self.exitWalk, ['sit', 'stickerBook', 'doorOut', 'DFA', 'trialerFA', 'teleportOut', 'quest', 'purchase', 'phone', 'stopped', 'pet']), State.State('sit', self.enterSit, self.exitSit, ['walk']), State.State('stickerBook', self.enterStickerBook, self.exitStickerBook, ['walk', 'DFA', 'trialerFA', 'sit', 'doorOut', 'teleportOut', 'quest', 'purchase', 'phone', 'stopped', 'pet']), State.State('trialerFA', self.enterTrialerFA, self.exitTrialerFA, ['trialerFAReject', 'DFA']), State.State('trialerFAReject', self.enterTrialerFAReject, self.exitTrialerFAReject, ['walk']), State.State('DFA', self.enterDFA, self.exitDFA, ['DFAReject', 'HFA', 'NPCFA', 'teleportOut', 'doorOut']), State.State('DFAReject', self.enterDFAReject, self.exitDFAReject, ['walk']), State.State('NPCFA', self.enterNPCFA, self.exitNPCFA, ['NPCFAReject', 'HFA', 'teleportOut']), State.State('NPCFAReject', self.enterNPCFAReject, self.exitNPCFAReject, ['walk']), State.State('HFA', self.enterHFA, self.exitHFA, ['HFAReject', 'teleportOut', 'tunnelOut']), State.State('HFAReject', self.enterHFAReject, self.exitHFAReject, ['walk']), State.State('doorIn', self.enterDoorIn, self.exitDoorIn, ['walk']), State.State('doorOut', self.enterDoorOut, self.exitDoorOut, ['walk']), State.State('teleportIn', self.enterTeleportIn, self.exitTeleportIn, ['walk']), State.State('teleportOut', self.enterTeleportOut, self.exitTeleportOut, ['teleportIn']), State.State('quest', self.enterQuest, self.exitQuest, ['walk', 'doorOut']), State.State('tutorial', self.enterTutorial, self.exitTutorial, ['walk', 'quest']), State.State('purchase', self.enterPurchase, self.exitPurchase, ['walk', 'doorOut']), State.State('pet', self.enterPet, self.exitPet, ['walk']), State.State('phone', self.enterPhone, self.exitPhone, ['walk', 'doorOut']), State.State('stopped', self.enterStopped, self.exitStopped, ['walk', 'doorOut']), State.State('final', self.enterFinal, self.exitFinal, ['start'])], 'start', 'final') self.parentFSMState = parentFSMState def load(self): Place.Place.load(self) self.parentFSMState.addChild(self.fsm) def unload(self): Place.Place.unload(self) self.parentFSMState.removeChild(self.fsm) del self.parentFSMState del self.fsm ModelPool.garbageCollect() TexturePool.garbageCollect() def enter(self, requestStatus): self.zoneId = requestStatus['zoneId'] self.fsm.enterInitialState() messenger.send('enterToonInterior') self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) volume = requestStatus.get('musicVolume', 0.7) base.playMusic(self.loader.activityMusic, looping=1, volume=volume) self._telemLimiter = TLGatherAllAvs('ToonInterior', RotationLimitToH) NametagGlobals.setMasterArrowsOn(1) self.fsm.request(requestStatus['how'], [requestStatus]) def exit(self): self.ignoreAll() messenger.send('exitToonInterior') self._telemLimiter.destroy() del self._telemLimiter NametagGlobals.setMasterArrowsOn(0) self.loader.activityMusic.stop() def setState(self, state): self.fsm.request(state) def enterTutorial(self, requestStatus): self.fsm.request('walk') base.localAvatar.b_setParent(ToontownGlobals.SPRender) globalClock.tick() base.transitions.irisIn() messenger.send('enterTutorialInterior') def exitTutorial(self): pass def doRequestLeave(self, requestStatus): self.fsm.request('trialerFA', [requestStatus]) def enterDFACallback(self, requestStatus, doneStatus): self.dfa.exit() del self.dfa ds = doneStatus['mode'] if ds == 'complete': self.fsm.request('NPCFA', [requestStatus]) elif ds == 'incomplete': self.fsm.request('DFAReject') else: self.notify.error('Unknown done status for DownloadForceAcknowledge: ' + `doneStatus`) def enterNPCFA(self, requestStatus): self.acceptOnce(self.npcfaDoneEvent, self.enterNPCFACallback, [requestStatus]) self.npcfa = NPCForceAcknowledge.NPCForceAcknowledge(self.npcfaDoneEvent) self.npcfa.enter() def exitNPCFA(self): self.ignore(self.npcfaDoneEvent) def enterNPCFACallback(self, requestStatus, doneStatus): self.npcfa.exit() del self.npcfa if doneStatus['mode'] == 'complete': outHow = {'teleportIn': 'teleportOut', 'tunnelIn': 'tunnelOut', 'doorIn': 'doorOut'} self.fsm.request(outHow[requestStatus['how']], [requestStatus]) elif doneStatus['mode'] == 'incomplete': self.fsm.request('NPCFAReject') else: self.notify.error('Unknown done status for NPCForceAcknowledge: ' + `doneStatus`) def enterNPCFAReject(self): self.fsm.request('walk') def exitNPCFAReject(self): pass def enterHFA(self, requestStatus): self.acceptOnce(self.hfaDoneEvent, self.enterHFACallback, [requestStatus]) self.hfa = HealthForceAcknowledge.HealthForceAcknowledge(self.hfaDoneEvent) self.hfa.enter(1) def exitHFA(self): self.ignore(self.hfaDoneEvent) def enterHFACallback(self, requestStatus, doneStatus): self.hfa.exit() del self.hfa if doneStatus['mode'] == 'complete': outHow = {'teleportIn': 'teleportOut', 'tunnelIn': 'tunnelOut', 'doorIn': 'doorOut'} self.fsm.request(outHow[requestStatus['how']], [requestStatus]) elif doneStatus['mode'] == 'incomplete': self.fsm.request('HFAReject') else: self.notify.error('Unknown done status for HealthForceAcknowledge: ' + `doneStatus`) def enterHFAReject(self): self.fsm.request('walk') def exitHFAReject(self): pass def enterTeleportIn(self, requestStatus): if ZoneUtil.isPetshop(self.zoneId): base.localAvatar.setPosHpr(0, 0, ToontownGlobals.FloorOffset, 45.0, 0.0, 0.0) else: base.localAvatar.setPosHpr(2.5, 11.5, ToontownGlobals.FloorOffset, 45.0, 0.0, 0.0) Place.Place.enterTeleportIn(self, requestStatus) def enterTeleportOut(self, requestStatus): Place.Place.enterTeleportOut(self, requestStatus, self.__teleportOutDone) def __teleportOutDone(self, requestStatus): hoodId = requestStatus['hoodId'] zoneId = requestStatus['zoneId'] shardId = requestStatus['shardId'] if hoodId == self.loader.hood.id and zoneId == self.zoneId and shardId == None: self.fsm.request('teleportIn', [requestStatus]) elif hoodId == ToontownGlobals.MyEstate: self.getEstateZoneAndGoHome(requestStatus) else: self.doneStatus = requestStatus messenger.send(self.doneEvent) return def goHomeFailed(self, task): self.notifyUserGoHomeFailed() self.ignore('setLocalEstateZone') self.doneStatus['avId'] = -1 self.doneStatus['zoneId'] = self.getZoneId() self.fsm.request('teleportIn', [self.doneStatus]) return Task.done def exitTeleportOut(self): Place.Place.exitTeleportOut(self)
class CogHQExterior(BattlePlace.BattlePlace): notify = DirectNotifyGlobal.directNotify.newCategory('CogHQExterior') def __init__(self, loader, parentFSM, doneEvent): BattlePlace.BattlePlace.__init__(self, loader, doneEvent) self.parentFSM = parentFSM self.fsm = ClassicFSM.ClassicFSM('CogHQExterior', [ State.State('start', self.enterStart, self.exitStart, ['walk', 'tunnelIn', 'teleportIn', 'doorIn']), State.State('walk', self.enterWalk, self.exitWalk, [ 'stickerBook', 'teleportOut', 'tunnelOut', 'DFA', 'doorOut', 'died', 'stopped', 'WaitForBattle', 'battle', 'squished', 'stopped' ]), State.State('stopped', self.enterStopped, self.exitStopped, ['walk', 'teleportOut', 'stickerBook']), State.State('doorIn', self.enterDoorIn, self.exitDoorIn, ['walk', 'stopped']), State.State('doorOut', self.enterDoorOut, self.exitDoorOut, ['walk', 'stopped']), State.State( 'stickerBook', self.enterStickerBook, self.exitStickerBook, [ 'walk', 'DFA', 'WaitForBattle', 'battle', 'tunnelOut', 'doorOut', 'squished', 'died' ]), State.State('WaitForBattle', self.enterWaitForBattle, self.exitWaitForBattle, ['battle', 'walk']), State.State('battle', self.enterBattle, self.exitBattle, ['walk', 'teleportOut', 'died']), State.State('DFA', self.enterDFA, self.exitDFA, ['DFAReject', 'teleportOut', 'tunnelOut']), State.State('DFAReject', self.enterDFAReject, self.exitDFAReject, ['walk']), State.State('squished', self.enterSquished, self.exitSquished, ['walk', 'died', 'teleportOut']), State.State('teleportIn', self.enterTeleportIn, self.exitTeleportIn, ['walk', 'WaitForBattle', 'battle']), State.State('teleportOut', self.enterTeleportOut, self.exitTeleportOut, ['teleportIn', 'final', 'WaitForBattle']), State.State('died', self.enterDied, self.exitDied, ['quietZone']), State.State('tunnelIn', self.enterTunnelIn, self.exitTunnelIn, ['walk', 'WaitForBattle', 'battle']), State.State('tunnelOut', self.enterTunnelOut, self.exitTunnelOut, ['final']), State.State('final', self.enterFinal, self.exitFinal, ['start']) ], 'start', 'final') def load(self): self.parentFSM.getStateNamed('cogHQExterior').addChild(self.fsm) BattlePlace.BattlePlace.load(self) def unload(self): self.parentFSM.getStateNamed('cogHQExterior').removeChild(self.fsm) del self.fsm BattlePlace.BattlePlace.unload(self) def enter(self, requestStatus): self.zoneId = requestStatus['zoneId'] BattlePlace.BattlePlace.enter(self) self.fsm.enterInitialState() base.playMusic(self.loader.music, looping=1, volume=0.8) self.loader.geom.reparentTo(render) self.nodeList = [self.loader.geom] self._telemLimiter = TLGatherAllAvs('CogHQExterior', RotationLimitToH) self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) NametagGlobals.setMasterArrowsOn(1) self.tunnelOriginList = base.cr.hoodMgr.addLinkTunnelHooks( self, self.nodeList, self.zoneId) how = requestStatus['how'] self.fsm.request(how, [requestStatus]) def exit(self): self.fsm.requestFinalState() self._telemLimiter.destroy() del self._telemLimiter self.loader.music.stop() for node in self.tunnelOriginList: node.removeNode() del self.tunnelOriginList if self.loader.geom: self.loader.geom.reparentTo(hidden) self.ignoreAll() BattlePlace.BattlePlace.exit(self) def enterTunnelOut(self, requestStatus): fromZoneId = self.zoneId - self.zoneId % 100 tunnelName = base.cr.hoodMgr.makeLinkTunnelName( self.loader.hood.id, fromZoneId) requestStatus['tunnelName'] = tunnelName BattlePlace.BattlePlace.enterTunnelOut(self, requestStatus) def enterTeleportIn(self, requestStatus): x, y, z, h, p, r = base.cr.hoodMgr.getPlaygroundCenterFromId( self.loader.hood.id) base.localAvatar.setPosHpr(render, x, y, z, h, p, r) BattlePlace.BattlePlace.enterTeleportIn(self, requestStatus) def enterTeleportOut(self, requestStatus, callback=None): if requestStatus.has_key('battle'): self.__teleportOutDone(requestStatus) else: BattlePlace.BattlePlace.enterTeleportOut(self, requestStatus, self.__teleportOutDone) def __teleportOutDone(self, requestStatus): hoodId = requestStatus['hoodId'] zoneId = requestStatus['zoneId'] avId = requestStatus['avId'] shardId = requestStatus['shardId'] if hoodId == self.loader.hood.hoodId and zoneId == self.loader.hood.hoodId and shardId == None: self.fsm.request('teleportIn', [requestStatus]) elif hoodId == ToontownGlobals.MyEstate: self.getEstateZoneAndGoHome(requestStatus) else: self.doneStatus = requestStatus messenger.send(self.doneEvent) return def exitTeleportOut(self): BattlePlace.BattlePlace.exitTeleportOut(self) def enterSquished(self): base.localAvatar.laffMeter.start() base.localAvatar.b_setAnimState('Squish') taskMgr.doMethodLater(2.0, self.handleSquishDone, base.localAvatar.uniqueName('finishSquishTask')) def handleSquishDone(self, extraArgs=[]): base.cr.playGame.getPlace().setState('walk') def exitSquished(self): taskMgr.remove(base.localAvatar.uniqueName('finishSquishTask')) base.localAvatar.laffMeter.stop()
class Street(BattlePlace.BattlePlace): notify = DirectNotifyGlobal.directNotify.newCategory('Street') def __init__(self, loader, parentFSM, doneEvent): BattlePlace.BattlePlace.__init__(self, loader, doneEvent) self.fsm = ClassicFSM.ClassicFSM('Street', [State.State('start', self.enterStart, self.exitStart, ['walk', 'tunnelIn', 'doorIn', 'teleportIn', 'elevatorIn']), State.State('walk', self.enterWalk, self.exitWalk, ['push', 'sit', 'stickerBook', 'WaitForBattle', 'battle', 'DFA', 'trialerFA', 'doorOut', 'elevator', 'tunnelIn', 'tunnelOut', 'teleportOut', 'quest', 'stopped', 'fishing', 'purchase', 'died']), State.State('sit', self.enterSit, self.exitSit, ['walk']), State.State('push', self.enterPush, self.exitPush, ['walk']), State.State('stickerBook', self.enterStickerBook, self.exitStickerBook, ['walk', 'push', 'sit', 'battle', 'DFA', 'trialerFA', 'doorOut', 'elevator', 'tunnelIn', 'tunnelOut', 'WaitForBattle', 'teleportOut', 'quest', 'stopped', 'fishing', 'purchase']), State.State('WaitForBattle', self.enterWaitForBattle, self.exitWaitForBattle, ['battle', 'walk']), State.State('battle', self.enterBattle, self.exitBattle, ['walk', 'teleportOut', 'died']), State.State('doorIn', self.enterDoorIn, self.exitDoorIn, ['walk']), State.State('doorOut', self.enterDoorOut, self.exitDoorOut, ['walk']), State.State('elevatorIn', self.enterElevatorIn, self.exitElevatorIn, ['walk']), State.State('elevator', self.enterElevator, self.exitElevator, ['walk']), State.State('trialerFA', self.enterTrialerFA, self.exitTrialerFA, ['trialerFAReject', 'DFA']), State.State('trialerFAReject', self.enterTrialerFAReject, self.exitTrialerFAReject, ['walk']), State.State('DFA', self.enterDFA, self.exitDFA, ['DFAReject', 'teleportOut', 'tunnelOut']), State.State('DFAReject', self.enterDFAReject, self.exitDFAReject, ['walk']), State.State('teleportIn', self.enterTeleportIn, self.exitTeleportIn, ['walk', 'teleportOut', 'quietZone', 'WaitForBattle', 'battle']), State.State('teleportOut', self.enterTeleportOut, self.exitTeleportOut, ['teleportIn', 'quietZone', 'WaitForBattle']), State.State('died', self.enterDied, self.exitDied, ['quietZone']), State.State('tunnelIn', self.enterTunnelIn, self.exitTunnelIn, ['walk']), State.State('tunnelOut', self.enterTunnelOut, self.exitTunnelOut, ['final']), State.State('quietZone', self.enterQuietZone, self.exitQuietZone, ['teleportIn']), State.State('quest', self.enterQuest, self.exitQuest, ['walk', 'stopped']), State.State('stopped', self.enterStopped, self.exitStopped, ['walk']), State.State('stopped', self.enterStopped, self.exitStopped, ['walk']), State.State('fishing', self.enterFishing, self.exitFishing, ['walk']), State.State('purchase', self.enterPurchase, self.exitPurchase, ['walk']), State.State('final', self.enterFinal, self.exitFinal, ['start'])], 'start', 'final') self.parentFSM = parentFSM self.tunnelOriginList = [] self.elevatorDoneEvent = 'elevatorDone' self.halloweenLights = [] self.zone = 0 def enter(self, requestStatus, visibilityFlag = 1, arrowsOn = 1): teleportDebug(requestStatus, 'Street.enter(%s)' % (requestStatus,)) self._ttfToken = None self.fsm.enterInitialState() base.playMusic(self.loader.music, looping=1, volume=0.8) self.loader.geom.reparentTo(render) if visibilityFlag: self.visibilityOn() base.localAvatar.setGeom(self.loader.geom) base.localAvatar.setOnLevelGround(1) self._telemLimiter = TLGatherAllAvs('Street', RotationLimitToH) NametagGlobals.setMasterArrowsOn(arrowsOn) self.zone = ZoneUtil.getBranchZone(requestStatus['zoneId']) def __lightDecorationOn__(): geom = base.cr.playGame.getPlace().loader.geom self.halloweenLights = geom.findAllMatches('**/*light*') self.halloweenLights += geom.findAllMatches('**/*lamp*') self.halloweenLights += geom.findAllMatches('**/prop_snow_tree*') for light in self.halloweenLights: light.setColorScaleOff(1) newsManager = base.cr.newsManager if newsManager: holidayIds = base.cr.newsManager.getDecorationHolidayId() if (ToontownGlobals.HALLOWEEN_COSTUMES in holidayIds or ToontownGlobals.SPOOKY_COSTUMES in holidayIds) and self.loader.hood.spookySkyFile: lightsOff = Sequence(LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.1, Vec4(0.55, 0.55, 0.65, 1)), Func(self.loader.hood.startSpookySky)) lightsOff.start() else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.1, Vec4(1, 1, 1, 1)) lightsOn.start() else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.1, Vec4(1, 1, 1, 1)) lightsOn.start() self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) self.enterZone(requestStatus['zoneId']) self.tunnelOriginList = base.cr.hoodMgr.addLinkTunnelHooks(self, self.loader.nodeList, self.zoneId) self.fsm.request(requestStatus['how'], [requestStatus]) self.replaceStreetSignTextures() return def exit(self, visibilityFlag = 1): if visibilityFlag: self.visibilityOff() self.loader.geom.reparentTo(hidden) self._telemLimiter.destroy() del self._telemLimiter def __lightDecorationOff__(): for light in self.halloweenLights: light.reparentTo(hidden) newsManager = base.cr.newsManager NametagGlobals.setMasterArrowsOn(0) self.loader.hood.stopSky() self.loader.music.stop() base.localAvatar.setGeom(render) base.localAvatar.setOnLevelGround(0) def load(self): BattlePlace.BattlePlace.load(self) self.parentFSM.getStateNamed('street').addChild(self.fsm) def unload(self): self.parentFSM.getStateNamed('street').removeChild(self.fsm) del self.parentFSM del self.fsm self.enterZone(None) cleanupDialog('globalDialog') self.ignoreAll() BattlePlace.BattlePlace.unload(self) return def enterElevatorIn(self, requestStatus): self._eiwbTask = taskMgr.add(Functor(self._elevInWaitBldgTask, requestStatus['bldgDoId']), uniqueName('elevInWaitBldg')) def _elevInWaitBldgTask(self, bldgDoId, task): bldg = base.cr.doId2do.get(bldgDoId) if bldg: if bldg.elevatorNodePath is not None: self._enterElevatorGotElevator() return Task.done return Task.cont def _enterElevatorGotElevator(self): messenger.send('insideVictorElevator') def exitElevatorIn(self): taskMgr.remove(self._eiwbTask) def enterElevator(self, distElevator): base.localAvatar.cantLeaveGame = 1 self.accept(self.elevatorDoneEvent, self.handleElevatorDone) self.elevator = Elevator.Elevator(self.fsm.getStateNamed('elevator'), self.elevatorDoneEvent, distElevator) self.elevator.load() self.elevator.enter() def exitElevator(self): base.localAvatar.cantLeaveGame = 0 self.ignore(self.elevatorDoneEvent) self.elevator.unload() self.elevator.exit() del self.elevator def detectedElevatorCollision(self, distElevator): self.fsm.request('elevator', [distElevator]) return None def handleElevatorDone(self, doneStatus): self.notify.debug('handling elevator done event') where = doneStatus['where'] if where == 'reject': if hasattr(base.localAvatar, 'elevatorNotifier') and base.localAvatar.elevatorNotifier.isNotifierOpen(): pass else: self.fsm.request('walk') elif where == 'exit': self.fsm.request('walk') elif where in ('suitInterior', 'cogdoInterior'): self.doneStatus = doneStatus messenger.send(self.doneEvent) else: self.notify.error('Unknown mode: ' + where + ' in handleElevatorDone') def enterTunnelIn(self, requestStatus): self.enterZone(requestStatus['zoneId']) BattlePlace.BattlePlace.enterTunnelIn(self, requestStatus) def enterTeleportIn(self, requestStatus): teleportDebug(requestStatus, 'Street.enterTeleportIn(%s)' % (requestStatus,)) zoneId = requestStatus['zoneId'] self._ttfToken = self.addSetZoneCompleteCallback(Functor(self._teleportToFriend, requestStatus)) self.enterZone(zoneId) BattlePlace.BattlePlace.enterTeleportIn(self, requestStatus) def _teleportToFriend(self, requestStatus): avId = requestStatus['avId'] hoodId = requestStatus['hoodId'] zoneId = requestStatus['zoneId'] if avId != -1: if not base.cr.doId2do.has_key(avId): teleportDebug(requestStatus, "couldn't find friend %s" % avId) handle = base.cr.identifyFriend(avId) requestStatus = {'how': 'teleportIn', 'hoodId': hoodId, 'zoneId': hoodId, 'shardId': None, 'loader': 'safeZoneLoader', 'where': 'playground', 'avId': avId} self.fsm.request('final') self.__teleportOutDone(requestStatus) return def exitTeleportIn(self): self.removeSetZoneCompleteCallback(self._ttfToken) self._ttfToken = None BattlePlace.BattlePlace.exitTeleportIn(self) return def enterTeleportOut(self, requestStatus): if requestStatus.has_key('battle'): self.__teleportOutDone(requestStatus) else: BattlePlace.BattlePlace.enterTeleportOut(self, requestStatus, self.__teleportOutDone) def __teleportOutDone(self, requestStatus): hoodId = requestStatus['hoodId'] zoneId = requestStatus['zoneId'] shardId = requestStatus['shardId'] if hoodId == self.loader.hood.id and shardId == None: if zoneId == self.zoneId: self.fsm.request('teleportIn', [requestStatus]) elif requestStatus['where'] == 'street' and ZoneUtil.getBranchZone(zoneId) == self.loader.branchZone: self.fsm.request('quietZone', [requestStatus]) else: self.doneStatus = requestStatus messenger.send(self.doneEvent) elif hoodId == ToontownGlobals.MyEstate: self.getEstateZoneAndGoHome(requestStatus) else: self.doneStatus = requestStatus messenger.send(self.doneEvent) return def exitTeleportOut(self): BattlePlace.BattlePlace.exitTeleportOut(self) def goHomeFailed(self, task): self.notifyUserGoHomeFailed() self.ignore('setLocalEstateZone') self.doneStatus['avId'] = -1 self.doneStatus['zoneId'] = self.getZoneId() self.fsm.request('teleportIn', [self.doneStatus]) return Task.done def renameFloorPolys(self, nodeList): for i in nodeList: collNodePaths = i.findAllMatches('**/+CollisionNode') numCollNodePaths = collNodePaths.getNumPaths() visGroupName = i.node().getName() for j in xrange(numCollNodePaths): collNodePath = collNodePaths.getPath(j) bitMask = collNodePath.node().getIntoCollideMask() if bitMask.getBit(1): collNodePath.node().setName(visGroupName) def hideAllVisibles(self): for i in self.loader.nodeList: i.stash() def showAllVisibles(self): for i in self.loader.nodeList: i.unstash() def visibilityOn(self): self.hideAllVisibles() self.accept('on-floor', self.enterZone) def visibilityOff(self): self.ignore('on-floor') self.showAllVisibles() def doEnterZone(self, newZoneId): if self.zoneId != None: for i in self.loader.nodeDict[self.zoneId]: if newZoneId: if i not in self.loader.nodeDict[newZoneId]: self.loader.fadeOutDict[i].start() self.loader.exitAnimatedProps(i) else: i.stash() self.loader.exitAnimatedProps(i) if newZoneId != None: for i in self.loader.nodeDict[newZoneId]: if self.zoneId: if i not in self.loader.nodeDict[self.zoneId]: self.loader.fadeInDict[i].start() self.loader.enterAnimatedProps(i) else: if self.loader.fadeOutDict[i].isPlaying(): self.loader.fadeOutDict[i].finish() if self.loader.fadeInDict[i].isPlaying(): self.loader.fadeInDict[i].finish() self.loader.enterAnimatedProps(i) i.unstash() if newZoneId != self.zoneId: if visualizeZones: if self.zoneId != None: self.loader.zoneDict[self.zoneId].clearColor() if newZoneId != None: self.loader.zoneDict[newZoneId].setColor(0, 0, 1, 1, 100) if newZoneId is not None: loader = base.cr.playGame.getPlace().loader if newZoneId in loader.zoneVisDict: base.cr.sendSetZoneMsg(newZoneId, loader.zoneVisDict[newZoneId]) else: visList = [newZoneId] + loader.zoneVisDict.values()[0] base.cr.sendSetZoneMsg(newZoneId, visList) self.zoneId = newZoneId geom = base.cr.playGame.getPlace().loader.geom self.halloweenLights = geom.findAllMatches('**/*light*') self.halloweenLights += geom.findAllMatches('**/*lamp*') self.halloweenLights += geom.findAllMatches('**/prop_snow_tree*') for light in self.halloweenLights: light.setColorScaleOff(1) return def replaceStreetSignTextures(self): if not hasattr(base.cr, 'playGame'): return place = base.cr.playGame.getPlace() if place is None: return geom = base.cr.playGame.getPlace().loader.geom signs = geom.findAllMatches('**/*tunnelAheadSign*;+s') if signs.getNumPaths() > 0: streetSign = base.cr.streetSign signTexturePath = streetSign.StreetSignBaseDir + '/' + streetSign.StreetSignFileName loaderTexturePath = Filename(str(signTexturePath)) alphaPath = 'phase_4/maps/tt_t_ara_gen_tunnelAheadSign_a.rgb' inDreamland = False if place.zoneId and ZoneUtil.getCanonicalHoodId(place.zoneId) == ToontownGlobals.DonaldsDreamland: inDreamland = True alphaPath = 'phase_4/maps/tt_t_ara_gen_tunnelAheadSign_a.rgb' if Filename(signTexturePath).exists(): signTexture = loader.loadTexture(loaderTexturePath, alphaPath) for sign in signs: if Filename(signTexturePath).exists(): sign.setTexture(signTexture, 1) if inDreamland: sign.setColorScale(0.525, 0.525, 0.525, 1) return
class Street(BattlePlace.BattlePlace): notify = DirectNotifyGlobal.directNotify.newCategory('Street') def __init__(self, loader, parentFSM, doneEvent): BattlePlace.BattlePlace.__init__(self, loader, doneEvent) self.fsm = ClassicFSM.ClassicFSM('Street', [ State.State( 'start', self.enterStart, self.exitStart, ['walk', 'tunnelIn', 'doorIn', 'teleportIn', 'elevatorIn']), State.State('walk', self.enterWalk, self.exitWalk, [ 'push', 'sit', 'stickerBook', 'WaitForBattle', 'battle', 'DFA', 'trialerFA', 'doorOut', 'elevator', 'tunnelIn', 'tunnelOut', 'teleportOut', 'quest', 'stopped', 'fishing', 'purchase', 'died' ]), State.State('sit', self.enterSit, self.exitSit, ['walk']), State.State('push', self.enterPush, self.exitPush, ['walk']), State.State( 'stickerBook', self.enterStickerBook, self.exitStickerBook, [ 'walk', 'push', 'sit', 'battle', 'DFA', 'trialerFA', 'doorOut', 'elevator', 'tunnelIn', 'tunnelOut', 'WaitForBattle', 'teleportOut', 'quest', 'stopped', 'fishing', 'purchase' ]), State.State('WaitForBattle', self.enterWaitForBattle, self.exitWaitForBattle, ['battle', 'walk']), State.State('battle', self.enterBattle, self.exitBattle, ['walk', 'teleportOut', 'died']), State.State('doorIn', self.enterDoorIn, self.exitDoorIn, ['walk']), State.State('doorOut', self.enterDoorOut, self.exitDoorOut, ['walk']), State.State('elevatorIn', self.enterElevatorIn, self.exitElevatorIn, ['walk']), State.State('elevator', self.enterElevator, self.exitElevator, ['walk']), State.State('trialerFA', self.enterTrialerFA, self.exitTrialerFA, ['trialerFAReject', 'DFA']), State.State('trialerFAReject', self.enterTrialerFAReject, self.exitTrialerFAReject, ['walk']), State.State('DFA', self.enterDFA, self.exitDFA, ['DFAReject', 'teleportOut', 'tunnelOut']), State.State('DFAReject', self.enterDFAReject, self.exitDFAReject, ['walk']), State.State( 'teleportIn', self.enterTeleportIn, self.exitTeleportIn, [ 'walk', 'teleportOut', 'quietZone', 'WaitForBattle', 'battle' ]), State.State('teleportOut', self.enterTeleportOut, self.exitTeleportOut, ['teleportIn', 'quietZone', 'WaitForBattle']), State.State('died', self.enterDied, self.exitDied, ['quietZone']), State.State('tunnelIn', self.enterTunnelIn, self.exitTunnelIn, ['walk']), State.State('tunnelOut', self.enterTunnelOut, self.exitTunnelOut, ['final']), State.State('quietZone', self.enterQuietZone, self.exitQuietZone, ['teleportIn']), State.State('quest', self.enterQuest, self.exitQuest, ['walk', 'stopped']), State.State('stopped', self.enterStopped, self.exitStopped, ['walk']), State.State('stopped', self.enterStopped, self.exitStopped, ['walk']), State.State('fishing', self.enterFishing, self.exitFishing, ['walk']), State.State('purchase', self.enterPurchase, self.exitPurchase, ['walk']), State.State('final', self.enterFinal, self.exitFinal, ['start']) ], 'start', 'final') self.parentFSM = parentFSM self.tunnelOriginList = [] self.elevatorDoneEvent = 'elevatorDone' self.halloweenLights = [] self.zone = 0 def enter(self, requestStatus, visibilityFlag=1, arrowsOn=1): teleportDebug(requestStatus, 'Street.enter(%s)' % (requestStatus, )) self._ttfToken = None self.fsm.enterInitialState() base.playMusic(self.loader.music, looping=1, volume=0.8) self.loader.geom.reparentTo(render) if visibilityFlag: self.visibilityOn() base.localAvatar.setGeom(self.loader.geom) base.localAvatar.setOnLevelGround(1) self._telemLimiter = TLGatherAllAvs('Street', RotationLimitToH) NametagGlobals.setWant2dNametags(arrowsOn) self.zone = ZoneUtil.getBranchZone(requestStatus['zoneId']) def __lightDecorationOn__(): geom = base.cr.playGame.getPlace().loader.geom self.halloweenLights = geom.findAllMatches('**/*light*') self.halloweenLights += geom.findAllMatches('**/*lamp*') self.halloweenLights += geom.findAllMatches('**/prop_snow_tree*') for light in self.halloweenLights: light.setColorScaleOff(1) newsManager = base.cr.newsManager if newsManager: holidayIds = base.cr.newsManager.getDecorationHolidayId() if (ToontownGlobals.HALLOWEEN_COSTUMES in holidayIds or ToontownGlobals.SPOOKY_COSTUMES in holidayIds) and self.loader.hood.spookySkyFile: lightsOff = Sequence( LerpColorScaleInterval(base.cr.playGame.hood.loader.geom, 0.1, Vec4(0.55, 0.55, 0.65, 1)), Func(self.loader.hood.startSpookySky)) lightsOff.start() else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval( base.cr.playGame.hood.loader.geom, 0.1, Vec4(1, 1, 1, 1)) lightsOn.start() else: self.loader.hood.startSky() lightsOn = LerpColorScaleInterval( base.cr.playGame.hood.loader.geom, 0.1, Vec4(1, 1, 1, 1)) lightsOn.start() self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) self.enterZone(requestStatus['zoneId']) self.tunnelOriginList = base.cr.hoodMgr.addLinkTunnelHooks( self, self.loader.nodeList, self.zoneId) self.fsm.request(requestStatus['how'], [requestStatus]) self.replaceStreetSignTextures() return def exit(self, visibilityFlag=1): if visibilityFlag: self.visibilityOff() self.loader.geom.reparentTo(hidden) self._telemLimiter.destroy() del self._telemLimiter def __lightDecorationOff__(): for light in self.halloweenLights: light.reparentTo(hidden) newsManager = base.cr.newsManager NametagGlobals.setWant2dNametags(False) self.loader.hood.stopSky() self.loader.music.stop() base.localAvatar.setGeom(render) base.localAvatar.setOnLevelGround(0) def load(self): BattlePlace.BattlePlace.load(self) self.parentFSM.getStateNamed('street').addChild(self.fsm) def unload(self): self.parentFSM.getStateNamed('street').removeChild(self.fsm) del self.parentFSM del self.fsm self.enterZone(None) cleanupDialog('globalDialog') self.ignoreAll() BattlePlace.BattlePlace.unload(self) return def enterElevatorIn(self, requestStatus): self._eiwbTask = taskMgr.add( Functor(self._elevInWaitBldgTask, requestStatus['bldgDoId']), uniqueName('elevInWaitBldg')) def _elevInWaitBldgTask(self, bldgDoId, task): bldg = base.cr.doId2do.get(bldgDoId) if bldg: if bldg.elevatorNodePath is not None: if self._enterElevatorGotElevator(): return Task.done return Task.cont def _enterElevatorGotElevator(self): if not messenger.whoAccepts('insideVictorElevator'): return False messenger.send('insideVictorElevator') return True def exitElevatorIn(self): taskMgr.remove(self._eiwbTask) def enterElevator(self, distElevator): base.localAvatar.cantLeaveGame = 1 self.accept(self.elevatorDoneEvent, self.handleElevatorDone) self.elevator = Elevator.Elevator(self.fsm.getStateNamed('elevator'), self.elevatorDoneEvent, distElevator) self.elevator.load() self.elevator.enter() def exitElevator(self): base.localAvatar.cantLeaveGame = 0 self.ignore(self.elevatorDoneEvent) self.elevator.unload() self.elevator.exit() del self.elevator def detectedElevatorCollision(self, distElevator): self.fsm.request('elevator', [distElevator]) return None def handleElevatorDone(self, doneStatus): self.notify.debug('handling elevator done event') where = doneStatus['where'] if where == 'reject': if hasattr( base.localAvatar, 'elevatorNotifier' ) and base.localAvatar.elevatorNotifier.isNotifierOpen(): pass else: self.fsm.request('walk') elif where == 'exit': self.fsm.request('walk') elif where in ('suitInterior', 'cogdoInterior'): self.doneStatus = doneStatus messenger.send(self.doneEvent) else: self.notify.error('Unknown mode: ' + where + ' in handleElevatorDone') def enterTunnelIn(self, requestStatus): self.enterZone(requestStatus['zoneId']) BattlePlace.BattlePlace.enterTunnelIn(self, requestStatus) def enterTeleportIn(self, requestStatus): teleportDebug(requestStatus, 'Street.enterTeleportIn(%s)' % (requestStatus, )) zoneId = requestStatus['zoneId'] self._ttfToken = self.addSetZoneCompleteCallback( Functor(self._teleportToFriend, requestStatus)) self.enterZone(zoneId) BattlePlace.BattlePlace.enterTeleportIn(self, requestStatus) def _teleportToFriend(self, requestStatus): avId = requestStatus['avId'] hoodId = requestStatus['hoodId'] zoneId = requestStatus['zoneId'] if avId != -1: if avId not in base.cr.doId2do: teleportDebug(requestStatus, "couldn't find friend %s" % avId) handle = base.cr.identifyFriend(avId) requestStatus = { 'how': 'teleportIn', 'hoodId': hoodId, 'zoneId': hoodId, 'shardId': None, 'loader': 'safeZoneLoader', 'where': 'playground', 'avId': avId } self.fsm.request('final') self.__teleportOutDone(requestStatus) return def exitTeleportIn(self): self.removeSetZoneCompleteCallback(self._ttfToken) self._ttfToken = None BattlePlace.BattlePlace.exitTeleportIn(self) return def enterTeleportOut(self, requestStatus): if 'battle' in requestStatus: self.__teleportOutDone(requestStatus) else: BattlePlace.BattlePlace.enterTeleportOut(self, requestStatus, self.__teleportOutDone) def __teleportOutDone(self, requestStatus): hoodId = requestStatus['hoodId'] zoneId = requestStatus['zoneId'] shardId = requestStatus['shardId'] if hoodId == self.loader.hood.id and shardId == None: if zoneId == self.zoneId: self.fsm.request('teleportIn', [requestStatus]) elif requestStatus['where'] == 'street' and ZoneUtil.getBranchZone( zoneId) == self.loader.branchZone: self.fsm.request('quietZone', [requestStatus]) else: self.doneStatus = requestStatus messenger.send(self.doneEvent) elif hoodId == ToontownGlobals.MyEstate: self.getEstateZoneAndGoHome(requestStatus) else: self.doneStatus = requestStatus messenger.send(self.doneEvent) return def exitTeleportOut(self): BattlePlace.BattlePlace.exitTeleportOut(self) def goHomeFailed(self, task): self.notifyUserGoHomeFailed() self.ignore('setLocalEstateZone') self.doneStatus['avId'] = -1 self.doneStatus['zoneId'] = self.getZoneId() self.fsm.request('teleportIn', [self.doneStatus]) return Task.done def renameFloorPolys(self, nodeList): for i in nodeList: collNodePaths = i.findAllMatches('**/+CollisionNode') numCollNodePaths = collNodePaths.getNumPaths() visGroupName = i.node().getName() for j in xrange(numCollNodePaths): collNodePath = collNodePaths.getPath(j) bitMask = collNodePath.node().getIntoCollideMask() if bitMask.getBit(1): collNodePath.node().setName(visGroupName) def hideAllVisibles(self): for i in self.loader.nodeList: i.stash() def showAllVisibles(self): for i in self.loader.nodeList: i.unstash() def visibilityOn(self): self.hideAllVisibles() self.accept('on-floor', self.enterZone) def visibilityOff(self): self.ignore('on-floor') self.showAllVisibles() def doEnterZone(self, newZoneId): if self.zoneId != None: for i in self.loader.nodeDict[self.zoneId]: if newZoneId: if i not in self.loader.nodeDict[newZoneId]: self.loader.fadeOutDict[i].start() self.loader.exitAnimatedProps(i) else: i.stash() self.loader.exitAnimatedProps(i) if newZoneId != None: for i in self.loader.nodeDict[newZoneId]: if self.zoneId: if i not in self.loader.nodeDict[self.zoneId]: self.loader.fadeInDict[i].start() self.loader.enterAnimatedProps(i) else: if self.loader.fadeOutDict[i].isPlaying(): self.loader.fadeOutDict[i].finish() if self.loader.fadeInDict[i].isPlaying(): self.loader.fadeInDict[i].finish() self.loader.enterAnimatedProps(i) i.unstash() if newZoneId != self.zoneId: if visualizeZones: if self.zoneId != None: self.loader.zoneDict[self.zoneId].clearColor() if newZoneId != None: self.loader.zoneDict[newZoneId].setColor(0, 0, 1, 1, 100) if newZoneId is not None: loader = base.cr.playGame.getPlace().loader if newZoneId in loader.zoneVisDict: base.cr.sendSetZoneMsg(newZoneId, loader.zoneVisDict[newZoneId]) else: visList = [newZoneId] + loader.zoneVisDict.values()[0] base.cr.sendSetZoneMsg(newZoneId, visList) self.zoneId = newZoneId geom = base.cr.playGame.getPlace().loader.geom self.halloweenLights = geom.findAllMatches('**/*light*') self.halloweenLights += geom.findAllMatches('**/*lamp*') self.halloweenLights += geom.findAllMatches('**/prop_snow_tree*') for light in self.halloweenLights: light.setColorScaleOff(1) return def replaceStreetSignTextures(self): if not hasattr(base.cr, 'playGame'): return place = base.cr.playGame.getPlace() if place is None: return geom = base.cr.playGame.getPlace().loader.geom signs = geom.findAllMatches('**/*tunnelAheadSign*;+s') if signs.getNumPaths() > 0: streetSign = base.cr.streetSign signTexturePath = streetSign.StreetSignBaseDir + '/' + streetSign.StreetSignFileName loaderTexturePath = Filename(str(signTexturePath)) alphaPath = 'phase_4/maps/tt_t_ara_gen_tunnelAheadSign_a.rgb' inDreamland = False if place.zoneId and ZoneUtil.getCanonicalHoodId( place.zoneId) == ToontownGlobals.DonaldsDreamland: inDreamland = True alphaPath = 'phase_4/maps/tt_t_ara_gen_tunnelAheadSign_a.rgb' if Filename(signTexturePath).exists(): signTexture = loader.loadTexture(loaderTexturePath, alphaPath) for sign in signs: if Filename(signTexturePath).exists(): sign.setTexture(signTexture, 1) if inDreamland: sign.setColorScale(0.525, 0.525, 0.525, 1) return
class CogHQExterior(BattlePlace.BattlePlace): notify = DirectNotifyGlobal.directNotify.newCategory('CogHQExterior') def __init__(self, loader, parentFSM, doneEvent): BattlePlace.BattlePlace.__init__(self, loader, doneEvent) self.parentFSM = parentFSM self.fsm = ClassicFSM.ClassicFSM('CogHQExterior', [ State.State('start', self.enterStart, self.exitStart, [ 'walk', 'tunnelIn', 'skipTunnelIn', 'teleportIn', 'portalIn', 'doorIn' ]), State.State('walk', self.enterWalk, self.exitWalk, [ 'stickerBook', 'teleportOut', 'tunnelOut', 'DFA', 'doorOut', 'died', 'stopped', 'WaitForBattle', 'battle', 'squished', 'stopped' ]), State.State('stopped', self.enterStopped, self.exitStopped, ['walk', 'teleportOut', 'stickerBook']), State.State('doorIn', self.enterDoorIn, self.exitDoorIn, ['walk', 'stopped']), State.State('doorOut', self.enterDoorOut, self.exitDoorOut, ['walk', 'stopped']), State.State( 'stickerBook', self.enterStickerBook, self.exitStickerBook, [ 'walk', 'DFA', 'WaitForBattle', 'battle', 'tunnelOut', 'doorOut', 'squished', 'died' ]), State.State('WaitForBattle', self.enterWaitForBattle, self.exitWaitForBattle, ['battle', 'walk']), State.State('battle', self.enterBattle, self.exitBattle, ['walk', 'teleportOut', 'died']), State.State('DFA', self.enterDFA, self.exitDFA, ['DFAReject', 'teleportOut', 'tunnelOut']), State.State('DFAReject', self.enterDFAReject, self.exitDFAReject, ['walk']), State.State('squished', self.enterSquished, self.exitSquished, ['walk', 'died', 'teleportOut']), State.State('teleportIn', self.enterTeleportIn, self.exitTeleportIn, ['walk', 'WaitForBattle', 'battle']), State.State('teleportOut', self.enterTeleportOut, self.exitTeleportOut, ['teleportIn', 'final', 'WaitForBattle']), State.State('died', self.enterDied, self.exitDied, ['quietZone']), State.State('tunnelIn', self.enterTunnelIn, self.exitTunnelIn, ['walk', 'WaitForBattle', 'battle']), State.State('skipTunnelIn', self.enterSkipTunnelIn, self.exitSkipTunnelIn, ['walk', 'stopped']), State.State('tunnelOut', self.enterTunnelOut, self.exitTunnelOut, ['final']), State.State('portalIn', self.enterPortalIn, self.exitPortalIn, ['walk', 'WaitForBattle', 'battle']), State.State('final', self.enterFinal, self.exitFinal, ['start']) ], 'start', 'final') def load(self): self.parentFSM.getStateNamed('cogHQExterior').addChild(self.fsm) BattlePlace.BattlePlace.load(self) def unload(self): self.parentFSM.getStateNamed('cogHQExterior').removeChild(self.fsm) del self.fsm BattlePlace.BattlePlace.unload(self) def enter(self, requestStatus): self.zoneId = requestStatus['zoneId'] BattlePlace.BattlePlace.enter(self) self.fsm.enterInitialState() base.playMusic(self.loader.music, looping=1, volume=0.8) self.loader.geom.reparentTo(render) self.nodeList = [self.loader.geom] self._telemLimiter = TLGatherAllAvs('CogHQExterior', RotationLimitToH) self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) NametagGlobals.setMasterArrowsOn(1) self.tunnelOriginList = base.cr.hoodMgr.addLinkTunnelHooks( self, self.nodeList, self.zoneId) how = requestStatus['how'] self.fsm.request(how, [requestStatus]) if self.zoneId != ToontownGlobals.BossbotHQ: self.handleInterests() def exit(self): self.fsm.requestFinalState() self._telemLimiter.destroy() del self._telemLimiter self.loader.music.stop() for node in self.tunnelOriginList: node.removeNode() del self.tunnelOriginList if self.loader.geom: self.loader.geom.reparentTo(hidden) self.ignoreAll() BattlePlace.BattlePlace.exit(self) def enterTunnelOut(self, requestStatus): fromZoneId = self.zoneId - self.zoneId % 100 tunnelName = base.cr.hoodMgr.makeLinkTunnelName( self.loader.hood.id, fromZoneId) requestStatus['tunnelName'] = tunnelName BattlePlace.BattlePlace.enterTunnelOut(self, requestStatus) def enterTeleportIn(self, requestStatus): try: coords = ToontownGlobals.hood2Coords[base.queuedHood] base.queuedHood = None print coords base.localAvatar.setPosHpr(render, *coords[0]) except: x, y, z, h, p, r = base.cr.hoodMgr.getPlaygroundCenterFromId( self.loader.hood.id) base.localAvatar.setPosHpr(render, x, y, z, h, p, r) BattlePlace.BattlePlace.enterTeleportIn(self, requestStatus) return def enterTeleportOut(self, requestStatus, callback=None): if 'battle' in requestStatus: self.__teleportOutDone(requestStatus) else: BattlePlace.BattlePlace.enterTeleportOut(self, requestStatus, self.__teleportOutDone) def __teleportOutDone(self, requestStatus): hoodId = requestStatus['hoodId'] zoneId = requestStatus['zoneId'] avId = requestStatus['avId'] shardId = requestStatus['shardId'] if hoodId == self.loader.hood.hoodId and zoneId == self.loader.hood.hoodId and shardId == None: self.fsm.request('teleportIn', [requestStatus]) elif hoodId == ToontownGlobals.MyEstate: self.getEstateZoneAndGoHome(requestStatus) else: self.doneStatus = requestStatus messenger.send(self.doneEvent) return def exitTeleportOut(self): BattlePlace.BattlePlace.exitTeleportOut(self) def enterSquished(self): base.localAvatar.laffMeter.start() base.localAvatar.b_setAnimState('Squish') taskMgr.doMethodLater(2.0, self.handleSquishDone, base.localAvatar.uniqueName('finishSquishTask')) def handleSquishDone(self, extraArgs=[]): base.cr.playGame.getPlace().setState('walk') def exitSquished(self): taskMgr.remove(base.localAvatar.uniqueName('finishSquishTask')) base.localAvatar.laffMeter.stop() def handleInterests(self): dnaStore = DNAStorage() dnaFileName = self.genDNAFileName(self.zoneId) loadDNAFileAI(dnaStore, dnaFileName) self.zoneVisDict = {} for i in xrange(dnaStore.getNumDNAVisGroupsAI()): groupFullName = dnaStore.getDNAVisGroupName(i) visGroup = dnaStore.getDNAVisGroupAI(i) visZoneId = int(base.cr.hoodMgr.extractGroupName(groupFullName)) visZoneId = ZoneUtil.getTrueZoneId(visZoneId, self.zoneId) visibles = [] for i in xrange(visGroup.getNumVisibles()): visibles.append(int(visGroup.getVisibleName(i))) visibles.append(ZoneUtil.getBranchZone(visZoneId)) self.zoneVisDict[visZoneId] = visibles base.cr.sendSetZoneMsg(self.zoneId, self.zoneVisDict.values()[0])
class CogHQBossBattle(BattlePlace.BattlePlace): notify = DirectNotifyGlobal.directNotify.newCategory('CogHQBossBattle') def __init__(self, loader, parentFSM, doneEvent): BattlePlace.BattlePlace.__init__(self, loader, doneEvent) self.parentFSM = parentFSM self.bossCog = None self.teleportInPosHpr = (0, 0, 0, 0, 0, 0) self.fsm = ClassicFSM.ClassicFSM('CogHQBossBattle', [State.State('start', self.enterStart, self.exitStart, ['walk', 'tunnelIn', 'teleportIn', 'movie']), State.State('battle', self.enterBattle, self.exitBattle, ['walk', 'died', 'movie']), State.State('finalBattle', self.enterFinalBattle, self.exitFinalBattle, ['walk', 'stickerBook', 'teleportOut', 'died', 'tunnelOut', 'DFA', 'battle', 'movie', 'ouch', 'crane', 'WaitForBattle', 'squished']), State.State('movie', self.enterMovie, self.exitMovie, ['walk', 'battle', 'finalBattle', 'died', 'teleportOut']), State.State('ouch', self.enterOuch, self.exitOuch, ['walk', 'battle', 'finalBattle', 'died', 'crane']), State.State('crane', self.enterCrane, self.exitCrane, ['walk', 'battle', 'finalBattle', 'died', 'ouch', 'squished']), State.State('walk', self.enterWalk, self.exitWalk, ['stickerBook', 'teleportOut', 'died', 'tunnelOut', 'DFA', 'battle', 'movie', 'ouch', 'crane', 'finalBattle', 'WaitForBattle']), State.State('stickerBook', self.enterStickerBook, self.exitStickerBook, ['walk', 'DFA', 'WaitForBattle', 'movie', 'battle']), State.State('WaitForBattle', self.enterWaitForBattle, self.exitWaitForBattle, ['battle', 'walk', 'movie']), State.State('DFA', self.enterDFA, self.exitDFA, ['DFAReject', 'teleportOut', 'tunnelOut']), State.State('DFAReject', self.enterDFAReject, self.exitDFAReject, ['walk']), State.State('teleportIn', self.enterTeleportIn, self.exitTeleportIn, ['walk']), State.State('teleportOut', self.enterTeleportOut, self.exitTeleportOut, ['teleportIn', 'final', 'WaitForBattle']), State.State('died', self.enterDied, self.exitDied, ['final']), State.State('tunnelIn', self.enterTunnelIn, self.exitTunnelIn, ['walk']), State.State('tunnelOut', self.enterTunnelOut, self.exitTunnelOut, ['final']), State.State('squished', self.enterSquished, self.exitSquished, ['finalBattle', 'crane', 'died', 'teleportOut']), State.State('final', self.enterFinal, self.exitFinal, ['start'])], 'start', 'final') return def load(self): BattlePlace.BattlePlace.load(self) self.parentFSM.getStateNamed('cogHQBossBattle').addChild(self.fsm) self.townBattle = self.loader.townBattle for i in xrange(1, 3): Suit.loadSuits(i) def unload(self): BattlePlace.BattlePlace.unload(self) self.parentFSM.getStateNamed('cogHQBossBattle').removeChild(self.fsm) del self.parentFSM del self.fsm self.ignoreAll() for i in xrange(1, 3): Suit.unloadSuits(i) def getTaskZoneId(self): return base.cr.playGame.hood.id def enter(self, requestStatus, bossCog): self.zoneId = requestStatus['zoneId'] BattlePlace.BattlePlace.enter(self) self.fsm.enterInitialState() self.bossCog = bossCog if self.bossCog: self.bossCog.d_avatarEnter() self._telemLimiter = TLGatherAllAvs('CogHQBossBattle', RotationLimitToH) NametagGlobals.setWant2dNametags(True) base.localAvatar.inventory.setRespectInvasions(0) self.fsm.request(requestStatus['how'], [requestStatus]) def exit(self): self.fsm.requestFinalState() base.localAvatar.inventory.setRespectInvasions(1) if self.bossCog: self.bossCog.d_avatarExit() self.bossCog = None self._telemLimiter.destroy() del self._telemLimiter BattlePlace.BattlePlace.exit(self) return def enterBattle(self, event): mult = 1 if self.bossCog: mult = ToontownBattleGlobals.getBossBattleCreditMultiplier(self.bossCog.battleNumber) self.townBattle.enter(event, self.fsm.getStateNamed('battle'), bldg=1, creditMultiplier=mult) base.localAvatar.b_setAnimState('off', 1) base.localAvatar.setTeleportAvailable(0) base.localAvatar.cantLeaveGame = 1 def exitBattle(self): self.townBattle.exit() def enterFinalBattle(self): self.walkStateData.enter() self.walkStateData.fsm.request('walking') base.localAvatar.setTeleportAvailable(0) base.localAvatar.setTeleportAllowed(0) base.localAvatar.cantLeaveGame = 0 base.localAvatar.book.hideButton() self.ignore(ToontownGlobals.StickerBookHotkey) self.ignore('enterStickerBook') self.ignore(ToontownGlobals.OptionsPageHotkey) def exitFinalBattle(self): self.walkStateData.exit() base.localAvatar.setTeleportAllowed(1) def enterMovie(self, requestStatus = None): base.localAvatar.setTeleportAvailable(0) def exitMovie(self): pass def enterOuch(self): base.localAvatar.setTeleportAvailable(0) base.localAvatar.laffMeter.start() def exitOuch(self): base.localAvatar.laffMeter.stop() def enterCrane(self): base.localAvatar.setTeleportAvailable(0) base.localAvatar.laffMeter.start() base.localAvatar.collisionsOn() def exitCrane(self): base.localAvatar.collisionsOff() base.localAvatar.laffMeter.stop() def enterWalk(self, teleportIn = 0): BattlePlace.BattlePlace.enterWalk(self, teleportIn) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) base.localAvatar.setTeleportAllowed(0) base.localAvatar.book.hideButton() self.ignore(ToontownGlobals.StickerBookHotkey) self.ignore('enterStickerBook') self.ignore(ToontownGlobals.OptionsPageHotkey) self.ignore(self.walkDoneEvent) def exitWalk(self): BattlePlace.BattlePlace.exitWalk(self) base.localAvatar.setTeleportAllowed(1) def enterStickerBook(self, page = None): BattlePlace.BattlePlace.enterStickerBook(self, page) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterSit(self): BattlePlace.BattlePlace.enterSit(self) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterTeleportIn(self, requestStatus): base.localAvatar.detachNode() base.localAvatar.setPosHpr(*self.teleportInPosHpr) BattlePlace.BattlePlace.enterTeleportIn(self, requestStatus) def enterTeleportOut(self, requestStatus): BattlePlace.BattlePlace.enterTeleportOut(self, requestStatus, self.__teleportOutDone) def __teleportOutDone(self, requestStatus): hoodId = requestStatus['hoodId'] if hoodId == ToontownGlobals.MyEstate: self.getEstateZoneAndGoHome(requestStatus) else: self.doneStatus = requestStatus messenger.send(self.doneEvent) def enterSquished(self): base.localAvatar.laffMeter.start() base.localAvatar.b_setAnimState('Flattened') def handleSquishDone(self, extraArgs = []): base.cr.playGame.getPlace().setState('walk') def exitSquished(self): taskMgr.remove(base.localAvatar.uniqueName('finishSquishTask')) base.localAvatar.laffMeter.stop()
class FactoryExterior(BattlePlace.BattlePlace): notify = DirectNotifyGlobal.directNotify.newCategory('FactoryExterior') def __init__(self, loader, parentFSM, doneEvent): BattlePlace.BattlePlace.__init__(self, loader, doneEvent) self.parentFSM = parentFSM self.elevatorDoneEvent = 'elevatorDone' def load(self): self.fsm = ClassicFSM.ClassicFSM('FactoryExterior', [ State.State('start', self.enterStart, self.exitStart, ['walk', 'tunnelIn', 'teleportIn', 'doorIn']), State.State('walk', self.enterWalk, self.exitWalk, [ 'stickerBook', 'teleportOut', 'tunnelOut', 'DFA', 'doorOut', 'elevator', 'stopped', 'WaitForBattle', 'battle' ]), State.State('stopped', self.enterStopped, self.exitStopped, ['walk', 'teleportOut', 'elevator']), State.State( 'stickerBook', self.enterStickerBook, self.exitStickerBook, ['walk', 'DFA', 'WaitForBattle', 'battle', 'elevator']), State.State('WaitForBattle', self.enterWaitForBattle, self.exitWaitForBattle, ['battle', 'walk']), State.State('battle', self.enterBattle, self.exitBattle, ['walk', 'teleportOut', 'died']), State.State('DFA', self.enterDFA, self.exitDFA, ['DFAReject', 'teleportOut', 'tunnelOut']), State.State('DFAReject', self.enterDFAReject, self.exitDFAReject, ['walk']), State.State('teleportIn', self.enterTeleportIn, self.exitTeleportIn, ['walk']), State.State('teleportOut', self.enterTeleportOut, self.exitTeleportOut, ['teleportIn', 'final', 'WaitForBattle']), State.State('doorIn', self.enterDoorIn, self.exitDoorIn, ['walk']), State.State('doorOut', self.enterDoorOut, self.exitDoorOut, ['walk']), State.State('died', self.enterDied, self.exitDied, ['quietZone']), State.State('tunnelIn', self.enterTunnelIn, self.exitTunnelIn, ['walk']), State.State('tunnelOut', self.enterTunnelOut, self.exitTunnelOut, ['final']), State.State('elevator', self.enterElevator, self.exitElevator, ['walk', 'stopped']), State.State('final', self.enterFinal, self.exitFinal, ['start']) ], 'start', 'final') self.parentFSM.getStateNamed('factoryExterior').addChild(self.fsm) BattlePlace.BattlePlace.load(self) def unload(self): self.parentFSM.getStateNamed('factoryExterior').removeChild(self.fsm) del self.fsm BattlePlace.BattlePlace.unload(self) def enter(self, requestStatus): self.zoneId = requestStatus['zoneId'] BattlePlace.BattlePlace.enter(self) self.fsm.enterInitialState() base.playMusic(self.loader.music, looping=1, volume=0.8) self.loader.geom.reparentTo(render) self.nodeList = [self.loader.geom] self.loader.hood.startSky() self._telemLimiter = TLGatherAllAvs('FactoryExterior', RotationLimitToH) self.accept('doorDoneEvent', self.handleDoorDoneEvent) self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger) NametagGlobals.setMasterArrowsOn(1) self.createNPC() self.tunnelOriginList = base.cr.hoodMgr.addLinkTunnelHooks( self, self.nodeList, self.zoneId) how = requestStatus['how'] self.fsm.request(how, [requestStatus]) def exit(self): self._telemLimiter.destroy() del self._telemLimiter self.loader.hood.stopSky() self.fsm.requestFinalState() self.loader.music.stop() for node in self.tunnelOriginList: node.removeNode() del self.tunnelOriginList del self.nodeList self.removeNPC() self.ignoreAll() BattlePlace.BattlePlace.exit(self) def enterTunnelOut(self, requestStatus): fromZoneId = self.zoneId - self.zoneId % 100 tunnelName = base.cr.hoodMgr.makeLinkTunnelName( self.loader.hood.id, fromZoneId) requestStatus['tunnelName'] = tunnelName BattlePlace.BattlePlace.enterTunnelOut(self, requestStatus) def enterTeleportIn(self, requestStatus): base.localAvatar.setPosHpr(-34, -350, 0, -28, 0, 0) BattlePlace.BattlePlace.enterTeleportIn(self, requestStatus) def enterTeleportOut(self, requestStatus): BattlePlace.BattlePlace.enterTeleportOut(self, requestStatus, self.__teleportOutDone) def __teleportOutDone(self, requestStatus): hoodId = requestStatus['hoodId'] zoneId = requestStatus['zoneId'] avId = requestStatus['avId'] shardId = requestStatus['shardId'] if hoodId == self.loader.hood.hoodId and zoneId == self.zoneId and shardId == None: self.fsm.request('teleportIn', [requestStatus]) elif hoodId == ToontownGlobals.MyEstate: self.getEstateZoneAndGoHome(requestStatus) else: self.doneStatus = requestStatus messenger.send(self.doneEvent) return def exitTeleportOut(self): BattlePlace.BattlePlace.exitTeleportOut(self) def enterElevator(self, distElevator, skipDFABoard=0): self.accept(self.elevatorDoneEvent, self.handleElevatorDone) self.elevator = Elevator.Elevator(self.fsm.getStateNamed('elevator'), self.elevatorDoneEvent, distElevator) if skipDFABoard: self.elevator.skipDFABoard = 1 distElevator.elevatorFSM = self.elevator self.elevator.load() self.elevator.enter() def exitElevator(self): self.ignore(self.elevatorDoneEvent) self.elevator.unload() self.elevator.exit() del self.elevator def detectedElevatorCollision(self, distElevator): self.fsm.request('elevator', [distElevator]) def handleElevatorDone(self, doneStatus): self.notify.debug('handling elevator done event') where = doneStatus['where'] if where == 'reject': if hasattr( base.localAvatar, 'elevatorNotifier' ) and base.localAvatar.elevatorNotifier.isNotifierOpen(): pass else: self.fsm.request('walk') elif where == 'exit': self.fsm.request('walk') elif where == 'factoryInterior': self.doneStatus = doneStatus messenger.send(self.doneEvent) elif where == 'stageInterior': self.doneStatus = doneStatus messenger.send(self.doneEvent) else: self.notify.error('Unknown mode: ' + where + ' in handleElevatorDone') def createNPC(self): if not config.GetBool('want-fnaf', False): return self.npc = NPCToons.createLocalNPC(357) self.npc.reparentTo(self.loader.geom) self.npc.setPos(13, -77, 0) self.npc.setH(180) cNode = CollisionNode('fnaf-npc') cNode.addSolid(CollisionSphere(0, 0, 0, 1)) cNode.setCollideMask(ToontownGlobals.WallBitmask) cnp = self.npc.attachNewNode(cNode) self.accept('enterfnaf-npc', self.__handleNPC) self.panel = aspect2d.attachNewNode( CardMaker('fnaf-npc-panel').generate()) self.panel.setTexture( loader.loadTexture('phase_9/maps/tt_fnaf_news.png')) self.panel.setScale(2, 1, 1.5) self.panel.setPos(-1, 0, -.75) guiButton = loader.loadModel('phase_3/models/gui/quit_button') imageList = (guiButton.find('**/QuitBtn_UP'), guiButton.find('**/QuitBtn_DN'), guiButton.find('**/QuitBtn_RLVR')) playButton = DirectButton(text="Accept this job", image=imageList, relief=None, text_scale=.05, command=self.__handleNPCPanelStatus, extraArgs=[1]) exitButton = DirectButton(text=TTLocalizer.GardenDropExit, image=imageList, relief=None, text_scale=.05, command=self.__handleNPCPanelStatus, extraArgs=[0]) playButton.wrtReparentTo(self.panel) exitButton.wrtReparentTo(self.panel) playButton.setPos(playButton, (.69, 0, -.69)) exitButton.setPos(exitButton, (-.69, 0, -.69)) self.panel.stash() def __handleNPC(self, entry): self.fsm.request('stopped') self.panel.unstash() def __handleNPCPanelStatus(self, mode=0): if mode: base.cr.fnafMgr.enterMinigame() else: self.panel.stash() self.fsm.request('walk') def removeNPC(self): if not config.GetBool('want-fnaf', False): return self.npc.cleanup() self.npc.removeNode() self.panel.removeNode() del self.npc def enterZoneStreetBattle(self, newZoneId): # hqs must ignore this return def debugStartMinigame(self, zoneId, minigameId): self.doneStatus = { 'loader': 'minigame', 'where': 'minigame', 'hoodId': self.loader.hood.id, 'zoneId': zoneId, 'shardId': None, 'minigameId': minigameId } messenger.send(self.doneEvent)
class MintInterior(BattlePlace.BattlePlace): notify = DirectNotifyGlobal.directNotify.newCategory('MintInterior') def __init__(self, loader, parentFSM, doneEvent): BattlePlace.BattlePlace.__init__(self, loader, doneEvent) self.parentFSM = parentFSM self.zoneId = loader.mintId self.fsm = ClassicFSM.ClassicFSM('MintInterior', [State.State('start', self.enterStart, self.exitStart, ['walk', 'teleportIn', 'fallDown']), State.State('walk', self.enterWalk, self.exitWalk, ['push', 'sit', 'stickerBook', 'WaitForBattle', 'battle', 'died', 'teleportOut', 'squished', 'fallDown', 'stopped']), State.State('stopped', self.enterStopped, self.exitStopped, ['walk', 'teleportOut', 'stickerBook']), State.State('sit', self.enterSit, self.exitSit, ['walk', 'died', 'teleportOut']), State.State('push', self.enterPush, self.exitPush, ['walk', 'died', 'teleportOut']), State.State('stickerBook', self.enterStickerBook, self.exitStickerBook, ['walk', 'battle', 'WaitForBattle', 'died', 'teleportOut']), State.State('WaitForBattle', self.enterWaitForBattle, self.exitWaitForBattle, ['battle', 'walk', 'died', 'teleportOut']), State.State('battle', self.enterBattle, self.exitBattle, ['walk', 'teleportOut', 'died']), State.State('fallDown', self.enterFallDown, self.exitFallDown, ['walk', 'died', 'teleportOut']), State.State('squished', self.enterSquished, self.exitSquished, ['walk', 'died', 'teleportOut']), State.State('teleportIn', self.enterTeleportIn, self.exitTeleportIn, ['walk', 'teleportOut', 'quietZone', 'died']), State.State('teleportOut', self.enterTeleportOut, self.exitTeleportOut, ['teleportIn', 'FLA', 'quietZone', 'WaitForBattle']), State.State('died', self.enterDied, self.exitDied, ['teleportOut']), State.State('FLA', self.enterFLA, self.exitFLA, ['quietZone']), State.State('quietZone', self.enterQuietZone, self.exitQuietZone, ['teleportIn']), State.State('final', self.enterFinal, self.exitFinal, ['start'])], 'start', 'final') def load(self): self.parentFSM.getStateNamed('mintInterior').addChild(self.fsm) BattlePlace.BattlePlace.load(self) self.music = base.loadMusic('phase_9/audio/bgm/CBHQ_Mint_bg.ogg') def unload(self): self.parentFSM.getStateNamed('mintInterior').removeChild(self.fsm) del self.music del self.fsm del self.parentFSM BattlePlace.BattlePlace.unload(self) def enter(self, requestStatus): self.fsm.enterInitialState() base.transitions.fadeOut(t=0) base.localAvatar.inventory.setRespectInvasions(0) base.cr.forbidCheesyEffects(1) self._telemLimiter = TLGatherAllAvs('MintInterior', RotationLimitToH) def commence(self = self): NametagGlobals.setWant2dNametags(True) self.fsm.request(requestStatus['how'], [requestStatus]) base.playMusic(self.music, looping=1, volume=0.8) base.transitions.irisIn() mint = bboard.get(DistributedMint.DistributedMint.ReadyPost) self.loader.hood.spawnTitleText(mint.mintId, mint.floorNum) self.mintReadyWatcher = BulletinBoardWatcher.BulletinBoardWatcher('MintReady', DistributedMint.DistributedMint.ReadyPost, commence) self.mintDefeated = 0 self.acceptOnce(DistributedMint.DistributedMint.WinEvent, self.handleMintWinEvent) if __debug__ and 0: self.accept('f10', lambda : messenger.send(DistributedMint.DistributedMint.WinEvent)) self.confrontedBoss = 0 def handleConfrontedBoss(self = self): self.confrontedBoss = 1 self.acceptOnce('localToonConfrontedMintBoss', handleConfrontedBoss) def exit(self): NametagGlobals.setWant2dNametags(False) bboard.remove(DistributedMint.DistributedMint.ReadyPost) self._telemLimiter.destroy() del self._telemLimiter base.cr.forbidCheesyEffects(0) base.localAvatar.inventory.setRespectInvasions(1) self.fsm.requestFinalState() self.loader.music.stop() self.music.stop() self.ignoreAll() del self.mintReadyWatcher def enterWalk(self, teleportIn = 0): BattlePlace.BattlePlace.enterWalk(self, teleportIn) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterPush(self): BattlePlace.BattlePlace.enterPush(self) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterWaitForBattle(self): MintInterior.notify.debug('enterWaitForBattle') BattlePlace.BattlePlace.enterWaitForBattle(self) if base.localAvatar.getParent() != render: base.localAvatar.wrtReparentTo(render) base.localAvatar.b_setParent(ToontownGlobals.SPRender) def exitWaitForBattle(self): MintInterior.notify.debug('exitWaitForBattle') BattlePlace.BattlePlace.exitWaitForBattle(self) def enterBattle(self, event): MintInterior.notify.debug('enterBattle') self.music.stop() BattlePlace.BattlePlace.enterBattle(self, event) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterTownBattle(self, event): mult = ToontownBattleGlobals.getMintCreditMultiplier(self.zoneId) base.localAvatar.inventory.setBattleCreditMultiplier(mult) self.loader.townBattle.enter(event, self.fsm.getStateNamed('battle'), bldg=1, creditMultiplier=mult) def exitBattle(self): MintInterior.notify.debug('exitBattle') BattlePlace.BattlePlace.exitBattle(self) self.loader.music.stop() base.playMusic(self.music, looping=1, volume=0.8) def enterStickerBook(self, page = None): BattlePlace.BattlePlace.enterStickerBook(self, page) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterSit(self): BattlePlace.BattlePlace.enterSit(self) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterZone(self, zoneId): pass def enterTeleportOut(self, requestStatus): MintInterior.notify.debug('enterTeleportOut()') BattlePlace.BattlePlace.enterTeleportOut(self, requestStatus, self.__teleportOutDone) def __processLeaveRequest(self, requestStatus): hoodId = requestStatus['hoodId'] if hoodId == ToontownGlobals.MyEstate: self.getEstateZoneAndGoHome(requestStatus) else: self.doneStatus = requestStatus messenger.send(self.doneEvent) def __teleportOutDone(self, requestStatus): MintInterior.notify.debug('__teleportOutDone()') messenger.send('leavingMint') messenger.send('localToonLeft') if self.mintDefeated and not self.confrontedBoss: self.fsm.request('FLA', [requestStatus]) else: self.__processLeaveRequest(requestStatus) def exitTeleportOut(self): MintInterior.notify.debug('exitTeleportOut()') BattlePlace.BattlePlace.exitTeleportOut(self) def handleMintWinEvent(self): MintInterior.notify.debug('handleMintWinEvent') if base.cr.playGame.getPlace().fsm.getCurrentState().getName() == 'died': return self.mintDefeated = 1 if 1: zoneId = ZoneUtil.getHoodId(self.zoneId) else: zoneId = ZoneUtil.getSafeZoneId(base.localAvatar.defaultZone) self.fsm.request('teleportOut', [{'loader': ZoneUtil.getLoaderName(zoneId), 'where': ZoneUtil.getToonWhereName(zoneId), 'how': 'teleportIn', 'hoodId': zoneId, 'zoneId': zoneId, 'shardId': None, 'avId': -1}]) def enterDied(self, requestStatus, callback = None): MintInterior.notify.debug('enterDied') def diedDone(requestStatus, self = self, callback = callback): if callback is not None: callback() messenger.send('leavingMint') self.doneStatus = requestStatus messenger.send(self.doneEvent) return BattlePlace.BattlePlace.enterDied(self, requestStatus, diedDone) def enterFLA(self, requestStatus): MintInterior.notify.debug('enterFLA') self.flaDialog = TTDialog.TTGlobalDialog(message=TTLocalizer.ForcedLeaveMintAckMsg, doneEvent='FLADone', style=TTDialog.Acknowledge, fadeScreen=1) def continueExit(self = self, requestStatus = requestStatus): self.__processLeaveRequest(requestStatus) self.accept('FLADone', continueExit) self.flaDialog.show() def exitFLA(self): MintInterior.notify.debug('exitFLA') if hasattr(self, 'flaDialog'): self.flaDialog.cleanup() del self.flaDialog
class FactoryInterior(BattlePlace.BattlePlace): __module__ = __name__ notify = DirectNotifyGlobal.directNotify.newCategory('FactoryInterior') def __init__(self, loader, parentFSM, doneEvent): BattlePlace.BattlePlace.__init__(self, loader, doneEvent) self.parentFSM = parentFSM self.zoneId = ToontownGlobals.SellbotFactoryInt self.elevatorDoneEvent = 'elevatorDone' def load(self): self.fsm = ClassicFSM.ClassicFSM('FactoryInterior', [State.State('start', self.enterStart, self.exitStart, ['walk', 'teleportIn', 'fallDown']), State.State('walk', self.enterWalk, self.exitWalk, ['push', 'sit', 'stickerBook', 'WaitForBattle', 'battle', 'died', 'teleportOut', 'squished', 'DFA', 'fallDown', 'elevator']), State.State('stopped', self.enterStopped, self.exitStopped, ['walk', 'teleportOut']), State.State('sit', self.enterSit, self.exitSit, ['walk', 'died', 'teleportOut']), State.State('push', self.enterPush, self.exitPush, ['walk', 'died', 'teleportOut']), State.State('stickerBook', self.enterStickerBook, self.exitStickerBook, ['walk', 'battle', 'DFA', 'WaitForBattle', 'died', 'teleportOut']), State.State('WaitForBattle', self.enterWaitForBattle, self.exitWaitForBattle, ['battle', 'walk', 'died', 'teleportOut']), State.State('battle', self.enterBattle, self.exitBattle, ['walk', 'teleportOut', 'died']), State.State('fallDown', self.enterFallDown, self.exitFallDown, ['walk', 'died', 'teleportOut']), State.State('squished', self.enterSquished, self.exitSquished, ['walk', 'died', 'teleportOut']), State.State('teleportIn', self.enterTeleportIn, self.exitTeleportIn, ['walk', 'teleportOut', 'quietZone', 'died']), State.State('teleportOut', self.enterTeleportOut, self.exitTeleportOut, ['teleportIn', 'FLA', 'quietZone', 'WaitForBattle']), State.State('DFA', self.enterDFA, self.exitDFA, ['DFAReject', 'teleportOut']), State.State('DFAReject', self.enterDFAReject, self.exitDFAReject, ['walkteleportOut']), State.State('died', self.enterDied, self.exitDied, ['teleportOut']), State.State('FLA', self.enterFLA, self.exitFLA, ['quietZone']), State.State('quietZone', self.enterQuietZone, self.exitQuietZone, ['teleportIn']), State.State('elevator', self.enterElevator, self.exitElevator, ['walk']), State.State('final', self.enterFinal, self.exitFinal, ['start'])], 'start', 'final') self.parentFSM.getStateNamed('factoryInterior').addChild(self.fsm) BattlePlace.BattlePlace.load(self) self.music = base.loadMusic('phase_9/audio/bgm/CHQ_FACT_bg.mid') def unload(self): self.parentFSM.getStateNamed('factoryInterior').removeChild(self.fsm) del self.fsm del self.music BattlePlace.BattlePlace.unload(self) def enter(self, requestStatus): self.fsm.enterInitialState() base.transitions.fadeOut(t=0) base.localAvatar.inventory.setRespectInvasions(0) self._telemLimiter = TLGatherAllAvs('FactoryInterior', RotationLimitToH) def commence(self = self): NametagGlobals.setMasterArrowsOn(1) self.fsm.request(requestStatus['how'], [requestStatus]) base.playMusic(self.music, looping=1, volume=0.8) base.transitions.irisIn() if hasattr(base, 'factoryReady'): commence() else: self.acceptOnce('FactoryReady', commence) self.factoryDefeated = 0 self.acceptOnce('FactoryWinEvent', self.handleFactoryWinEvent) if __debug__ and 0: self.accept('f10', lambda : messenger.send('FactoryWinEvent')) self.confrontedForeman = 0 def handleConfrontedForeman(self = self): self.confrontedForeman = 1 self.acceptOnce('localToonConfrontedForeman', handleConfrontedForeman) def exit(self): NametagGlobals.setMasterArrowsOn(0) self._telemLimiter.destroy() del self._telemLimiter if hasattr(base, 'factoryReady'): del base.factoryReady base.localAvatar.inventory.setRespectInvasions(1) self.fsm.requestFinalState() self.loader.music.stop() self.music.stop() self.ignoreAll() def enterWalk(self, teleportIn = 0): BattlePlace.BattlePlace.enterWalk(self, teleportIn) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterPush(self): BattlePlace.BattlePlace.enterPush(self) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterWaitForBattle(self): FactoryInterior.notify.info('enterWaitForBattle') BattlePlace.BattlePlace.enterWaitForBattle(self) if base.localAvatar.getParent() != render: base.localAvatar.wrtReparentTo(render) base.localAvatar.b_setParent(ToontownGlobals.SPRender) def exitWaitForBattle(self): FactoryInterior.notify.info('exitWaitForBattle') BattlePlace.BattlePlace.exitWaitForBattle(self) def enterBattle(self, event): FactoryInterior.notify.info('enterBattle') self.music.stop() BattlePlace.BattlePlace.enterBattle(self, event) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterTownBattle(self, event): mult = ToontownBattleGlobals.getFactoryCreditMultiplier(self.zoneId) base.localAvatar.inventory.setBattleCreditMultiplier(mult) self.loader.townBattle.enter(event, self.fsm.getStateNamed('battle'), bldg=1, creditMultiplier=mult) def exitBattle(self): FactoryInterior.notify.info('exitBattle') BattlePlace.BattlePlace.exitBattle(self) self.loader.music.stop() base.playMusic(self.music, looping=1, volume=0.8) def enterStickerBook(self, page = None): BattlePlace.BattlePlace.enterStickerBook(self, page) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterSit(self): BattlePlace.BattlePlace.enterSit(self) self.ignore('teleportQuery') base.localAvatar.setTeleportAvailable(0) def enterZone(self, zoneId): pass def enterTeleportOut(self, requestStatus): FactoryInterior.notify.info('enterTeleportOut()') BattlePlace.BattlePlace.enterTeleportOut(self, requestStatus, self.__teleportOutDone) def __processLeaveRequest(self, requestStatus): hoodId = requestStatus['hoodId'] if hoodId == ToontownGlobals.MyEstate: self.getEstateZoneAndGoHome(requestStatus) else: self.doneStatus = requestStatus messenger.send(self.doneEvent) def __teleportOutDone(self, requestStatus): FactoryInterior.notify.info('__teleportOutDone()') messenger.send('leavingFactory') messenger.send('localToonLeft') if self.factoryDefeated and not self.confrontedForeman: self.fsm.request('FLA', [requestStatus]) else: self.__processLeaveRequest(requestStatus) def exitTeleportOut(self): FactoryInterior.notify.info('exitTeleportOut()') BattlePlace.BattlePlace.exitTeleportOut(self) def detectedElevatorCollision(self, distElevator): self.fsm.request('elevator', [distElevator]) def enterElevator(self, distElevator): self.accept(self.elevatorDoneEvent, self.handleElevatorDone) self.elevator = Elevator.Elevator(self.fsm.getStateNamed('elevator'), self.elevatorDoneEvent, distElevator) distElevator.elevatorFSM = self.elevator self.elevator.load() self.elevator.enter() def exitElevator(self): self.ignore(self.elevatorDoneEvent) self.elevator.unload() self.elevator.exit() def handleElevatorDone(self, doneStatus): self.notify.debug('handling elevator done event') where = doneStatus['where'] if where == 'reject': if hasattr(base.localAvatar, 'elevatorNotifier') and base.localAvatar.elevatorNotifier.isNotifierOpen(): pass else: self.fsm.request('walk') elif where == 'exit': self.fsm.request('walk') elif where == 'factoryInterior' or where == 'suitInterior': self.doneStatus = doneStatus self.doneEvent = 'lawOfficeFloorDone' messenger.send(self.doneEvent) else: self.notify.error('Unknown mode: ' + where + ' in handleElevatorDone') def handleFactoryWinEvent--- This code section failed: ---