oldschool-toontown/toontown/ai/WelcomeValleyManagerAI.py

43 lines
1.9 KiB
Python
Raw Normal View History

2019-11-09 04:55:55 +00:00
from direct.directnotify import DirectNotifyGlobal
from direct.distributed.DistributedObjectAI import DistributedObjectAI
2019-12-06 02:38:58 +00:00
from toontown.hood import ZoneUtil
from toontown.hood.GSHoodDataAI import GSHoodDataAI
from toontown.hood.TTHoodDataAI import TTHoodDataAI
from toontown.toonbase import ToontownGlobals
2019-11-09 04:55:55 +00:00
class WelcomeValleyManagerAI(DistributedObjectAI):
notify = DirectNotifyGlobal.directNotify.newCategory('WelcomeValleyManagerAI')
2019-12-06 02:38:58 +00:00
def requestZoneIdMessage(self, zoneId, context):
avId = self.air.getAvatarIdFromSender()
if zoneId == 0:
zoneId = ToontownGlobals.WelcomeValleyBegin
self.toonSetZone(avId, zoneId)
self.sendUpdateToAvatarId(avId, 'requestZoneIdResponse', [zoneId, context])
def toonSetZone(self, doId, zoneId):
event = self.staticGetLogicalZoneChangeEvent(doId)
inWelcomeValley = self.isAccepting(event)
if not ZoneUtil.isDynamicZone(zoneId):
if ZoneUtil.isWelcomeValley(zoneId) and not inWelcomeValley:
self.air.districtStats.b_setNewAvatarCount(self.air.districtStats.getNewAvatarCount() + 1)
self.accept(event, lambda newZoneId, _: self.toonSetZone(doId, newZoneId))
2019-12-06 04:10:13 +00:00
self.accept(self.air.getAvatarExitEvent(doId), self.toonSetZone,
extraArgs=[doId, ToontownGlobals.ToontownCentral])
2019-12-06 02:38:58 +00:00
elif (not ZoneUtil.isWelcomeValley(zoneId)) and inWelcomeValley:
self.air.districtStats.b_setNewAvatarCount(self.air.districtStats.getNewAvatarCount() - 1)
self.ignore(event)
self.ignore(self.air.getAvatarExitEvent(doId))
def createWelcomeValleyZones(self):
self.notify.info('Creating Welcome Valley zones...')
# Toontown Central
self.air.generateHood(TTHoodDataAI, 22000)
# Goofy Speedway
self.air.generateHood(GSHoodDataAI, 23000)