more cleanup, game will crash

This commit is contained in:
Open Toontown 2023-04-24 00:12:43 -04:00
parent 327fb57e61
commit 1e4a7495d2
5 changed files with 147 additions and 102 deletions

View file

@ -1,31 +1,33 @@
from panda3d.core import * from panda3d.core import ModelPool, TexturePool
from toontown.toonbase.ToonBaseGlobal import * from panda3d.otp import NametagGlobals
from direct.directnotify import DirectNotifyGlobal
from toontown.hood import Place
from toontown.hood import ZoneUtil
from direct.showbase import DirectObject
from direct.fsm import StateData
from direct.fsm import ClassicFSM, State
from direct.fsm import State
from direct.task import Task
from otp.distributed.TelemetryLimiter import RotationLimitToH, TLGatherAllAvs
from toontown.toonbase import ToontownGlobals
from toontown.toonbase import TTLocalizer
from toontown.toon import NPCForceAcknowledge
from toontown.toon import HealthForceAcknowledge
class ToonInterior(Place.Place): from direct.directnotify.DirectNotifyGlobal import directNotify
notify = DirectNotifyGlobal.directNotify.newCategory('ToonInterior') from direct.fsm.ClassicFSM import ClassicFSM
from direct.fsm.State import State
from direct.showbase.MessengerGlobal import messenger
from otp.distributed.TelemetryLimiter import RotationLimitToH, TLGatherAllAvs
from toontown.hood import ZoneUtil
from toontown.hood.Place import Place
from toontown.toon.HealthForceAcknowledge import HealthForceAcknowledge
from toontown.toon.NPCForceAcknowledge import NPCForceAcknowledge
from toontown.toonbase import ToontownGlobals
from toontown.toonbase.ToonBaseGlobal import base
class ToonInterior(Place):
notify = directNotify.newCategory('ToonInterior')
def __init__(self, loader, parentFSMState, doneEvent): def __init__(self, loader, parentFSMState, doneEvent):
Place.Place.__init__(self, loader, doneEvent) Place.__init__(self, loader, doneEvent)
self.dnaFile = 'phase_7/models/modules/toon_interior' self.dnaFile = 'phase_7/models/modules/toon_interior'
self.isInterior = 1 self.isInterior = 1
self.tfaDoneEvent = 'tfaDoneEvent' self.tfaDoneEvent = 'tfaDoneEvent'
self.hfaDoneEvent = 'hfaDoneEvent' self.hfaDoneEvent = 'hfaDoneEvent'
self.npcfaDoneEvent = 'npcfaDoneEvent' self.npcfaDoneEvent = 'npcfaDoneEvent'
self.fsm = ClassicFSM.ClassicFSM('ToonInterior', [State.State('start', self.enterStart, self.exitStart, ['doorIn', 'teleportIn', 'tutorial']), self.fsm = ClassicFSM('ToonInterior', [State('start', self.enterStart, self.exitStart, ['doorIn', 'teleportIn', 'tutorial']),
State.State('walk', self.enterWalk, self.exitWalk, ['sit', State('walk', self.enterWalk, self.exitWalk, ['sit',
'stickerBook', 'stickerBook',
'doorOut', 'doorOut',
'DFA', 'DFA',
@ -36,8 +38,8 @@ class ToonInterior(Place.Place):
'phone', 'phone',
'stopped', 'stopped',
'pet']), 'pet']),
State.State('sit', self.enterSit, self.exitSit, ['walk']), State('sit', self.enterSit, self.exitSit, ['walk']),
State.State('stickerBook', self.enterStickerBook, self.exitStickerBook, ['walk', State('stickerBook', self.enterStickerBook, self.exitStickerBook, ['walk',
'DFA', 'DFA',
'trialerFA', 'trialerFA',
'sit', 'sit',
@ -48,37 +50,37 @@ class ToonInterior(Place.Place):
'phone', 'phone',
'stopped', 'stopped',
'pet']), 'pet']),
State.State('trialerFA', self.enterTrialerFA, self.exitTrialerFA, ['trialerFAReject', 'DFA']), State('trialerFA', self.enterTrialerFA, self.exitTrialerFA, ['trialerFAReject', 'DFA']),
State.State('trialerFAReject', self.enterTrialerFAReject, self.exitTrialerFAReject, ['walk']), State('trialerFAReject', self.enterTrialerFAReject, self.exitTrialerFAReject, ['walk']),
State.State('DFA', self.enterDFA, self.exitDFA, ['DFAReject', State('DFA', self.enterDFA, self.exitDFA, ['DFAReject',
'HFA', 'HFA',
'NPCFA', 'NPCFA',
'teleportOut', 'teleportOut',
'doorOut']), 'doorOut']),
State.State('DFAReject', self.enterDFAReject, self.exitDFAReject, ['walk']), State('DFAReject', self.enterDFAReject, self.exitDFAReject, ['walk']),
State.State('NPCFA', self.enterNPCFA, self.exitNPCFA, ['NPCFAReject', 'HFA', 'teleportOut']), State('NPCFA', self.enterNPCFA, self.exitNPCFA, ['NPCFAReject', 'HFA', 'teleportOut']),
State.State('NPCFAReject', self.enterNPCFAReject, self.exitNPCFAReject, ['walk']), State('NPCFAReject', self.enterNPCFAReject, self.exitNPCFAReject, ['walk']),
State.State('HFA', self.enterHFA, self.exitHFA, ['HFAReject', 'teleportOut', 'tunnelOut']), State('HFA', self.enterHFA, self.exitHFA, ['HFAReject', 'teleportOut', 'tunnelOut']),
State.State('HFAReject', self.enterHFAReject, self.exitHFAReject, ['walk']), State('HFAReject', self.enterHFAReject, self.exitHFAReject, ['walk']),
State.State('doorIn', self.enterDoorIn, self.exitDoorIn, ['walk']), State('doorIn', self.enterDoorIn, self.exitDoorIn, ['walk']),
State.State('doorOut', self.enterDoorOut, self.exitDoorOut, ['walk', 'stopped']), State('doorOut', self.enterDoorOut, self.exitDoorOut, ['walk', 'stopped']),
State.State('teleportIn', self.enterTeleportIn, self.exitTeleportIn, ['walk']), State('teleportIn', self.enterTeleportIn, self.exitTeleportIn, ['walk']),
State.State('teleportOut', self.enterTeleportOut, self.exitTeleportOut, ['teleportIn']), State('teleportOut', self.enterTeleportOut, self.exitTeleportOut, ['teleportIn']),
State.State('quest', self.enterQuest, self.exitQuest, ['walk', 'doorOut']), State('quest', self.enterQuest, self.exitQuest, ['walk', 'doorOut']),
State.State('tutorial', self.enterTutorial, self.exitTutorial, ['walk', 'quest']), State('tutorial', self.enterTutorial, self.exitTutorial, ['walk', 'quest']),
State.State('purchase', self.enterPurchase, self.exitPurchase, ['walk', 'doorOut']), State('purchase', self.enterPurchase, self.exitPurchase, ['walk', 'doorOut']),
State.State('pet', self.enterPet, self.exitPet, ['walk']), State('pet', self.enterPet, self.exitPet, ['walk']),
State.State('phone', self.enterPhone, self.exitPhone, ['walk', 'doorOut']), State('phone', self.enterPhone, self.exitPhone, ['walk', 'doorOut']),
State.State('stopped', self.enterStopped, self.exitStopped, ['walk', 'doorOut']), State('stopped', self.enterStopped, self.exitStopped, ['walk', 'doorOut']),
State.State('final', self.enterFinal, self.exitFinal, ['start'])], 'start', 'final') State('final', self.enterFinal, self.exitFinal, ['start'])], 'start', 'final')
self.parentFSMState = parentFSMState self.parentFSMState = parentFSMState
def load(self): def load(self):
Place.Place.load(self) Place.load(self)
self.parentFSMState.addChild(self.fsm) self.parentFSMState.addChild(self.fsm)
def unload(self): def unload(self):
Place.Place.unload(self) Place.unload(self)
self.parentFSMState.removeChild(self.fsm) self.parentFSMState.removeChild(self.fsm)
del self.parentFSMState del self.parentFSMState
del self.fsm del self.fsm
@ -111,7 +113,7 @@ class ToonInterior(Place.Place):
def enterTutorial(self, requestStatus): def enterTutorial(self, requestStatus):
self.fsm.request('walk') self.fsm.request('walk')
base.localAvatar.b_setParent(ToontownGlobals.SPRender) base.localAvatar.b_setParent(ToontownGlobals.SPRender)
globalClock.tick() base.clock.tick()
base.transitions.irisIn() base.transitions.irisIn()
messenger.send('enterTutorialInterior') messenger.send('enterTutorialInterior')
@ -134,7 +136,7 @@ class ToonInterior(Place.Place):
def enterNPCFA(self, requestStatus): def enterNPCFA(self, requestStatus):
self.acceptOnce(self.npcfaDoneEvent, self.enterNPCFACallback, [requestStatus]) self.acceptOnce(self.npcfaDoneEvent, self.enterNPCFACallback, [requestStatus])
self.npcfa = NPCForceAcknowledge.NPCForceAcknowledge(self.npcfaDoneEvent) self.npcfa = NPCForceAcknowledge(self.npcfaDoneEvent)
self.npcfa.enter() self.npcfa.enter()
def exitNPCFA(self): def exitNPCFA(self):
@ -161,7 +163,7 @@ class ToonInterior(Place.Place):
def enterHFA(self, requestStatus): def enterHFA(self, requestStatus):
self.acceptOnce(self.hfaDoneEvent, self.enterHFACallback, [requestStatus]) self.acceptOnce(self.hfaDoneEvent, self.enterHFACallback, [requestStatus])
self.hfa = HealthForceAcknowledge.HealthForceAcknowledge(self.hfaDoneEvent) self.hfa = HealthForceAcknowledge(self.hfaDoneEvent)
self.hfa.enter(1) self.hfa.enter(1)
def exitHFA(self): def exitHFA(self):
@ -191,10 +193,11 @@ class ToonInterior(Place.Place):
base.localAvatar.setPosHpr(0, 0, ToontownGlobals.FloorOffset, 45.0, 0.0, 0.0) base.localAvatar.setPosHpr(0, 0, ToontownGlobals.FloorOffset, 45.0, 0.0, 0.0)
else: else:
base.localAvatar.setPosHpr(2.5, 11.5, ToontownGlobals.FloorOffset, 45.0, 0.0, 0.0) base.localAvatar.setPosHpr(2.5, 11.5, ToontownGlobals.FloorOffset, 45.0, 0.0, 0.0)
Place.Place.enterTeleportIn(self, requestStatus)
Place.enterTeleportIn(self, requestStatus)
def enterTeleportOut(self, requestStatus): def enterTeleportOut(self, requestStatus):
Place.Place.enterTeleportOut(self, requestStatus, self.__teleportOutDone) Place.enterTeleportOut(self, requestStatus, self.__teleportOutDone)
def __teleportOutDone(self, requestStatus): def __teleportOutDone(self, requestStatus):
hoodId = requestStatus['hoodId'] hoodId = requestStatus['hoodId']
@ -207,7 +210,6 @@ class ToonInterior(Place.Place):
else: else:
self.doneStatus = requestStatus self.doneStatus = requestStatus
messenger.send(self.doneEvent) messenger.send(self.doneEvent)
return
def goHomeFailed(self, task): def goHomeFailed(self, task):
self.notifyUserGoHomeFailed() self.notifyUserGoHomeFailed()
@ -215,7 +217,7 @@ class ToonInterior(Place.Place):
self.doneStatus['avId'] = -1 self.doneStatus['avId'] = -1
self.doneStatus['zoneId'] = self.getZoneId() self.doneStatus['zoneId'] = self.getZoneId()
self.fsm.request('teleportIn', [self.doneStatus]) self.fsm.request('teleportIn', [self.doneStatus])
return Task.done return task.done
def exitTeleportOut(self): def exitTeleportOut(self):
Place.Place.exitTeleportOut(self) Place.exitTeleportOut(self)

