diff --git a/toontown/ai/ToontownAIRepository.py b/toontown/ai/ToontownAIRepository.py index 748ac41..6d2bbca 100644 --- a/toontown/ai/ToontownAIRepository.py +++ b/toontown/ai/ToontownAIRepository.py @@ -25,6 +25,8 @@ from toontown.hood.TTHoodDataAI import TTHoodDataAI from toontown.pets.PetManagerAI import PetManagerAI from toontown.quest.QuestManagerAI import QuestManagerAI from toontown.racing.DistributedLeaderBoardAI import DistributedLeaderBoardAI +from toontown.racing.DistributedRacePadAI import DistributedRacePadAI +from toontown.racing.DistributedViewPadAI import DistributedViewPadAI from toontown.racing.RaceManagerAI import RaceManagerAI from toontown.shtiker.CogPageManagerAI import CogPageManagerAI from toontown.suit.SuitInvasionManagerAI import SuitInvasionManagerAI @@ -269,8 +271,31 @@ class ToontownAIRepository(ToontownInternalRepository): def findPartyHats(self, dnaData, zoneId): return [] # TODO - def findRacingPads(self, dnaData, zoneId, area, type='racing_pad'): - return [], [] # TODO + def findRacingPads(self, dnaData, zoneId, area, type='racing_pad', overrideDNAZone=False): + kartPads, kartPadGroups = [], [] + if type in dnaData.getName(): + if type == 'racing_pad': + racePad = DistributedRacePadAI(self) + racePad.setArea(area) + racePad.generateWithRequired(zoneId) + kartPads.append(racePad) + kartPadGroups.append(dnaData) + elif type == 'viewing_pad': + viewPad = DistributedViewPadAI(self) + viewPad.setArea(area) + viewPad.generateWithRequired(zoneId) + kartPads.append(viewPad) + kartPadGroups.append(dnaData) + + for i in xrange(dnaData.getNumChildren()): + foundKartPads, foundKartPadGroups = self.findRacingPads(dnaData.at(i), zoneId, area, type, overrideDNAZone) + kartPads.extend(foundKartPads) + kartPadGroups.extend(foundKartPadGroups) + + return kartPads, kartPadGroups + + def findStartingBlocks(self, dnaData, racePad): + return [] # TODO def findLeaderBoards(self, dnaData, zoneId): leaderBoards = [] diff --git a/toontown/racing/DistributedKartPadAI.py b/toontown/racing/DistributedKartPadAI.py index 75f7d4d..21be060 100644 --- a/toontown/racing/DistributedKartPadAI.py +++ b/toontown/racing/DistributedKartPadAI.py @@ -1,5 +1,16 @@ from direct.directnotify import DirectNotifyGlobal from direct.distributed.DistributedObjectAI import DistributedObjectAI + class DistributedKartPadAI(DistributedObjectAI): notify = DirectNotifyGlobal.directNotify.newCategory('DistributedKartPadAI') + + def __init__(self, air): + DistributedObjectAI.__init__(self, air) + self.area = None + + def setArea(self, area): + self.area = area + + def getArea(self): + return self.area diff --git a/toontown/racing/DistributedRacePad.py b/toontown/racing/DistributedRacePad.py index f90f055..0aab464 100644 --- a/toontown/racing/DistributedRacePad.py +++ b/toontown/racing/DistributedRacePad.py @@ -1,3 +1,4 @@ +from panda3d.core import * from direct.directnotify import DirectNotifyGlobal from direct.task.Task import Task from direct.distributed.ClockDelta import * diff --git a/toontown/racing/DistributedRacePadAI.py b/toontown/racing/DistributedRacePadAI.py index b7ac92b..f2f58b1 100644 --- a/toontown/racing/DistributedRacePadAI.py +++ b/toontown/racing/DistributedRacePadAI.py @@ -1,5 +1,32 @@ from direct.directnotify import DirectNotifyGlobal -from direct.distributed.DistributedObjectAI import DistributedObjectAI +from direct.distributed.ClockDelta import globalClockDelta -class DistributedRacePadAI(DistributedObjectAI): +from toontown.racing.DistributedKartPadAI import DistributedKartPadAI + + +class DistributedRacePadAI(DistributedKartPadAI): notify = DirectNotifyGlobal.directNotify.newCategory('DistributedRacePadAI') + + def __init__(self, air): + DistributedKartPadAI.__init__(self, air) + self.state = 'Off' + self.trackInfo = [0, 0] + + def setState(self, state): + self.state = state + + def d_setState(self, state): + self.sendUpdate('setState', [state, globalClockDelta.getRealNetworkTime()]) + + def b_setState(self, state): + self.setState(state) + self.d_setState(state) + + def getState(self): + return self.state, globalClockDelta.getRealNetworkTime() + + def getTrackInfo(self): + return self.trackInfo + + def request(self, state): + self.b_setState(state) diff --git a/toontown/racing/DistributedViewPadAI.py b/toontown/racing/DistributedViewPadAI.py index 09c92da..9023d0e 100644 --- a/toontown/racing/DistributedViewPadAI.py +++ b/toontown/racing/DistributedViewPadAI.py @@ -1,5 +1,19 @@ from direct.directnotify import DirectNotifyGlobal -from direct.distributed.DistributedObjectAI import DistributedObjectAI +from direct.distributed.ClockDelta import globalClockDelta -class DistributedViewPadAI(DistributedObjectAI): +from toontown.racing.DistributedKartPadAI import DistributedKartPadAI + + +class DistributedViewPadAI(DistributedKartPadAI): notify = DirectNotifyGlobal.directNotify.newCategory('DistributedViewPadAI') + + def __init__(self, air): + DistributedKartPadAI.__init__(self, air) + self.lastEntered = 0 + + def announceGenerate(self): + DistributedKartPadAI.announceGenerate(self) + self.lastEntered = globalClockDelta.getRealNetworkTime() + + def getLastEntered(self): + return self.lastEntered