oldschool-toontown/toontown/ai/ToontownAIRepository.py

93 lines
3.2 KiB
Python
Raw Normal View History

2019-11-10 18:46:41 -06:00
from direct.directnotify import DirectNotifyGlobal
2019-11-17 15:29:23 -06:00
from otp.ai.AIZoneData import AIZoneDataStore
from otp.distributed.OtpDoGlobals import *
2019-11-10 18:46:41 -06:00
from toontown.distributed.ToontownInternalRepository import ToontownInternalRepository
from toontown.distributed.ToontownDistrictAI import ToontownDistrictAI
2019-11-17 15:29:23 -06:00
from toontown.ai.HolidayManagerAI import HolidayManagerAI
2019-11-17 15:57:18 -06:00
from toontown.ai.NewsManagerAI import NewsManagerAI
2019-11-17 15:29:23 -06:00
from toontown.catalog.CatalogManagerAI import CatalogManagerAI
from toontown.uberdog.DistributedInGameNewsMgrAI import DistributedInGameNewsMgrAI
2019-11-10 18:46:41 -06:00
class ToontownAIRepository(ToontownInternalRepository):
notify = DirectNotifyGlobal.directNotify.newCategory('ToontownAIRepository')
def __init__(self, baseChannel, serverId, districtName):
ToontownInternalRepository.__init__(self, baseChannel, serverId, dcSuffix='AI')
self.districtName = districtName
2019-11-20 16:05:59 -06:00
self.doLiveUpdates = config.GetBool('want-live-updates', True)
2019-11-10 18:46:41 -06:00
self.districtId = None
self.district = None
2019-11-17 15:29:23 -06:00
self.holidayManager = None
self.zoneDataStore = None
2019-11-20 16:05:59 -06:00
self.newsManager = None
2019-11-17 15:29:23 -06:00
self.inGameNewsMgr = None
self.catalogManager = None
2019-11-10 18:46:41 -06:00
def handleConnected(self):
ToontownInternalRepository.handleConnected(self)
# Generate our district...
self.districtId = self.allocateChannel()
self.district = ToontownDistrictAI(self)
self.district.setName(self.districtName)
self.district.generateWithRequiredAndId(self.districtId, self.getGameDoId(), OTP_ZONE_ID_DISTRICTS)
2019-11-10 19:50:13 -06:00
# Claim ownership of that district...
self.district.setAI(self.ourChannel)
2019-11-17 15:29:23 -06:00
# Create our local objects.
self.createLocals()
# Create our global objects.
self.createGlobals()
2019-11-10 19:50:13 -06:00
# Make our district available, and we're done.
self.district.b_setAvailable(True)
self.notify.info('Done.')
2019-11-17 15:29:23 -06:00
def createLocals(self):
"""
Creates "local" (non-distributed) objects.
"""
# Create our holiday manager...
self.holidayManager = HolidayManagerAI(self)
# Create our zone data store...
self.zoneDataStore = AIZoneDataStore()
def createGlobals(self):
"""
Creates "global" (distributed) objects.
"""
2019-11-17 15:57:18 -06:00
# Generate our news manager...
self.newsManager = NewsManagerAI(self)
self.newsManager.generateWithRequired(OTP_ZONE_ID_MANAGEMENT)
2019-11-17 15:29:23 -06:00
# Generate our in-game news manager...
self.inGameNewsMgr = DistributedInGameNewsMgrAI(self)
self.inGameNewsMgr.generateWithRequired(OTP_ZONE_ID_MANAGEMENT)
# Generate our catalog manager...
self.catalogManager = CatalogManagerAI(self)
2019-11-20 14:12:05 -06:00
self.catalogManager.generateWithRequired(OTP_ZONE_ID_MANAGEMENT)
2019-11-17 15:29:23 -06:00
def getTrackClsends(self):
return False
def getAvatarExitEvent(self, avId):
return 'distObjDelete-%d' % avId
def getZoneDataStore(self):
return self.zoneDataStore
def incrementPopulation(self):
print 'TODO districtStats'
def decrementPopulation(self):
print 'TODO districtStats'
def sendQueryToonMaxHp(self, avId, callback):
pass # TODO?