historical/toontown-classic.git/toontown/coghq/BossbotCogHQLoader.py
2024-01-16 11:20:27 -06:00

214 lines
8.5 KiB
Python

from direct.directnotify import DirectNotifyGlobal
from direct.fsm import StateData
import CogHQLoader
from toontown.toonbase import ToontownGlobals
from direct.gui import DirectGui
from toontown.toonbase import TTLocalizer
from toontown.toon import Toon
from direct.fsm import State
from toontown.coghq import BossbotHQExterior
from toontown.coghq import BossbotHQBossBattle
from toontown.coghq import BossbotOfficeExterior
from toontown.coghq import CountryClubInterior
from panda3d.core import DecalEffect, TextEncoder
import random
import thread
aspectSF = 0.7227
class BossbotCogHQLoader(CogHQLoader.CogHQLoader):
notify = DirectNotifyGlobal.directNotify.newCategory('BossbotCogHQLoader')
def __init__(self, hood, parentFSMState, doneEvent):
CogHQLoader.CogHQLoader.__init__(self, hood, parentFSMState, doneEvent)
self.fsm.addState(State.State('countryClubInterior', self.enterCountryClubInterior, self.exitCountryClubInterior, ['quietZone', 'cogHQExterior']))
for stateName in ['start', 'cogHQExterior', 'quietZone']:
state = self.fsm.getStateNamed(stateName)
state.addTransition('countryClubInterior')
self.musicFile = random.choice(['phase_12/audio/bgm/Bossbot_Entry_v1.ogg', 'phase_12/audio/bgm/Bossbot_Entry_v2.ogg', 'phase_12/audio/bgm/Bossbot_Entry_v3.ogg'])
self.cogHQExteriorModelPath = 'phase_12/models/bossbotHQ/CogGolfHub'
self.factoryExteriorModelPath = 'phase_11/models/lawbotHQ/LB_DA_Lobby'
self.cogHQLobbyModelPath = 'phase_12/models/bossbotHQ/CogGolfCourtyard'
self.geom = None
self.toSamBotHQ = loader.loadModel("phase_6/models/cogHQ/Cog_Tunnel.bam")
self.toSamBotHQ.setColor(1,0,0)
self.toSamBotHQ.setPos(161.825,-30.519,0.025)
self.toSamBotHQ.setHpr(70,0,0)
self.toBBHQ = loader.loadModel("phase_6/models/cogHQ/Cog_Tunnel.bam")
self.toBBHQ.setColor(1,0,0)
self.toBBHQ.setPos(10,126,0.025)
self.toBBHQ.setHpr(555,0,0)
self.toFunnyFarm = loader.loadModel("phase_6/models/cogHQ/Cog_Tunnel.bam")
self.toFunnyFarm.setPos(16.2,-50,0.025)
self.toFunnyFarm.setHpr(128,0,0)
self.geom2 = loader.loadModel("phase_4/models/neighborhoods/toontown_central.bam")
return
def load(self, zoneId):
CogHQLoader.CogHQLoader.load(self, zoneId)
Toon.loadBossbotHQAnims()
def unloadPlaceGeom(self):
if self.geom:
self.geom.removeNode()
self.geom = None
CogHQLoader.CogHQLoader.unloadPlaceGeom(self)
return
def loadPlaceGeom(self, zoneId):
self.notify.info('loadPlaceGeom: %s' % zoneId)
plainOldZoneId = zoneId
zoneId = zoneId - zoneId % 100
self.notify.debug('zoneId = %d ToontownGlobals.BossbotHQ=%d' % (zoneId, ToontownGlobals.BossbotHQ))
if zoneId == ToontownGlobals.BossbotHQ:
self.geom = loader.loadModel(self.cogHQExteriorModelPath)
gzLinkTunnel = self.geom.find('**/LinkTunnel1')
gzLinkTunnel.setName('linktunnel_gz_17000_DNARoot')
self.makeSigns()
top = self.geom.find('**/TunnelEntrance')
origin = top.find('**/tunnel_origin')
origin.setH(-33.33)
self.toSamBotHQ.reparentTo(render)
self.toSamBotHQ.show()
tfa = thread.allocate_lock()
with tfa:
while True:
if (base.localAvatar.getPos() == self.toSamBotHQ.getPos()):
print("Going to SamBotHQ")
loadPlaceGeom(7666)
break
else:
return None
elif plainOldZoneId == 7666:
self.toSamBotHQ.hide()
self.geom2.reparentTo(render)
self.toBBHQ.reparentTo(render)
self.toFunnyFarm.reparentTo(render)
self.toBBHQ.show()
self.toFunnyFarm.show()
tfb = thread.allocate_lock()
with tfb:
while True:
if (base.localAvatar.getPos() == self.toBBHQ.getPos()):
print("Going to BBHQ")
loadPlaceGeom(10000)
break
else:
return None
elif zoneId == ToontownGlobals.BossbotLobby:
if base.config.GetBool('want-qa-regression', 0):
self.notify.info('QA-REGRESSION: COGHQ: Visit BossbotLobby')
self.notify.debug('cogHQLobbyModelPath = %s' % self.cogHQLobbyModelPath)
self.geom = loader.loadModel(self.cogHQLobbyModelPath)
else:
self.notify.warning('loadPlaceGeom: unclassified zone %s' % zoneId)
try:
self.toSamBotHQ.hide()
except AttributeError:
print("Not a valid object SBHQ tunnel")
except:
print("Unknown error.")
try:
self.toFunnyFarm.hide()
except AttributeError:
print("Not a valid object FF tunnel")
except:
print("Unknown error.")
try:
self.toBBHQ.hide()
self.toBBHQ.removeNode()
except AttributeError:
print("Not a valid object BBHQ tunnel")
except:
print("Unknown error.")
CogHQLoader.CogHQLoader.loadPlaceGeom(self, zoneId)
def makeSigns(self):
def makeSign(topStr, signStr, textId):
top = self.geom.find('**/' + topStr)
sign = top.find('**/' + signStr)
locator = top.find('**/sign_origin')
signText = DirectGui.OnscreenText(text=TextEncoder.upper(TTLocalizer.GlobalStreetNames[textId][-1]), font=ToontownGlobals.getSuitFont(), scale=TTLocalizer.BCHQLsignText, fg=(0, 0, 0, 1), parent=sign)
signText.setPosHpr(locator, 0, -0.1, -0.25, 0, 0, 0)
signText.setDepthWrite(0)
makeSign('Gate_2', 'Sign_6', 10700)
makeSign('TunnelEntrance', 'Sign_2', 1000)
makeSign('Gate_3', 'Sign_3', 10600)
makeSign('Gate_4', 'Sign_4', 10500)
makeSign('GateHouse', 'Sign_5', 10200)
def unload(self):
CogHQLoader.CogHQLoader.unload(self)
try:
self.toSamBotHQ.hide()
except AttributeError:
print("Not a valid object SBHQ tunnel")
except:
print("Unknown error.")
try:
self.toFunnyFarm.hide()
except AttributeError:
print("Not a valid object FF tunnel")
except:
print("Unknown error.")
try:
self.toBBHQ.hide()
except AttributeError:
print("Not a valid object BBHQ tunnel")
except:
print("Unknown error.")
Toon.unloadSellbotHQAnims()
def enterStageInterior(self, requestStatus):
self.placeClass = StageInterior.StageInterior
self.stageId = requestStatus['stageId']
self.enterPlace(requestStatus)
def exitStageInterior(self):
self.exitPlace()
self.placeClass = None
return
def getExteriorPlaceClass(self):
self.notify.debug('getExteriorPlaceClass')
return BossbotHQExterior.BossbotHQExterior
def getBossPlaceClass(self):
self.notify.debug('getBossPlaceClass')
return BossbotHQBossBattle.BossbotHQBossBattle
def enterFactoryExterior(self, requestStatus):
self.placeClass = BossbotOfficeExterior.BossbotOfficeExterior
self.enterPlace(requestStatus)
def exitFactoryExterior(self):
taskMgr.remove('titleText')
self.hood.hideTitleText()
self.exitPlace()
self.placeClass = None
return
def enterCogHQBossBattle(self, requestStatus):
self.notify.debug('BossbotCogHQLoader.enterCogHQBossBattle')
CogHQLoader.CogHQLoader.enterCogHQBossBattle(self, requestStatus)
base.cr.forbidCheesyEffects(1)
def exitCogHQBossBattle(self):
self.notify.debug('BossbotCogHQLoader.exitCogHQBossBattle')
CogHQLoader.CogHQLoader.exitCogHQBossBattle(self)
base.cr.forbidCheesyEffects(0)
def enterCountryClubInterior(self, requestStatus):
self.placeClass = CountryClubInterior.CountryClubInterior
self.notify.info('enterCountryClubInterior, requestStatus=%s' % requestStatus)
self.countryClubId = requestStatus['countryClubId']
self.enterPlace(requestStatus)
def exitCountryClubInterior(self):
self.exitPlace()
self.placeClass = None
del self.countryClubId
return