From 7eeedfab1df83a59960575cede0a48e821414976 Mon Sep 17 00:00:00 2001 From: John Cote Date: Wed, 12 Aug 2020 13:42:31 -0400 Subject: [PATCH] safezone: Generate our safezone manager --- toontown/ai/ToontownAIRepository.py | 6 ++++++ toontown/safezone/SafeZoneManagerAI.py | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/toontown/ai/ToontownAIRepository.py b/toontown/ai/ToontownAIRepository.py index 4d2ddf9..b80652f 100644 --- a/toontown/ai/ToontownAIRepository.py +++ b/toontown/ai/ToontownAIRepository.py @@ -42,6 +42,7 @@ from toontown.racing.DistributedStartingBlockAI import DistributedStartingBlockA from toontown.racing.DistributedStartingBlockAI import DistributedViewingBlockAI from toontown.racing.DistributedViewPadAI import DistributedViewPadAI from toontown.racing.RaceManagerAI import RaceManagerAI +from toontown.safezone.SafeZoneManagerAI import SafeZoneManagerAI from toontown.shtiker.CogPageManagerAI import CogPageManagerAI from toontown.suit.SuitInvasionManagerAI import SuitInvasionManagerAI from toontown.toon import NPCToons @@ -82,6 +83,7 @@ class ToontownAIRepository(ToontownInternalRepository): self.inGameNewsMgr = None self.catalogManager = None self.trophyMgr = None + self.safeZoneManager = None self.zoneTable = {} self.dnaStoreMap = {} self.dnaDataMap = {} @@ -196,6 +198,10 @@ class ToontownAIRepository(ToontownInternalRepository): self.trophyMgr = DistributedTrophyMgrAI(self) self.trophyMgr.generateWithRequired(OTP_ZONE_ID_MANAGEMENT) + # Generate our safezone manager... + self.safeZoneManager = SafeZoneManagerAI(self) + self.safeZoneManager.generateWithRequired(OTP_ZONE_ID_MANAGEMENT) + def generateHood(self, hoodConstructor, zoneId): # Bossbot HQ doesn't use DNA, so we skip over that. if zoneId != ToontownGlobals.BossbotHQ: diff --git a/toontown/safezone/SafeZoneManagerAI.py b/toontown/safezone/SafeZoneManagerAI.py index c2bf42a..88a61e9 100644 --- a/toontown/safezone/SafeZoneManagerAI.py +++ b/toontown/safezone/SafeZoneManagerAI.py @@ -1,5 +1,31 @@ from direct.directnotify import DirectNotifyGlobal from direct.distributed.DistributedObjectAI import DistributedObjectAI +HealFrequency = 30.0 + + class SafeZoneManagerAI(DistributedObjectAI): notify = DirectNotifyGlobal.directNotify.newCategory('SafeZoneManagerAI') + + def enterSafeZone(self): + avId = self.air.getAvatarIdFromSender() + if not avId: + return + + av = self.air.doId2do.get(avId) + if not av: + return + + if not av.isToonedUp(): + av.startToonUp(HealFrequency) + + def exitSafeZone(self): + avId = self.air.getAvatarIdFromSender() + if not avId: + return + + av = self.air.doId2do.get(avId) + if not av: + return + + av.stopToonUp()