oldschool-toontown/toontown/safezone/Playground.py

674 lines
27 KiB
Python
Raw Normal View History

2023-04-28 20:51:00 -05:00
from panda3d.core import LineSegs, NodePath, TextNode, Vec4
from panda3d.otp import NametagGlobals
from direct.directnotify.DirectNotifyGlobal import directNotify
from direct.fsm.ClassicFSM import ClassicFSM
from direct.fsm.State import State
from direct.gui.DirectLabel import DirectLabel
from direct.interval.IntervalGlobal import Func, LerpColorScaleInterval, Sequence
from direct.showbase.MessengerGlobal import messenger
2019-11-02 17:27:54 -05:00
from otp.distributed.TelemetryLimiter import RotationLimitToH, TLGatherAllAvs
2023-04-28 20:51:00 -05:00
from toontown.classicchars import CCharPaths
from toontown.hood.Place import Place
2019-11-02 17:27:54 -05:00
from toontown.quest import Quests
2023-04-28 20:51:00 -05:00
from toontown.toon.DeathForceAcknowledge import DeathForceAcknowledge
from toontown.toon.HealthForceAcknowledge import HealthForceAcknowledge
from toontown.toon.NPCForceAcknowledge import NPCForceAcknowledge
from toontown.toon.Toon import teleportDebug
from toontown.toonbase import ToontownGlobals
from toontown.toonbase import TTLocalizer
from toontown.toonbase.ToonBaseGlobal import base
from toontown.toontowngui import TTDialog
from toontown.trolley.Trolley import Trolley
from toontown.tutorial.TutorialForceAcknowledge import TutorialForceAcknowledge
2019-11-02 17:27:54 -05:00
2023-04-28 20:51:00 -05:00
class Playground(Place):
notify = directNotify.newCategory('Playground')
2019-11-02 17:27:54 -05:00
def __init__(self, loader, parentFSM, doneEvent):
2023-04-28 20:51:00 -05:00
Place.__init__(self, loader, doneEvent)
2019-11-02 17:27:54 -05:00
self.tfaDoneEvent = 'tfaDoneEvent'
2023-04-28 20:51:00 -05:00
self.fsm = ClassicFSM('Playground', [
State('start',
2019-11-02 17:27:54 -05:00
self.enterStart,
self.exitStart, [
'walk',
'deathAck',
'doorIn',
'tunnelIn']),
2023-04-28 20:51:00 -05:00
State('walk',
2019-11-02 17:27:54 -05:00
self.enterWalk,
self.exitWalk, [
'drive',
'sit',
'stickerBook',
'TFA',
'DFA',
'trialerFA',
'trolley',
'final',
'doorOut',
'options',
'quest',
'purchase',
'stopped',
'fishing']),
2023-04-28 20:51:00 -05:00
State('stickerBook',
2019-11-02 17:27:54 -05:00
self.enterStickerBook,
self.exitStickerBook, [
'walk',
'DFA',
'TFA',
'trolley',
'final',
'doorOut',
'quest',
'purchase',
'stopped',
'fishing',
'trialerFA']),
2023-04-28 20:51:00 -05:00
State('sit',
2019-11-02 17:27:54 -05:00
self.enterSit,
self.exitSit, [
'walk',
'DFA',
'trialerFA']),
2023-04-28 20:51:00 -05:00
State('drive',
2019-11-02 17:27:54 -05:00
self.enterDrive,
self.exitDrive, [
'walk',
'DFA',
'trialerFA']),
2023-04-28 20:51:00 -05:00
State('trolley',
2019-11-02 17:27:54 -05:00
self.enterTrolley,
self.exitTrolley, [
'walk']),
2023-04-28 20:51:00 -05:00
State('doorIn',
2019-11-02 17:27:54 -05:00
self.enterDoorIn,
self.exitDoorIn, [
'walk']),
2023-04-28 20:51:00 -05:00
State('doorOut',
2019-11-02 17:27:54 -05:00
self.enterDoorOut,
self.exitDoorOut, [
'walk']),
2023-04-28 20:51:00 -05:00
State('TFA',
2019-11-02 17:27:54 -05:00
self.enterTFA,
self.exitTFA, [
'TFAReject',
'DFA']),
2023-04-28 20:51:00 -05:00
State('TFAReject',
2019-11-02 17:27:54 -05:00
self.enterTFAReject,
self.exitTFAReject, [
'walk']),
2023-04-28 20:51:00 -05:00
State('trialerFA',
2019-11-02 17:27:54 -05:00
self.enterTrialerFA,
self.exitTrialerFA, [
'trialerFAReject',
'DFA']),
2023-04-28 20:51:00 -05:00
State('trialerFAReject',
2019-11-02 17:27:54 -05:00
self.enterTrialerFAReject,
self.exitTrialerFAReject, [
'walk']),
2023-04-28 20:51:00 -05:00
State('DFA',
2019-11-02 17:27:54 -05:00
self.enterDFA,
self.exitDFA, [
'DFAReject',
'NPCFA',
'HFA']),
2023-04-28 20:51:00 -05:00
State('DFAReject',
2019-11-02 17:27:54 -05:00
self.enterDFAReject,
self.exitDFAReject, [
'walk']),
2023-04-28 20:51:00 -05:00
State('NPCFA',
2019-11-02 17:27:54 -05:00
self.enterNPCFA,
self.exitNPCFA, [
'NPCFAReject',
'HFA']),
2023-04-28 20:51:00 -05:00
State('NPCFAReject',
2019-11-02 17:27:54 -05:00
self.enterNPCFAReject,
self.exitNPCFAReject, [
'walk']),
2023-04-28 20:51:00 -05:00
State('HFA',
2019-11-02 17:27:54 -05:00
self.enterHFA,
self.exitHFA, [
'HFAReject',
'teleportOut',
'tunnelOut']),
2023-04-28 20:51:00 -05:00
State('HFAReject',
2019-11-02 17:27:54 -05:00
self.enterHFAReject,
self.exitHFAReject, [
'walk']),
2023-04-28 20:51:00 -05:00
State('deathAck',
2019-11-02 17:27:54 -05:00
self.enterDeathAck,
self.exitDeathAck, [
'teleportIn']),
2023-04-28 20:51:00 -05:00
State('teleportIn',
2019-11-02 17:27:54 -05:00
self.enterTeleportIn,
self.exitTeleportIn, [
'walk',
'popup']),
2023-04-28 20:51:00 -05:00
State('popup',
2019-11-02 17:27:54 -05:00
self.enterPopup,
self.exitPopup, [
'walk']),
2023-04-28 20:51:00 -05:00
State('teleportOut',
2019-11-02 17:27:54 -05:00
self.enterTeleportOut,
self.exitTeleportOut, [
'deathAck',
'teleportIn']),
2023-04-28 20:51:00 -05:00
State('died',
2019-11-02 17:27:54 -05:00
self.enterDied,
self.exitDied, [
'final']),
2023-04-28 20:51:00 -05:00
State('tunnelIn',
2019-11-02 17:27:54 -05:00
self.enterTunnelIn,
self.exitTunnelIn, [
'walk']),
2023-04-28 20:51:00 -05:00
State('tunnelOut',
2019-11-02 17:27:54 -05:00
self.enterTunnelOut,
self.exitTunnelOut, [
'final']),
2023-04-28 20:51:00 -05:00
State('quest',
2019-11-02 17:27:54 -05:00
self.enterQuest,
self.exitQuest, [
'walk']),
2023-04-28 20:51:00 -05:00
State('purchase',
2019-11-02 17:27:54 -05:00
self.enterPurchase,
self.exitPurchase, [
'walk']),
2023-04-28 20:51:00 -05:00
State('stopped',
2019-11-02 17:27:54 -05:00
self.enterStopped,
self.exitStopped, [
'walk']),
2023-04-28 20:51:00 -05:00
State('fishing',
2019-11-02 17:27:54 -05:00
self.enterFishing,
self.exitFishing, [
'walk']),
2023-04-28 20:51:00 -05:00
State('final',
2019-11-02 17:27:54 -05:00
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
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)
2023-04-28 20:51:00 -05:00
self.loader.geom.reparentTo(base.render)
2019-11-02 17:27:54 -05:00
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()
2023-04-28 20:51:00 -05:00
2019-11-02 17:27:54 -05:00
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'
2023-04-28 20:51:00 -05:00
2019-11-02 17:27:54 -05:00
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
2023-04-28 20:51:00 -05:00
self.loader.geom.reparentTo(base.hidden)
2019-11-02 17:27:54 -05:00
def __lightDecorationOff__():
for light in self.loader.hood.halloweenLights:
2023-04-28 20:51:00 -05:00
light.reparentTo(base.hidden)
2019-11-02 17:27:54 -05:00
NametagGlobals.setMasterArrowsOn(0)
for i in self.loader.nodeList:
self.loader.exitAnimatedProps(i)
self.loader.hood.stopSky()
self.loader.music.stop()
def load(self):
2023-04-28 20:51:00 -05:00
Place.load(self)
2019-11-02 17:27:54 -05:00
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
2023-04-28 20:51:00 -05:00
2019-11-02 17:27:54 -05:00
if self.deathAckBox:
self.deathAckBox.cleanup()
self.deathAckBox = None
2023-04-28 20:51:00 -05:00
2019-11-02 17:27:54 -05:00
TTDialog.cleanupDialog('globalDialog')
self.ignoreAll()
2023-04-28 20:51:00 -05:00
Place.unload(self)
2019-11-02 17:27:54 -05:00
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)
for name, pointDef in list(paths.items()):
2019-11-02 17:27:54 -05:00
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())
2023-04-28 20:51:00 -05:00
2019-11-02 17:27:54 -05:00
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)
2023-04-28 20:51:00 -05:00
self.trolley = Trolley(self, self.fsm, self.trolleyDoneEvent)
2019-11-02 17:27:54 -05:00
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')
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)
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: ' + repr(doneStatus))
2019-11-02 17:27:54 -05:00
def enterHFA(self, requestStatus):
self.acceptOnce(self.hfaDoneEvent, self.enterHFACallback, [requestStatus])
2023-04-28 20:51:00 -05:00
self.hfa = HealthForceAcknowledge(self.hfaDoneEvent)
2019-11-02 17:27:54 -05:00
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'}
2023-04-28 20:51:00 -05:00
2019-11-02 17:27:54 -05:00
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))
2019-11-02 17:27:54 -05:00
def enterHFAReject(self):
self.fsm.request('walk')
def exitHFAReject(self):
pass
def enterNPCFA(self, requestStatus):
self.acceptOnce(self.npcfaDoneEvent, self.enterNPCFACallback, [requestStatus])
2023-04-28 20:51:00 -05:00
self.npcfa = NPCForceAcknowledge(self.npcfaDoneEvent)
2019-11-02 17:27:54 -05:00
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: ' + repr(doneStatus))
2019-11-02 17:27:54 -05:00
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
2023-04-28 20:51:00 -05:00
Place.enterWalk(self, teleportIn)
2019-11-02 17:27:54 -05:00
def enterDeathAck(self, requestStatus):
self.deathAckBox = None
self.fsm.request('teleportIn', [requestStatus])
def exitDeathAck(self):
if self.deathAckBox:
self.ignore('deathAck')
self.deathAckBox.cleanup()
self.deathAckBox = None
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])
2023-04-28 20:51:00 -05:00
self.deathAckBox = DeathForceAcknowledge(doneEvent='deathAck')
2019-11-02 17:27:54 -05:00
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'
2023-04-28 20:51:00 -05:00
imageModel = base.loader.loadModel('phase_4/models/gui/tfa_images')
2019-11-02 17:27:54 -05:00
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
2023-04-28 20:51:00 -05:00
gui = base.loader.loadModel('phase_3.5/models/gui/friendslist_gui')
2019-11-02 17:27:54 -05:00
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
2023-04-28 20:51:00 -05:00
2019-11-02 17:27:54 -05:00
self.dialog = TTDialog.TTDialog(text=msg, command=self.__cleanupDialog, style=TTDialog.Acknowledge)
2023-04-28 20:51:00 -05:00
imgLabel = DirectLabel(parent=self.dialog, relief=None, pos=imgPos, scale=TTLocalizer.PimgLabel, image=imgNodePath, image_scale=imgScale)
2019-11-02 17:27:54 -05:00
imageModel.removeNode()
else:
requestStatus['nextState'] = 'walk'
x, y, z, h, p, r = base.cr.hoodMgr.getPlaygroundCenterFromId(self.loader.hood.id)
2023-04-28 20:51:00 -05:00
2019-11-02 17:27:54 -05:00
base.localAvatar.detachNode()
2023-04-28 20:51:00 -05:00
base.localAvatar.setPosHpr(base.render, x, y, z, h, p, r)
Place.enterTeleportIn(self, requestStatus)
2019-11-02 17:27:54 -05:00
def __cleanupDialog(self, value):
if self.dialog:
self.dialog.cleanup()
self.dialog = None
2023-04-28 20:51:00 -05:00
2019-11-02 17:27:54 -05:00
if hasattr(self, 'fsm'):
self.fsm.request('walk', [1])
def __handleDeathAck(self, requestStatus):
if self.deathAckBox:
self.ignore('deathAck')
self.deathAckBox.cleanup()
self.deathAckBox = None
2023-04-28 20:51:00 -05:00
2019-11-02 17:27:54 -05:00
self.fsm.request('walk', [1])
def enterPopup(self, teleportIn = 0):
if base.localAvatar.hp < 1:
base.localAvatar.b_setAnimState('Sad', 1)
else:
base.localAvatar.b_setAnimState('neutral', 1.0)
2023-04-28 20:51:00 -05:00
2019-11-02 17:27:54 -05:00
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()
2023-04-28 20:51:00 -05:00
return task.done
2019-11-02 17:27:54 -05:00
def enterTeleportOut(self, requestStatus):
2023-04-28 20:51:00 -05:00
Place.enterTeleportOut(self, requestStatus, self.__teleportOutDone)
2019-11-02 17:27:54 -05:00
def __teleportOutDone(self, requestStatus):
teleportDebug(requestStatus, 'Playground.__teleportOutDone(%s)' % (requestStatus,))
if hasattr(self, 'activityFsm'):
self.activityFsm.requestFinalState()
2023-04-28 20:51:00 -05:00
2019-11-02 17:27:54 -05:00
hoodId = requestStatus['hoodId']
zoneId = requestStatus['zoneId']
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)
def exitTeleportOut(self):
2023-04-28 20:51:00 -05:00
Place.exitTeleportOut(self)
2019-11-02 17:27:54 -05:00
def createPlayground(self, dnaFile):
2023-04-28 20:51:00 -05:00
base.loader.loadDNAFile(self.loader.dnaStore, self.safeZoneStorageDNAFile)
node = base.loader.loadDNAFile(self.loader.dnaStore, dnaFile)
2019-11-02 17:27:54 -05:00
if node.getNumParents() == 1:
self.geom = NodePath(node.getParent(0))
2023-04-28 20:51:00 -05:00
self.geom.reparentTo(base.hidden)
2019-11-02 17:27:54 -05:00
else:
2023-04-28 20:51:00 -05:00
self.geom = base.hidden.attachNewNode(node)
2019-11-02 17:27:54 -05:00
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)
groupNode = self.geom.find('**/' + groupFullName)
if groupNode.isEmpty():
self.notify.error('Could not find visgroup')
2023-04-28 20:51:00 -05:00
2019-11-02 17:27:54 -05:00
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])
2023-04-28 20:51:00 -05:00
self.tfa = TutorialForceAcknowledge(self.tfaDoneEvent)
2019-11-02 17:27:54 -05:00
self.tfa.enter()
def exitTFA(self):
self.ignore(self.tfaDoneEvent)
def enterTFAReject(self):
self.fsm.request('walk')
def exitTFAReject(self):
pass