From 6d46f8cd32f71d36405c622a408ff4ae90ee64bf Mon Sep 17 00:00:00 2001 From: John Cote Date: Thu, 5 Dec 2019 22:03:12 -0500 Subject: [PATCH] racing: leaderboards initial commit --- toontown/ai/ToontownAIRepository.py | 15 ++++++++++++++- toontown/racing/DistributedLeaderBoardAI.py | 15 +++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/toontown/ai/ToontownAIRepository.py b/toontown/ai/ToontownAIRepository.py index 08ee3ed..4ce9d8c 100644 --- a/toontown/ai/ToontownAIRepository.py +++ b/toontown/ai/ToontownAIRepository.py @@ -24,6 +24,7 @@ from toontown.hood.MMHoodDataAI import MMHoodDataAI 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.shtiker.CogPageManagerAI import CogPageManagerAI from toontown.suit.SuitInvasionManagerAI import SuitInvasionManagerAI from toontown.toon import NPCToons @@ -267,7 +268,19 @@ class ToontownAIRepository(ToontownInternalRepository): return [], [] # TODO def findLeaderBoards(self, dnaData, zoneId): - return [] # TODO + leaderBoards = [] + if 'leaderBoard' in dnaData.getName(): + x, y, z = dnaData.getPos() + h, p, r = dnaData.getHpr() + leaderBoard = DistributedLeaderBoardAI(self, dnaData.getName(), x, y, z, h, p, r) + leaderBoard.generateWithRequired(zoneId) + leaderBoards.append(leaderBoard) + + for i in xrange(dnaData.getNumChildren()): + foundLeaderBoards = self.findLeaderBoards(dnaData.at(i), zoneId) + leaderBoards.extend(foundLeaderBoards) + + return leaderBoards def getTrackClsends(self): return False diff --git a/toontown/racing/DistributedLeaderBoardAI.py b/toontown/racing/DistributedLeaderBoardAI.py index 5368a7a..05ef4a4 100644 --- a/toontown/racing/DistributedLeaderBoardAI.py +++ b/toontown/racing/DistributedLeaderBoardAI.py @@ -1,5 +1,20 @@ from direct.directnotify import DirectNotifyGlobal from direct.distributed.DistributedObjectAI import DistributedObjectAI + class DistributedLeaderBoardAI(DistributedObjectAI): notify = DirectNotifyGlobal.directNotify.newCategory('DistributedLeaderBoardAI') + + def __init__(self, air, name, x, y, z, h, p, r): + DistributedObjectAI.__init__(self, air) + self.name = name + self.posHpr = (x, y, z, h, p, r) + + def getName(self): + return self.name + + def getPosHpr(self): + return self.posHpr + + def subscribeTo(self, subscription): + pass # TODO