oldschool-toontown/toontown/building/DistributedHQInteriorAI.py

50 lines
1.5 KiB
Python
Raw Normal View History

2019-11-02 17:27:54 -05:00
from direct.distributed import DistributedObjectAI
from direct.directnotify import DirectNotifyGlobal
import pickle
2019-11-02 17:27:54 -05:00
class DistributedHQInteriorAI(DistributedObjectAI.DistributedObjectAI):
def __init__(self, block, air, zoneId):
DistributedObjectAI.DistributedObjectAI.__init__(self, air)
self.block = block
self.zoneId = zoneId
self.tutorial = 0
self.isDirty = False
self.accept('leaderboardChanged', self.leaderboardChanged)
self.accept('leaderboardFlush', self.leaderboardFlush)
def delete(self):
self.ignore('leaderboardChanged')
self.ignore('leaderboardFlush')
self.ignore('setLeaderBoard')
self.ignore('AIStarted')
DistributedObjectAI.DistributedObjectAI.delete(self)
def getZoneIdAndBlock(self):
r = [
self.zoneId, self.block]
return r
def leaderboardChanged(self):
self.isDirty = True
def leaderboardFlush(self):
if self.isDirty:
self.sendNewLeaderBoard()
def sendNewLeaderBoard(self):
if self.air:
self.isDirty = False
self.sendUpdate('setLeaderBoard', [pickle.dumps(self.air.trophyMgr.getLeaderInfo(), 1)])
2019-11-02 17:27:54 -05:00
def getLeaderBoard(self):
return pickle.dumps(self.air.trophyMgr.getLeaderInfo(), 1)
2019-11-02 17:27:54 -05:00
def getTutorial(self):
return self.tutorial
def setTutorial(self, flag):
if self.tutorial != flag:
self.tutorial = flag
self.sendUpdate('setTutorial', [self.tutorial])