def enterTownLoader(self, requestStatus): teleportDebug( requestStatus, 'ToonHood.enterTownLoader, status=%s' % (requestStatus, )) self.accept(self.loaderDoneEvent, self.handleTownLoaderDone) self.loader.enter(requestStatus) self.spawnTitleText(requestStatus['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) 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 enterStreet(self, requestStatus): teleportDebug(requestStatus, 'enterStreet(%s)' % requestStatus) self.acceptOnce(self.placeDoneEvent, self.streetDone) self.place = self.streetClass(self, self.fsm, self.placeDoneEvent) self.place.load() base.cr.playGame.setPlace(self.place) self.place.enter(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 _placeTeleportInPostZoneComplete(self, requestStatus): teleportDebug( requestStatus, '_placeTeleportInPostZoneComplete(%s)' % (requestStatus, )) NametagGlobals.setMasterArrowsOn(0) base.localAvatar.laffMeter.start() base.localAvatar.startQuestMap() base.localAvatar.reconsiderCheesyEffect() base.localAvatar.obscureMoveFurnitureButton(1) avId = requestStatus.get('avId', -1) if avId != -1: def doTeleport(avId, teleported): if avId in base.cr.doId2do: teleportDebug(requestStatus, 'teleport to avatar') avatar = base.cr.doId2do[avId] avatar.forceToTruePosition() base.localAvatar.gotoNode(avatar) base.localAvatar.b_teleportGreeting(avId) else: friend = base.cr.identifyAvatar(avId) if friend is not None: # The avatar might be in another zone or not generated yet. if not teleported: # Try again one more time. teleportDebug(requestStatus, 'Retrying teleport...') taskMgr.doMethodLater(0.2, doTeleport, uniqueName('doTeleport'), extraArgs=[avId, True]) return teleportDebug(requestStatus, 'friend not here, giving up') base.localAvatar.setSystemMessage( avId, OTPLocalizer.WhisperTargetLeftVisit % (friend.getName(), )) friend.d_teleportGiveup(base.localAvatar.doId) taskMgr.doMethodLater(0.3, doTeleport, uniqueName('doTeleport'), extraArgs=[avId, False]) base.transitions.irisIn() self.nextState = requestStatus.get('nextState', 'walk') base.localAvatar.attachCamera() base.localAvatar.startUpdateSmartCamera() base.localAvatar.startPosHprBroadcast() globalClock.tick() base.localAvatar.b_setAnimState('TeleportIn', 1, callback=self.teleportInDone) base.localAvatar.d_broadcastPositionNow() base.localAvatar.b_setParent(ToontownGlobals.SPRender) return
def enterQuietZone(self, requestStatus): teleportDebug(requestStatus, 'Hood.enterQuietZone: status=%s' % requestStatus) self._quietZoneDoneEvent = uniqueName('quietZoneDone') self.acceptOnce(self._quietZoneDoneEvent, self.handleQuietZoneDone) self.quietZoneStateData = QuietZoneState.QuietZoneState(self._quietZoneDoneEvent) self._enterWaitForSetZoneResponseMsg = self.quietZoneStateData.getEnterWaitForSetZoneResponseMsg() self.acceptOnce(self._enterWaitForSetZoneResponseMsg, self.handleWaitForSetZoneResponse) self._quietZoneLeftEvent = self.quietZoneStateData.getQuietZoneLeftEvent() if base.placeBeforeObjects: self.acceptOnce(self._quietZoneLeftEvent, self.handleLeftQuietZone) self.quietZoneStateData.load() self.quietZoneStateData.enter(requestStatus)
def _placeTeleportInPostZoneComplete(self, requestStatus): teleportDebug(requestStatus, '_placeTeleportInPostZoneComplete(%s)' % (requestStatus,)) NametagGlobals.setMasterArrowsOn(0) base.localAvatar.laffMeter.start() base.localAvatar.startQuestMap() base.localAvatar.reconsiderCheesyEffect() base.localAvatar.obscureMoveFurnitureButton(1) avId = requestStatus.get('avId', -1) if avId != -1: def doTeleport(avId, teleported): if avId in base.cr.doId2do: teleportDebug(requestStatus, 'teleport to avatar') avatar = base.cr.doId2do[avId] avatar.forceToTruePosition() base.localAvatar.gotoNode(avatar) base.localAvatar.b_teleportGreeting(avId) else: friend = base.cr.identifyAvatar(avId) if friend is not None: # The avatar might be in another zone or not generated yet. if not teleported: # Try again one more time. teleportDebug(requestStatus, 'Retrying teleport...') taskMgr.doMethodLater(0.2, doTeleport, uniqueName('doTeleport'), extraArgs=[avId, True]) return teleportDebug(requestStatus, 'friend not here, giving up') base.localAvatar.setSystemMessage(avId, OTPLocalizer.WhisperTargetLeftVisit % (friend.getName(),)) friend.d_teleportGiveup(base.localAvatar.doId) taskMgr.doMethodLater(0.3, doTeleport, uniqueName('doTeleport'), extraArgs=[avId, False]) base.transitions.irisIn() self.nextState = requestStatus.get('nextState', 'walk') base.localAvatar.attachCamera() base.localAvatar.startUpdateSmartCamera() base.localAvatar.startPosHprBroadcast() globalClock.tick() base.localAvatar.b_setAnimState('TeleportIn', 1, callback=self.teleportInDone) base.localAvatar.d_broadcastPositionNow() base.localAvatar.b_setParent(ToontownGlobals.SPRender) return
def enterQuietZone(self, requestStatus): teleportDebug(requestStatus, 'Hood.enterQuietZone: status=%s' % requestStatus) self._quietZoneDoneEvent = uniqueName('quietZoneDone') self.acceptOnce(self._quietZoneDoneEvent, self.handleQuietZoneDone) self.quietZoneStateData = QuietZoneState.QuietZoneState( self._quietZoneDoneEvent) self._enterWaitForSetZoneResponseMsg = self.quietZoneStateData.getEnterWaitForSetZoneResponseMsg( ) self.acceptOnce(self._enterWaitForSetZoneResponseMsg, self.handleWaitForSetZoneResponse) self._quietZoneLeftEvent = self.quietZoneStateData.getQuietZoneLeftEvent( ) if base.placeBeforeObjects: self.acceptOnce(self._quietZoneLeftEvent, self.handleLeftQuietZone) self.quietZoneStateData.load() self.quietZoneStateData.enter(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 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 doTeleport(avId, teleported): if avId in base.cr.doId2do: teleportDebug(requestStatus, 'teleport to avatar') avatar = base.cr.doId2do[avId] avatar.forceToTruePosition() base.localAvatar.gotoNode(avatar) base.localAvatar.b_teleportGreeting(avId) else: friend = base.cr.identifyAvatar(avId) if friend is not None: # The avatar might be in another zone or not generated yet. if not teleported: # Try again one more time. teleportDebug(requestStatus, 'Retrying teleport...') taskMgr.doMethodLater(0.2, doTeleport, uniqueName('doTeleport'), extraArgs=[avId, True]) return teleportDebug(requestStatus, 'friend not here, giving up') base.localAvatar.setSystemMessage( avId, OTPLocalizer.WhisperTargetLeftVisit % (friend.getName(), )) friend.d_teleportGiveup(base.localAvatar.doId)
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 handleSafeZoneLoaderDone(self): doneStatus = self.loader.getDoneStatus() teleportDebug(doneStatus, 'handleSafeZoneLoaderDone, doneStatus=%s' % doneStatus) if self.isSameHood(doneStatus) and doneStatus['where'] != 'party' or doneStatus['loader'] == 'minigame': teleportDebug(doneStatus, 'same hood') self.fsm.request('quietZone', [doneStatus]) else: teleportDebug(doneStatus, 'different hood') self.doneStatus = doneStatus messenger.send(self.doneEvent)
def handleTownLoaderDone(self): doneStatus = self.loader.getDoneStatus() teleportDebug(doneStatus, 'handleTownLoaderDone, doneStatus=%s' % (doneStatus,)) if self.isSameHood(doneStatus): teleportDebug(doneStatus, 'same hood') self.fsm.request('quietZone', [doneStatus]) else: teleportDebug(doneStatus, 'different hood') self.doneStatus = doneStatus messenger.send(self.doneEvent)
def handlePlaygroundDone(self): status = self.place.doneStatus teleportDebug(status, 'handlePlaygroundDone, doneStatus=%s' % (status,)) if ZoneUtil.getBranchZone(status['zoneId']) == self.hood.hoodId and status['shardId'] == None: teleportDebug(status, 'same branch') self.fsm.request('quietZone', [status]) else: self.doneStatus = status teleportDebug(status, 'different hood') messenger.send(self.doneEvent) return
def handleTownLoaderDone(self): doneStatus = self.loader.getDoneStatus() teleportDebug(doneStatus, 'handleTownLoaderDone, doneStatus=%s' % (doneStatus, )) if self.isSameHood(doneStatus): teleportDebug(doneStatus, 'same hood') self.fsm.request('quietZone', [doneStatus]) else: teleportDebug(doneStatus, 'different hood') self.doneStatus = doneStatus messenger.send(self.doneEvent)
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 handleSafeZoneLoaderDone(self): doneStatus = self.loader.getDoneStatus() teleportDebug(doneStatus, 'handleSafeZoneLoaderDone, doneStatus=%s' % doneStatus) if self.isSameHood(doneStatus) and doneStatus[ 'where'] != 'party' or doneStatus['loader'] == 'minigame': teleportDebug(doneStatus, 'same hood') self.fsm.request('quietZone', [doneStatus]) else: teleportDebug(doneStatus, 'different hood') self.doneStatus = doneStatus messenger.send(self.doneEvent)
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 handlePlaygroundDone(self): status = self.place.doneStatus teleportDebug(status, 'handlePlaygroundDone, doneStatus=%s' % (status, )) if ZoneUtil.getBranchZone( status['zoneId'] ) == self.hood.hoodId and status['shardId'] == None: teleportDebug(status, 'same branch') self.fsm.request('quietZone', [status]) else: self.doneStatus = status teleportDebug(status, 'different hood') messenger.send(self.doneEvent) return
def doTeleport(avId, teleported): if avId in base.cr.doId2do: teleportDebug(requestStatus, 'teleport to avatar') avatar = base.cr.doId2do[avId] avatar.forceToTruePosition() base.localAvatar.gotoNode(avatar) base.localAvatar.b_teleportGreeting(avId) else: friend = base.cr.identifyAvatar(avId) if friend is not None: # The avatar might be in another zone or not generated yet. if not teleported: # Try again one more time. teleportDebug(requestStatus, 'Retrying teleport...') taskMgr.doMethodLater(0.2, doTeleport, uniqueName('doTeleport'), extraArgs=[avId, True]) return teleportDebug(requestStatus, 'friend not here, giving up') base.localAvatar.setSystemMessage(avId, OTPLocalizer.WhisperTargetLeftVisit % (friend.getName(),)) friend.d_teleportGiveup(base.localAvatar.doId)
def requestLeave(self, requestStatus): teleportDebug(requestStatus, 'requestLeave(%s)' % (requestStatus,)) if hasattr(self, 'fsm'): self.doRequestLeave(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 enterTownLoader(self, requestStatus): teleportDebug(requestStatus, 'ToonHood.enterTownLoader, status=%s' % (requestStatus,)) self.accept(self.loaderDoneEvent, self.handleTownLoaderDone) self.loader.enter(requestStatus) self.spawnTitleText(requestStatus['zoneId'])
def enter(self, requestStatus): teleportDebug(requestStatus, 'TownLoader.enter(%s)' % requestStatus) self.fsm.enterInitialState() teleportDebug(requestStatus, 'setting state: %s' % requestStatus['where']) self.setState(requestStatus['where'], requestStatus)
def handleLeftQuietZone(self): status = self.quietZoneStateData.getRequestStatus() teleportDebug(status, 'handleLeftQuietZone, status=%s' % status) teleportDebug(status, 'requesting %s' % status['loader']) self.fsm.request(status['loader'], [status])
def requestLeave(self, requestStatus): teleportDebug(requestStatus, 'requestLeave(%s)' % (requestStatus, )) if hasattr(self, 'fsm'): self.doRequestLeave(requestStatus)