2019-11-02 17:27:54 -05:00
|
|
|
from direct.distributed import DistributedObjectAI
|
|
|
|
from direct.directnotify import DirectNotifyGlobal
|
2019-12-30 00:07:56 -06:00
|
|
|
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
|
2019-12-30 00:07:56 -06:00
|
|
|
self.sendUpdate('setLeaderBoard', [pickle.dumps(self.air.trophyMgr.getLeaderInfo(), 1)])
|
2019-11-02 17:27:54 -05:00
|
|
|
|
|
|
|
def getLeaderBoard(self):
|
2019-12-30 00:07:56 -06:00
|
|
|
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])
|