View file

@ -1,24 +1,33 @@
from panda3d.core import * from panda3d.core import (
from toontown.toonbase.ToonBaseGlobal import * CompassEffect,
from toontown.toonbase.ToontownGlobals import * ModelPool,
from toontown.distributed.ToontownMsgTypes import * NodePath,
from direct.directnotify import DirectNotifyGlobal TexturePool,
from direct.fsm import StateData TransparencyAttrib,
from direct.task.Task import Task Vec4
from toontown.minigame import Purchase )
from direct.gui import OnscreenText
from toontown.building import SuitInterior
from . import QuietZoneState
from . import ZoneUtil
from toontown.toonbase import TTLocalizer
from toontown.toon.Toon import teleportDebug
from direct.interval.IntervalGlobal import *
class Hood(StateData.StateData): from direct.directnotify.DirectNotifyGlobal import directNotify
notify = DirectNotifyGlobal.directNotify.newCategory('Hood') from direct.fsm.StateData import StateData
from direct.gui.OnscreenText import OnscreenText
from direct.interval.IntervalGlobal import Sequence, Wait, Func
from direct.showbase.MessengerGlobal import messenger
from direct.showbase.PythonUtil import uniqueName
from direct.task.TaskManagerGlobal import taskMgr
from toontown.hood import ZoneUtil
from toontown.hood.QuietZoneState import QuietZoneState
from toontown.toon.Toon import teleportDebug
from toontown.toonbase import ToontownGlobals
from toontown.toonbase import TTLocalizer
from toontown.toonbase.ToonBaseGlobal import base
class Hood(StateData):
notify = directNotify.newCategory('Hood')
def __init__(self, parentFSM, doneEvent, dnaStore, hoodId): def __init__(self, parentFSM, doneEvent, dnaStore, hoodId):
StateData.StateData.__init__(self, doneEvent) StateData.__init__(self, doneEvent)
self.loader = 'not initialized' self.loader = 'not initialized'
self.parentFSM = parentFSM self.parentFSM = parentFSM
self.dnaStore = dnaStore self.dnaStore = dnaStore
@ -31,21 +40,20 @@ class Hood(StateData.StateData):
self.holidayStorageDNADict = {} self.holidayStorageDNADict = {}
self.spookySkyFile = None self.spookySkyFile = None
self.halloweenLights = [] self.halloweenLights = []
return
def enter(self, requestStatus): def enter(self, requestStatus):
hoodId = requestStatus['hoodId']
zoneId = requestStatus['zoneId'] zoneId = requestStatus['zoneId']
hoodText = self.getHoodText(zoneId) hoodText = self.getHoodText(zoneId)
self.titleText = OnscreenText.OnscreenText(hoodText, fg=self.titleColor, font=getSignFont(), pos=(0, -0.5), scale=TTLocalizer.HtitleText, drawOrder=0, mayChange=1) self.titleText = OnscreenText(hoodText, fg=self.titleColor, font=ToontownGlobals.getSignFont(), pos=(0, -0.5), scale=TTLocalizer.HtitleText, drawOrder=0, mayChange=1)
self.fsm.request(requestStatus['loader'], [requestStatus]) self.fsm.request(requestStatus['loader'], [requestStatus])
def getHoodText(self, zoneId): def getHoodText(self, zoneId):
hoodText = base.cr.hoodMgr.getFullnameFromId(self.id) hoodText = base.cr.hoodMgr.getFullnameFromId(self.id)
if self.id != Tutorial: if self.id != ToontownGlobals.Tutorial:
streetName = StreetNames.get(ZoneUtil.getCanonicalBranchZone(zoneId)) streetName = ToontownGlobals.StreetNames.get(ZoneUtil.getCanonicalBranchZone(zoneId))
if streetName: if streetName:
hoodText = hoodText + '\n' + streetName[-1] hoodText = hoodText + '\n' + streetName[-1]
return hoodText return hoodText
def spawnTitleText(self, zoneId): def spawnTitleText(self, zoneId):
@ -69,32 +77,35 @@ class Hood(StateData.StateData):
if self.titleTextSeq: if self.titleTextSeq:
self.titleTextSeq.finish() self.titleTextSeq.finish()
self.titleTextSeq = None self.titleTextSeq = None
if self.titleText: if self.titleText:
self.titleText.cleanup() self.titleText.cleanup()
self.titleText = None self.titleText = None
base.localAvatar.stopChat() base.localAvatar.stopChat()
return
def load(self): def load(self):
if self.storageDNAFile: if self.storageDNAFile:
loader.loadDNAFile(self.dnaStore, self.storageDNAFile) base.loader.loadDNAFile(self.dnaStore, self.storageDNAFile)
newsManager = base.cr.newsManager newsManager = base.cr.newsManager
if newsManager: if newsManager:
holidayIds = base.cr.newsManager.getDecorationHolidayId() holidayIds = base.cr.newsManager.getDecorationHolidayId()
for holiday in holidayIds: for holiday in holidayIds:
for storageFile in self.holidayStorageDNADict.get(holiday, []): for storageFile in self.holidayStorageDNADict.get(holiday, []):
loader.loadDNAFile(self.dnaStore, storageFile) base.loader.loadDNAFile(self.dnaStore, storageFile)
if ToontownGlobals.HALLOWEEN_COSTUMES not in holidayIds and ToontownGlobals.SPOOKY_COSTUMES not in holidayIds or not self.spookySkyFile: if ToontownGlobals.HALLOWEEN_COSTUMES not in holidayIds and ToontownGlobals.SPOOKY_COSTUMES not in holidayIds or not self.spookySkyFile:
self.sky = loader.loadModel(self.skyFile) self.sky = base.loader.loadModel(self.skyFile)
self.sky.setTag('sky', 'Regular') self.sky.setTag('sky', 'Regular')
self.sky.setScale(1.0) self.sky.setScale(1.0)
self.sky.setFogOff() self.sky.setFogOff()
else: else:
self.sky = loader.loadModel(self.spookySkyFile) self.sky = base.loader.loadModel(self.spookySkyFile)
self.sky.setTag('sky', 'Halloween') self.sky.setTag('sky', 'Halloween')
if not newsManager: if not newsManager:
self.sky = loader.loadModel(self.skyFile) self.sky = base.loader.loadModel(self.skyFile)
self.sky.setTag('sky', 'Regular') self.sky.setTag('sky', 'Regular')
self.sky.setScale(1.0) self.sky.setScale(1.0)
self.sky.setFogOff() self.sky.setFogOff()
@ -105,6 +116,7 @@ class Hood(StateData.StateData):
self.loader.exit() self.loader.exit()
self.loader.unload() self.loader.unload()
del self.loader del self.loader
del self.fsm del self.fsm
del self.parentFSM del self.parentFSM
self.dnaStore.resetHood() self.dnaStore.resetHood()
@ -134,12 +146,13 @@ class Hood(StateData.StateData):
teleportDebug(requestStatus, 'Hood.enterQuietZone: status=%s' % requestStatus) teleportDebug(requestStatus, 'Hood.enterQuietZone: status=%s' % requestStatus)
self._quietZoneDoneEvent = uniqueName('quietZoneDone') self._quietZoneDoneEvent = uniqueName('quietZoneDone')
self.acceptOnce(self._quietZoneDoneEvent, self.handleQuietZoneDone) self.acceptOnce(self._quietZoneDoneEvent, self.handleQuietZoneDone)
self.quietZoneStateData = QuietZoneState.QuietZoneState(self._quietZoneDoneEvent) self.quietZoneStateData = QuietZoneState(self._quietZoneDoneEvent)
self._enterWaitForSetZoneResponseMsg = self.quietZoneStateData.getEnterWaitForSetZoneResponseMsg() self._enterWaitForSetZoneResponseMsg = self.quietZoneStateData.getEnterWaitForSetZoneResponseMsg()
self.acceptOnce(self._enterWaitForSetZoneResponseMsg, self.handleWaitForSetZoneResponse) self.acceptOnce(self._enterWaitForSetZoneResponseMsg, self.handleWaitForSetZoneResponse)
self._quietZoneLeftEvent = self.quietZoneStateData.getQuietZoneLeftEvent() self._quietZoneLeftEvent = self.quietZoneStateData.getQuietZoneLeftEvent()
if base.placeBeforeObjects: if base.placeBeforeObjects:
self.acceptOnce(self._quietZoneLeftEvent, self.handleLeftQuietZone) self.acceptOnce(self._quietZoneLeftEvent, self.handleLeftQuietZone)
self.quietZoneStateData.load() self.quietZoneStateData.load()
self.quietZoneStateData.enter(requestStatus) self.quietZoneStateData.enter(requestStatus)
@ -151,7 +164,6 @@ class Hood(StateData.StateData):
self.quietZoneStateData.exit() self.quietZoneStateData.exit()
self.quietZoneStateData.unload() self.quietZoneStateData.unload()
self.quietZoneStateData = None self.quietZoneStateData = None
return
def loadLoader(self, requestStatus): def loadLoader(self, requestStatus):
pass pass
@ -159,19 +171,21 @@ class Hood(StateData.StateData):
def handleWaitForSetZoneResponse(self, requestStatus): def handleWaitForSetZoneResponse(self, requestStatus):
loaderName = requestStatus['loader'] loaderName = requestStatus['loader']
if loaderName == 'safeZoneLoader': if loaderName == 'safeZoneLoader':
if not loader.inBulkBlock: if not base.loader.inBulkBlock:
loader.beginBulkLoad('hood', TTLocalizer.HeadingToPlayground, safeZoneCountMap[self.id], 1, TTLocalizer.TIP_GENERAL) base.loader.beginBulkLoad('hood', TTLocalizer.HeadingToPlayground, ToontownGlobals.safeZoneCountMap[self.id], 1, TTLocalizer.TIP_GENERAL)
self.loadLoader(requestStatus) self.loadLoader(requestStatus)
loader.endBulkLoad('hood') base.loader.endBulkLoad('hood')
elif loaderName == 'townLoader': elif loaderName == 'townLoader':
if not loader.inBulkBlock: if not base.loader.inBulkBlock:
zoneId = requestStatus['zoneId'] zoneId = requestStatus['zoneId']
toPhrase = StreetNames[ZoneUtil.getCanonicalBranchZone(zoneId)][0] toPhrase = ToontownGlobals.StreetNames[ZoneUtil.getCanonicalBranchZone(zoneId)][0]
streetName = StreetNames[ZoneUtil.getCanonicalBranchZone(zoneId)][-1] streetName = ToontownGlobals.StreetNames[ZoneUtil.getCanonicalBranchZone(zoneId)][-1]
loader.beginBulkLoad('hood', TTLocalizer.HeadingToStreet % {'to': toPhrase, base.loader.beginBulkLoad('hood', TTLocalizer.HeadingToStreet % {'to': toPhrase,
'street': streetName}, townCountMap[self.id], 1, TTLocalizer.TIP_STREET) 'street': streetName}, ToontownGlobals.townCountMap[self.id], 1, TTLocalizer.TIP_STREET)
self.loadLoader(requestStatus) self.loadLoader(requestStatus)
loader.endBulkLoad('hood') base.loader.endBulkLoad('hood')
elif loaderName == 'minigame': elif loaderName == 'minigame':
pass pass
elif loaderName == 'cogHQLoader': elif loaderName == 'cogHQLoader':
@ -197,6 +211,7 @@ class Hood(StateData.StateData):
if self.titleTextSeq: if self.titleTextSeq:
self.titleTextSeq.finish() self.titleTextSeq.finish()
self.titleTextSeq = None self.titleTextSeq = None
self.hideTitleText() self.hideTitleText()
self.ignore(self.loaderDoneEvent) self.ignore(self.loaderDoneEvent)
self.loader.exit() self.loader.exit()
@ -215,7 +230,7 @@ class Hood(StateData.StateData):
messenger.send(self.doneEvent) messenger.send(self.doneEvent)
def startSky(self): def startSky(self):
self.sky.reparentTo(camera) self.sky.reparentTo(base.camera)
self.sky.setZ(0.0) self.sky.setZ(0.0)
self.sky.setHpr(0.0, 0.0, 0.0) self.sky.setHpr(0.0, 0.0, 0.0)
ce = CompassEffect.make(NodePath(), CompassEffect.PRot | CompassEffect.PZ) ce = CompassEffect.make(NodePath(), CompassEffect.PRot | CompassEffect.PZ)
@ -223,17 +238,19 @@ class Hood(StateData.StateData):
def stopSky(self): def stopSky(self):
taskMgr.remove('skyTrack') taskMgr.remove('skyTrack')
self.sky.reparentTo(hidden) self.sky.reparentTo(base.hidden)
def startSpookySky(self): def startSpookySky(self):
if not self.spookySkyFile: if not self.spookySkyFile:
return return
if hasattr(self, 'sky') and self.sky: if hasattr(self, 'sky') and self.sky:
self.stopSky() self.stopSky()
self.sky = loader.loadModel(self.spookySkyFile)
self.sky = base.loader.loadModel(self.spookySkyFile)
self.sky.setTag('sky', 'Halloween') self.sky.setTag('sky', 'Halloween')
self.sky.setColor(0.5, 0.5, 0.5, 1) self.sky.setColor(0.5, 0.5, 0.5, 1)
self.sky.reparentTo(camera) self.sky.reparentTo(base.camera)
self.sky.setTransparency(TransparencyAttrib.MDual, 1) self.sky.setTransparency(TransparencyAttrib.MDual, 1)
fadeIn = self.sky.colorScaleInterval(1.5, Vec4(1, 1, 1, 1), startColorScale=Vec4(1, 1, 1, 0.25), blendType='easeInOut') fadeIn = self.sky.colorScaleInterval(1.5, Vec4(1, 1, 1, 1), startColorScale=Vec4(1, 1, 1, 0.25), blendType='easeInOut')
fadeIn.start() fadeIn.start()
@ -244,9 +261,10 @@ class Hood(StateData.StateData):
def endSpookySky(self): def endSpookySky(self):
if hasattr(self, 'sky') and self.sky: if hasattr(self, 'sky') and self.sky:
self.sky.reparentTo(hidden) self.sky.reparentTo(base.hidden)
if hasattr(self, 'sky'): if hasattr(self, 'sky'):
self.sky = loader.loadModel(self.skyFile) self.sky = base.loader.loadModel(self.skyFile)
self.sky.setTag('sky', 'Regular') self.sky.setTag('sky', 'Regular')
self.sky.setScale(1.0) self.sky.setScale(1.0)
self.startSky() self.startSky()

