diff --git a/toontown/coghq/CogHQExterior.py b/toontown/coghq/CogHQExterior.py index 7df3905..cd1ec7c 100644 --- a/toontown/coghq/CogHQExterior.py +++ b/toontown/coghq/CogHQExterior.py @@ -76,8 +76,6 @@ class CogHQExterior(BattlePlace.BattlePlace): self.tunnelOriginList = base.cr.hoodMgr.addLinkTunnelHooks(self, self.nodeList, self.zoneId) how = requestStatus['how'] self.fsm.request(how, [requestStatus]) - if __astron__ and self.zoneId != ToontownGlobals.BossbotHQ: - self.handleInterests() def exit(self): self.fsm.requestFinalState() @@ -138,31 +136,3 @@ class CogHQExterior(BattlePlace.BattlePlace): def exitSquished(self): taskMgr.remove(base.localAvatar.uniqueName('finishSquishTask')) base.localAvatar.laffMeter.stop() - - if __astron__: - def handleInterests(self): - # First, we need to load the DNA file for this Cog HQ. - dnaStore = DNAStorage() - dnaFileName = self.genDNAFileName(self.zoneId) - loadDNAFileAI(dnaStore, dnaFileName) - - # Next, we need to collect all of the visgroup zone IDs. - self.zoneVisDict = {} - for i in range(dnaStore.getNumDNAVisGroupsAI()): - visGroup = dnaStore.getDNAVisGroupAI(i) - groupFullName = visGroup.getName() - visZoneId = int(base.cr.hoodMgr.extractGroupName(groupFullName)) - visZoneId = ZoneUtil.getTrueZoneId(visZoneId, self.zoneId) - visibles = [] - for i in range(visGroup.getNumVisibles()): - visibles.append(int(visGroup.getVisibleName(i))) - - visibles.append(ZoneUtil.getBranchZone(visZoneId)) - self.zoneVisDict[visZoneId] = visibles - - # Finally, we want interest in all visgroups due to this being a Cog HQ. - visList = list(self.zoneVisDict.values())[0] - if self.zoneId not in visList: - visList.append(self.zoneId) - - base.cr.sendSetZoneMsg(self.zoneId, visList) diff --git a/toontown/coghq/CogHQLoader.py b/toontown/coghq/CogHQLoader.py index 4a48b01..713551b 100644 --- a/toontown/coghq/CogHQLoader.py +++ b/toontown/coghq/CogHQLoader.py @@ -149,3 +149,16 @@ class CogHQLoader(StateData.StateData): self.exitPlace() self.placeClass = None return + + if __astron__: + @staticmethod + def genDNAFileName(zoneId): + from toontown.toonbase import ToontownGlobals + zoneId = ZoneUtil.getCanonicalZoneId(zoneId) + hoodId = ZoneUtil.getCanonicalHoodId(zoneId) + hood = ToontownGlobals.dnaMap[hoodId] + phase = ToontownGlobals.streetPhaseMap[hoodId] + if hoodId == zoneId: + zoneId = 'sz' + + return 'phase_%s/dna/%s_%s.dna' % (phase, hood, zoneId) diff --git a/toontown/hood/QuietZoneState.py b/toontown/hood/QuietZoneState.py index 5efd693..bb22453 100644 --- a/toontown/hood/QuietZoneState.py +++ b/toontown/hood/QuietZoneState.py @@ -1,7 +1,9 @@ from panda3d.core import * +from panda3d.toontown import * from direct.showbase.PythonUtil import Functor, PriorityCallbacks from direct.task import Task from toontown.distributed.ToontownMsgTypes import * +from toontown.toonbase import ToontownGlobals from otp.otpbase import OTPGlobals from direct.directnotify import DirectNotifyGlobal from direct.fsm import StateData @@ -284,18 +286,66 @@ class QuietZoneState(StateData.StateData): where = self._requestStatus['where'] base.cr.dumpAllSubShardObjects() base.cr.resetDeletedSubShardDoIds() - if __astron__ and where == 'street': - visZones = [ZoneUtil.getBranchZone(zoneId)] - # Assuming that the DNA have been loaded by bulk load before this. - loader = base.cr.playGame.hood.loader - visZones += [loader.node2zone[x] for x in loader.nodeDict[zoneId]] - if zoneId not in visZones: - visZones.append(zoneId) - base.cr.sendSetZoneMsg(zoneId, visZones) + if __astron__: + # Add viszones to streets and Cog HQs: + visZones = [] + if where == 'street': + visZones = self.getStreetViszones(zoneId) + if zoneId not in visZones: + visZones.append(zoneId) + base.cr.sendSetZoneMsg(zoneId, visZones) + elif where in ('cogHQExterior', 'factoryExterior'): + visZones = self.getCogHQViszones(zoneId) + if zoneId not in visZones: + visZones.append(zoneId) + if len(visZones) < 1 or (len(visZones) == 1 and visZones[0] == zoneId): + base.cr.sendSetZoneMsg(zoneId) + else: + base.cr.sendSetZoneMsg(zoneId, visZones) else: base.cr.sendSetZoneMsg(zoneId) self.waitForDatabase('WaitForSetZoneResponse') self.fsm.request('waitForSetZoneComplete') + + if __astron__: + def getStreetViszones(self, zoneId): + visZones = [ZoneUtil.getBranchZone(zoneId)] + # Assuming that the DNA have been loaded by bulk load before this (see Street.py). + loader = base.cr.playGame.hood.loader + visZones += [loader.node2zone[x] for x in loader.nodeDict[zoneId]] + self.notify.debug(f'getStreetViszones(zoneId={zoneId}): returning visZones: {visZones}') + return visZones + + def getCogHQViszones(self, zoneId): + loader = base.cr.playGame.hood.loader + + if zoneId in (ToontownGlobals.LawbotOfficeExt, ToontownGlobals.BossbotHQ): + # There are no viszones for these zones, just return an empty list. + return [] + + # First, we need to load the DNA file for this Cog HQ. + dnaStore = DNAStorage() + dnaFileName = loader.genDNAFileName(zoneId) + loadDNAFileAI(dnaStore, dnaFileName) + + # Next, we need to collect all of the visgroup zone IDs. + loader.zoneVisDict = {} + for i in range(dnaStore.getNumDNAVisGroupsAI()): + visGroup = dnaStore.getDNAVisGroupAI(i) + groupFullName = visGroup.getName() + visZoneId = int(base.cr.hoodMgr.extractGroupName(groupFullName)) + visZoneId = ZoneUtil.getTrueZoneId(visZoneId, zoneId) + visibles = [] + for i in range(visGroup.getNumVisibles()): + visibles.append(int(visGroup.getVisibleName(i))) + + # Now we'll store it in the loader since we need them when we enter a Cog battle. + loader.zoneVisDict[visZoneId] = visibles + + # Finally, we want interest in all visgroups due to this being a Cog HQ. + visZones = list(loader.zoneVisDict.values())[0] + self.notify.debug(f'getCogHQViszones(zoneId={zoneId}): returning visZones: {visZones}') + return visZones def exitWaitForSetZoneResponse(self): self.notify.debug('exitWaitForSetZoneResponse()')