Poodletooth-iLand/toontown/hood/CogHQAI.py

82 lines
3 KiB
Python
Raw Normal View History

2015-03-03 16:10:12 -06:00
from toontown.building import DoorTypes
from toontown.building.DistributedBoardingPartyAI import DistributedBoardingPartyAI
2015-05-27 08:07:12 -05:00
from toontown.coghq import DistributedCogHQDoorAI, DistributedCogHQExteriorDoorAI, LobbyManagerAI
2015-05-11 12:06:27 -05:00
from toontown.toonbase import TTLocalizer, ToontownGlobals
from toontown.toon import NPCToons
2015-03-03 16:10:12 -06:00
class CogHQAI:
notify = directNotify.newCategory('CogHQAI')
notify.setInfo(True)
def __init__(
self, air, zoneId, lobbyZoneId, lobbyFADoorCode,
lobbyElevatorCtor, bossCtor):
self.air = air
self.zoneId = zoneId
self.lobbyZoneId = lobbyZoneId
self.lobbyFADoorCode = lobbyFADoorCode
self.lobbyElevatorCtor = lobbyElevatorCtor
self.bossCtor = bossCtor
self.lobbyMgr = None
self.lobbyElevator = None
self.boardingParty = None
self.notify.info('Creating objects... ' + self.getLocationName(zoneId))
def getLocationName(self, zoneId):
lookupTable = ToontownGlobals.hoodNameMap
if (zoneId % 1000) != 0:
lookupTable = TTLocalizer.GlobalStreetNames
name = lookupTable.get(zoneId, '')
if isinstance(name, str):
return name
return name[2]
def startup(self):
self.createLobbyManager()
self.createLobbyElevator()
self.extDoor = self.makeCogHQDoor(self.lobbyZoneId, 0, 0, self.lobbyFADoorCode)
if simbase.config.GetBool('want-boarding-groups', True):
self.createBoardingParty()
2015-05-11 12:06:27 -05:00
self.npcs = NPCToons.createNpcsInZone(self.air, self.zoneId)
2015-05-11 14:05:59 -05:00
2015-05-11 12:06:27 -05:00
def shutdown(self):
for npc in self.npcs:
npc.requestDelete()
del self.npcs
2015-03-03 16:10:12 -06:00
def createLobbyManager(self):
self.lobbyMgr = LobbyManagerAI.LobbyManagerAI(self.air, self.bossCtor)
self.lobbyMgr.generateWithRequired(self.lobbyZoneId)
def createLobbyElevator(self):
self.lobbyElevator = self.lobbyElevatorCtor(
self.air, self.lobbyMgr, self.lobbyZoneId, antiShuffle=1)
self.lobbyElevator.generateWithRequired(self.lobbyZoneId)
def makeCogHQDoor(self, destinationZone, intDoorIndex, extDoorIndex, lock=0):
intDoor = DistributedCogHQDoorAI.DistributedCogHQDoorAI(
self.air, 0, DoorTypes.INT_COGHQ, self.zoneId,
doorIndex=intDoorIndex, lockValue=lock)
intDoor.zoneId = destinationZone
2015-07-17 09:29:56 -05:00
extDoor = DistributedCogHQDoorAI.DistributedCogHQDoorAI(
2015-03-03 16:10:12 -06:00
self.air, 0, DoorTypes.EXT_COGHQ, destinationZone,
doorIndex=extDoorIndex, lockValue=lock)
extDoor.setOtherDoor(intDoor)
intDoor.setOtherDoor(extDoor)
intDoor.generateWithRequired(destinationZone)
intDoor.sendUpdate('setDoorIndex', [intDoor.getDoorIndex()])
extDoor.generateWithRequired(self.zoneId)
extDoor.sendUpdate('setDoorIndex', [extDoor.getDoorIndex()])
return extDoor
def createBoardingParty(self):
self.boardingParty = DistributedBoardingPartyAI(self.air, [self.lobbyElevator.doId], 8)
self.boardingParty.generateWithRequired(self.lobbyZoneId)