2015-03-03 16:10:12 -06:00
|
|
|
from direct.directnotify.DirectNotifyGlobal import directNotify
|
|
|
|
from direct.distributed.DistributedObjectAI import DistributedObjectAI
|
|
|
|
|
|
|
|
class ToontownDistrictStatsAI(DistributedObjectAI):
|
|
|
|
notify = directNotify.newCategory('ToontownDistrictStatsAI')
|
|
|
|
|
|
|
|
districtId = 0
|
|
|
|
avatarCount = 0
|
|
|
|
invasionStatus = 0
|
|
|
|
|
|
|
|
def announceGenerate(self):
|
|
|
|
DistributedObjectAI.announceGenerate(self)
|
|
|
|
|
|
|
|
# We want to handle shard status queries so that a ShardStatusReceiver
|
|
|
|
# being created after we're generated will know where we're at:
|
2015-07-12 11:48:58 -05:00
|
|
|
self.air.accept('shardStatus', self.handleShardStatusQuery)
|
2015-03-03 16:10:12 -06:00
|
|
|
|
|
|
|
def handleShardStatusQuery(self):
|
|
|
|
# Send a shard status update containing our population:
|
|
|
|
status = {'population': self.avatarCount}
|
2015-07-12 11:51:05 -05:00
|
|
|
self.air.sendNetEvent('shardStatus', [self.air.ourChannel, status])
|
2015-03-03 16:10:12 -06:00
|
|
|
|
2015-06-29 13:54:28 -05:00
|
|
|
def setDistrictId(self, districtId):
|
2015-03-03 16:10:12 -06:00
|
|
|
self.districtId = districtId
|
|
|
|
|
2015-06-29 13:54:28 -05:00
|
|
|
def d_setDistrictId(self, districtId):
|
|
|
|
self.sendUpdate('setDistrictId', [districtId])
|
2015-03-03 16:10:12 -06:00
|
|
|
|
2015-06-29 13:54:28 -05:00
|
|
|
def b_setDistrictId(self, districtId):
|
|
|
|
self.setDistrictId(districtId)
|
|
|
|
self.d_setDistrictId(districtId)
|
2015-03-03 16:10:12 -06:00
|
|
|
|
2015-06-29 13:54:28 -05:00
|
|
|
def getDistrictId(self):
|
2015-03-03 16:10:12 -06:00
|
|
|
return self.districtId
|
|
|
|
|
|
|
|
def setAvatarCount(self, avatarCount):
|
|
|
|
self.avatarCount = avatarCount
|
|
|
|
|
|
|
|
# Send a shard status update containing our population:
|
|
|
|
status = {'population': self.avatarCount}
|
2015-07-12 11:48:58 -05:00
|
|
|
self.air.sendNetEvent('shardStatus', [self.air.ourChannel, status])
|
2015-03-03 16:10:12 -06:00
|
|
|
|
|
|
|
def d_setAvatarCount(self, avatarCount):
|
|
|
|
self.sendUpdate('setAvatarCount', [avatarCount])
|
|
|
|
|
|
|
|
def b_setAvatarCount(self, avatarCount):
|
|
|
|
self.d_setAvatarCount(avatarCount)
|
|
|
|
self.setAvatarCount(avatarCount)
|
|
|
|
|
|
|
|
def getAvatarCount(self):
|
|
|
|
return self.avatarCount
|
|
|
|
|
|
|
|
def setInvasionStatus(self, invasionStatus):
|
|
|
|
self.invasionStatus = invasionStatus
|
|
|
|
|
|
|
|
def d_setInvasionStatus(self, invasionStatus):
|
|
|
|
self.sendUpdate('setInvasionStatus', [invasionStatus])
|
|
|
|
|
|
|
|
def b_setInvasionStatus(self, invasionStatus):
|
|
|
|
self.setInvasionStatus(invasionStatus)
|
|
|
|
self.d_setInvasionStatus(invasionStatus)
|
|
|
|
|
|
|
|
def getInvasionStatus(self):
|
2015-07-05 18:59:25 -05:00
|
|
|
return self.invasionStatus
|