View file

@ -38,18 +38,17 @@ class OrthoDrive:
self.__placeToonHOG(self.lt.getPos()) self.__placeToonHOG(self.lt.getPos())
taskMgr.add(self.__update, OrthoDrive.TASK_NAME, priority=self.priority) taskMgr.add(self.__update, OrthoDrive.TASK_NAME, priority=self.priority)
self.lastAction = None self.lastAction = None
return
def __placeToonHOG(self, pos, h = None): def __placeToonHOG(self, pos, h = None):
if h == None: if h == None:
h = self.lt.getH() h = self.lt.getH()
self.lt.setPos(pos) self.lt.setPos(pos)
self.lt.setH(h) self.lt.setH(h)
self.lastPos = pos self.lastPos = pos
self.atRestHeading = h self.atRestHeading = h
self.lastXVel = 0 self.lastXVel = 0
self.lastYVel = 0 self.lastYVel = 0
return
def stop(self): def stop(self):
self.notify.debug('stop') self.notify.debug('stop')
@ -59,7 +58,9 @@ class OrthoDrive:
if hasattr(self, 'turnLocalToonIval'): if hasattr(self, 'turnLocalToonIval'):
if self.turnLocalToonIval.isPlaying(): if self.turnLocalToonIval.isPlaying():
self.turnLocalToonIval.pause() self.turnLocalToonIval.pause()
del self.turnLocalToonIval del self.turnLocalToonIval
base.localAvatar.setSpeed(0, 0) base.localAvatar.setSpeed(0, 0)
def __update(self, task): def __update(self, task):
@ -68,12 +69,16 @@ class OrthoDrive:
yVel = 0 yVel = 0
if self.arrowKeys.upPressed(): if self.arrowKeys.upPressed():
yVel += 1 yVel += 1
if self.arrowKeys.downPressed(): if self.arrowKeys.downPressed():
yVel -= 1 yVel -= 1
if self.arrowKeys.leftPressed(): if self.arrowKeys.leftPressed():
xVel -= 1 xVel -= 1
if self.arrowKeys.rightPressed(): if self.arrowKeys.rightPressed():
xVel += 1 xVel += 1
vel.setX(xVel) vel.setX(xVel)
vel.setY(yVel) vel.setY(yVel)
vel.normalize() vel.normalize()
@ -89,8 +94,10 @@ class OrthoDrive:
self.lt.runSound() self.lt.runSound()
else: else:
self.lt.stopSound() self.lt.stopSound()
if self.setHeading: if self.setHeading:
self.__handleHeading(xVel, yVel) self.__handleHeading(xVel, yVel)
toonPos = self.lt.getPos() toonPos = self.lt.getPos()
dt = base.clock.getDt() dt = base.clock.getDt()
posOffset = vel * dt posOffset = vel * dt
@ -101,10 +108,12 @@ class OrthoDrive:
if posOffsetLen > self.maxFrameMove: if posOffsetLen > self.maxFrameMove:
posOffset *= self.maxFrameMove posOffset *= self.maxFrameMove
posOffset /= posOffsetLen posOffset /= posOffsetLen
if self.customCollisionCallback: if self.customCollisionCallback:
toonPos = self.customCollisionCallback(toonPos, toonPos + posOffset) toonPos = self.customCollisionCallback(toonPos, toonPos + posOffset)
else: else:
toonPos = toonPos + posOffset toonPos = toonPos + posOffset
self.lt.setPos(toonPos) self.lt.setPos(toonPos)
self.lastPos = toonPos self.lastPos = toonPos
return task.cont return task.cont
@ -138,6 +147,8 @@ class OrthoDrive:
taskMgr.doMethodLater(0.05, setAtRestHeading, OrthoDrive.SET_ATREST_HEADING_TASK) taskMgr.doMethodLater(0.05, setAtRestHeading, OrthoDrive.SET_ATREST_HEADING_TASK)
else: else:
self.atRestHeading = curHeading self.atRestHeading = curHeading
orientToon(curHeading) orientToon(curHeading)
self.lastXVel = xVel self.lastXVel = xVel
self.lastYVel = yVel self.lastYVel = yVel

