Initial work on goofy leaderboard

This commit is contained in:
John 2015-06-06 15:57:29 +03:00 committed by Loudrob
parent 54125c5b65
commit 1e47509477
2 changed files with 45 additions and 12 deletions

View file

@ -6,9 +6,9 @@ from toontown.racing.DistributedRacePadAI import DistributedRacePadAI
from toontown.racing.DistributedStartingBlockAI import DistributedStartingBlockAI
from toontown.racing.DistributedViewPadAI import DistributedViewPadAI
from toontown.racing.DistributedStartingBlockAI import DistributedViewingBlockAI
from toontown.racing.DistributedLeaderBoardAI import DistributedLeaderBoardAI
from toontown.toonbase import ToontownGlobals
class GSHoodAI(HoodAI.HoodAI):
def __init__(self, air):
HoodAI.HoodAI.__init__(self, air,
@ -121,8 +121,30 @@ class GSHoodAI(HoodAI.HoodAI):
for viewingBlock in foundViewingBlocks:
viewPad.addStartingBlock(viewingBlock)
def findLeaderBoards(self, dnaData, zoneId):
return [] # TODO
def findLeaderBoards(self, dnaGroup, zoneId):
leaderBoards = []
if isinstance(dnaGroup, DNAGroup) and ('leader_board' in dnaGroup.getName()):
for i in xrange(dnaGroup.getNumChildren()):
childDnaGroup = dnaGroup.at(i)
if 'leaderBoard' in childDnaGroup.getName():
pos = childDnaGroup.getPos()
hpr = childDnaGroup.getHpr()
nameInfo = childDnaGroup.getName().split('_')
leaderBoard = DistributedLeaderBoardAI(simbase.air, nameInfo[1])
leaderBoard.setPosHpr(pos[0], pos[1], pos[2], hpr[0], hpr[1], hpr[2])
leaderBoard.generateWithRequired(zoneId)
leaderBoards.append(leaderBoard)
elif isinstance(dnaGroup, DNAVisGroup):
zoneId = int(dnaGroup.getName().split(':')[0])
for i in xrange(dnaGroup.getNumChildren()):
foundLeaderBoards = self.findLeaderBoards(dnaGroup.at(i), zoneId)
leaderBoards.extend(foundLeaderBoards)
return leaderBoards
def createLeaderBoards(self):
self.leaderBoards = []
@ -132,12 +154,7 @@ class GSHoodAI(HoodAI.HoodAI):
for leaderBoard in self.leaderBoards:
if not leaderBoard:
continue
if 'city' in leaderBoard.getName():
leaderBoardType = 'city'
elif 'stadium' in leaderBoard.getName():
leaderBoardType = 'stadium'
elif 'country' in leaderBoard.getName():
leaderBoardType = 'country'
leaderBoardType = leaderBoard.getName()
for subscription in RaceGlobals.LBSubscription[leaderBoardType]:
leaderBoard.subscribeTo(subscription)

View file

@ -4,9 +4,25 @@ from direct.distributed.DistributedObjectAI import DistributedObjectAI
class DistributedLeaderBoardAI(DistributedObjectAI):
notify = DirectNotifyGlobal.directNotify.newCategory("DistributedLeaderBoardAI")
def setPosHpr(self, todo0, todo1, todo2, todo3, todo4, todo5):
pass
def __init__(self, air, name):
DistributedObjectAI.__init__(self, air)
self.posHpr = (0, 0, 0, 0, 0, 0)
self.name = name
def setPosHpr(self, x, y, z, h, p, r):
self.posHpr = (x, y, z, h, p, r)
def getPosHpr(self):
return self.posHpr
def setName(self, name):
self.name = name
def getName(self):
return self.name
def setDisplay(self, todo0):
pass
def subscribeTo(self, todo0):
print 'subscribed to %s' % (todo0,)