View file

@ -33,7 +33,6 @@ class TwoDDrive:
self.ONE_JUMP_PER_UP_PRESSED = True self.ONE_JUMP_PER_UP_PRESSED = True
self.lastAction = None self.lastAction = None
self.isMovingX = False self.isMovingX = False
return
def destroy(self): def destroy(self):
self.game = None self.game = None
@ -43,7 +42,6 @@ class TwoDDrive:
del self.arrowKeys del self.arrowKeys
del self.customCollisionCallback del self.customCollisionCallback
self.lastAction = None self.lastAction = None
return
def start(self): def start(self):
self.notify.debug('start') self.notify.debug('start')
@ -55,6 +53,7 @@ class TwoDDrive:
def __placeToonHOG(self, pos, h = None): def __placeToonHOG(self, pos, h = None):
if h == None: if h == None:
h = self.lt.getH() h = self.lt.getH()
self.lt.setPos(pos) self.lt.setPos(pos)
self.lt.setH(h) self.lt.setH(h)
self.lastPos = pos self.lastPos = pos
@ -62,7 +61,6 @@ class TwoDDrive:
self.oldAtRestHeading = h self.oldAtRestHeading = h
self.lastXVel = 0 self.lastXVel = 0
self.lastYVel = 0 self.lastYVel = 0
return
def stop(self): def stop(self):
self.notify.debug('stop') self.notify.debug('stop')
@ -72,7 +70,9 @@ class TwoDDrive:
if hasattr(self, 'turnLocalToonIval'): if hasattr(self, 'turnLocalToonIval'):
if self.turnLocalToonIval.isPlaying(): if self.turnLocalToonIval.isPlaying():
self.turnLocalToonIval.pause() self.turnLocalToonIval.pause()
del self.turnLocalToonIval del self.turnLocalToonIval
base.localAvatar.setSpeed(0, 0) base.localAvatar.setSpeed(0, 0)
base.localAvatar.stopSound() base.localAvatar.stopSound()
@ -92,10 +92,13 @@ class TwoDDrive:
if not self.game.isHeadInFloor: if not self.game.isHeadInFloor:
if base.localAvatar.controlManager.currentControls == base.localAvatar.controlManager.get('twoD'): if base.localAvatar.controlManager.currentControls == base.localAvatar.controlManager.get('twoD'):
base.localAvatar.controlManager.currentControls.jumpPressed() base.localAvatar.controlManager.currentControls.jumpPressed()
if self.arrowKeys.leftPressed(): if self.arrowKeys.leftPressed():
xVel -= 1 xVel -= 1
if self.arrowKeys.rightPressed(): if self.arrowKeys.rightPressed():
xVel += 1 xVel += 1
vel.setX(xVel) vel.setX(xVel)
vel.setY(yVel) vel.setY(yVel)
vel.normalize() vel.normalize()
@ -107,6 +110,7 @@ class TwoDDrive:
elif self.isMovingX: elif self.isMovingX:
self.isMovingX = False self.isMovingX = False
messenger.send('avatarStoppedX') messenger.send('avatarStoppedX')
speed = vel.length() speed = vel.length()
action = self.lt.setSpeed(speed, 0) action = self.lt.setSpeed(speed, 0)
if action != self.lastAction: if action != self.lastAction:
@ -115,8 +119,10 @@ class TwoDDrive:
base.localAvatar.runSound() base.localAvatar.runSound()
else: else:
base.localAvatar.stopSound() base.localAvatar.stopSound()
if self.setHeading: if self.setHeading:
self.__handleHeading(xVel, yVel) self.__handleHeading(xVel, yVel)
toonPos = self.lt.getPos() toonPos = self.lt.getPos()
dt = base.clock.getDt() dt = base.clock.getDt()
posOffset = vel * dt posOffset = vel * dt
@ -124,6 +130,7 @@ class TwoDDrive:
toonPos = self.customCollisionCallback(toonPos, toonPos + posOffset) toonPos = self.customCollisionCallback(toonPos, toonPos + posOffset)
else: else:
toonPos += posOffset toonPos += posOffset
self.lt.setPos(toonPos) self.lt.setPos(toonPos)
self.lastPos = toonPos self.lastPos = toonPos
return task.cont return task.cont
@ -157,6 +164,8 @@ class TwoDDrive:
taskMgr.doMethodLater(0.05, setAtRestHeading, TwoDDrive.SET_ATREST_HEADING_TASK) taskMgr.doMethodLater(0.05, setAtRestHeading, TwoDDrive.SET_ATREST_HEADING_TASK)
else: else:
self.atRestHeading = curHeading self.atRestHeading = curHeading
orientToon(curHeading) orientToon(curHeading)
self.lastXVel = xVel self.lastXVel = xVel
self.lastYVel = yVel self.lastYVel = yVel

View file

@ -44,6 +44,7 @@ if launcher.isDummy():
http = HTTPClient() http = HTTPClient()
else: else:
http = launcher.http http = launcher.http
tempLoader = Loader() tempLoader = Loader()
backgroundNode = tempLoader.loadSync(Filename('phase_3/models/gui/loading-background')) backgroundNode = tempLoader.loadSync(Filename('phase_3/models/gui/loading-background'))
from direct.gui import DirectGuiGlobals from direct.gui import DirectGuiGlobals
@ -55,6 +56,7 @@ from .ToonBaseGlobal import base
if base.win == None: if base.win == None:
print('Unable to open window; aborting.') print('Unable to open window; aborting.')
sys.exit() sys.exit()
launcher.setPandaErrorCode(0) launcher.setPandaErrorCode(0)
launcher.setPandaWindowOpen() launcher.setPandaWindowOpen()
ConfigVariableDouble('decompressor-step-time').setValue(0.01) ConfigVariableDouble('decompressor-step-time').setValue(0.01)
@ -77,11 +79,13 @@ if base.musicManagerIsValid:
music.setLoop(1) music.setLoop(1)
music.setVolume(0.9) music.setVolume(0.9)
music.play() music.play()
print('ToontownStart: Loading default gui sounds') print('ToontownStart: Loading default gui sounds')
DirectGuiGlobals.setDefaultRolloverSound(base.loader.loadSfx('phase_3/audio/sfx/GUI_rollover.ogg')) DirectGuiGlobals.setDefaultRolloverSound(base.loader.loadSfx('phase_3/audio/sfx/GUI_rollover.ogg'))
DirectGuiGlobals.setDefaultClickSound(base.loader.loadSfx('phase_3/audio/sfx/GUI_create_toon_fwd.ogg')) DirectGuiGlobals.setDefaultClickSound(base.loader.loadSfx('phase_3/audio/sfx/GUI_create_toon_fwd.ogg'))
else: else:
music = None music = None
from direct.gui.DirectGui import OnscreenText from direct.gui.DirectGui import OnscreenText
serverVersion = ConfigVariableString('server-version', 'no_version_set').value serverVersion = ConfigVariableString('server-version', 'no_version_set').value
print('ToontownStart: serverVersion: ', serverVersion) print('ToontownStart: serverVersion: ', serverVersion)
@ -100,6 +104,7 @@ if not launcher.isDummy():
base.startShow(cr, launcher.getGameServer()) base.startShow(cr, launcher.getGameServer())
else: else:
base.startShow(cr) base.startShow(cr)
backgroundNodePath.reparentTo(hidden) backgroundNodePath.reparentTo(hidden)
backgroundNodePath.removeNode() backgroundNodePath.removeNode()
del backgroundNodePath del backgroundNodePath