From b9c206a8d9c2f642085da914fa5e9dc2d6956021 Mon Sep 17 00:00:00 2001 From: Open Toontown Date: Fri, 22 Nov 2019 20:18:26 -0500 Subject: [PATCH] ai: add district stats --- etc/Configrc.prc | 4 +- toontown/ai/ToontownAIRepository.py | 12 ++++- .../distributed/ToontownDistrictStatsAI.py | 45 +++++++++++++++++++ toontown/toon/DistributedToonAI.py | 2 +- 4 files changed, 59 insertions(+), 4 deletions(-) diff --git a/etc/Configrc.prc b/etc/Configrc.prc index 02440ee..7c532e6 100644 --- a/etc/Configrc.prc +++ b/etc/Configrc.prc @@ -38,13 +38,15 @@ load-display pandagl aux-display pandagl aux-display pandadx9 aux-display tinydisplay +depth-bits 24 win-size 800 600 fullscreen #t -compress-channels #t +compress-channels #f display-lists 0 early-random-seed 1 ssl-cipher-list DEFAULT respect-prev-transform 1 +default-directnotify-level info notify-level-collide warning notify-level-chan warning notify-level-gobj warning diff --git a/toontown/ai/ToontownAIRepository.py b/toontown/ai/ToontownAIRepository.py index 4483e5a..16fe33c 100644 --- a/toontown/ai/ToontownAIRepository.py +++ b/toontown/ai/ToontownAIRepository.py @@ -3,6 +3,7 @@ from otp.ai.AIZoneData import AIZoneDataStore from otp.distributed.OtpDoGlobals import * from toontown.distributed.ToontownInternalRepository import ToontownInternalRepository from toontown.distributed.ToontownDistrictAI import ToontownDistrictAI +from toontown.distributed.ToontownDistrictStatsAI import ToontownDistrictStatsAI from toontown.ai.HolidayManagerAI import HolidayManagerAI from toontown.ai.NewsManagerAI import NewsManagerAI from toontown.catalog.CatalogManagerAI import CatalogManagerAI @@ -17,6 +18,7 @@ class ToontownAIRepository(ToontownInternalRepository): self.doLiveUpdates = config.GetBool('want-live-updates', True) self.districtId = None self.district = None + self.districtStats = None self.holidayManager = None self.zoneDataStore = None self.newsManager = None @@ -61,6 +63,12 @@ class ToontownAIRepository(ToontownInternalRepository): Creates "global" (distributed) objects. """ + # Generate our district stats... + self.districtStats = ToontownDistrictStatsAI(self) + self.districtStats.settoontownDistrictId(self.districtId) + self.districtStats.generateWithRequiredAndId(self.allocateChannel(), self.district.getDoId(), + OTP_ZONE_ID_DISTRICTS_STATS) + # Generate our news manager... self.newsManager = NewsManagerAI(self) self.newsManager.generateWithRequired(OTP_ZONE_ID_MANAGEMENT) @@ -83,10 +91,10 @@ class ToontownAIRepository(ToontownInternalRepository): return self.zoneDataStore def incrementPopulation(self): - print 'TODO districtStats' + self.districtStats.b_setAvatarCount(self.districtStats.getAvatarCount() + 1) def decrementPopulation(self): - print 'TODO districtStats' + self.districtStats.b_setAvatarCount(self.districtStats.getAvatarCount() - 1) def sendQueryToonMaxHp(self, avId, callback): pass # TODO? diff --git a/toontown/distributed/ToontownDistrictStatsAI.py b/toontown/distributed/ToontownDistrictStatsAI.py index cc85434..86d4c6b 100644 --- a/toontown/distributed/ToontownDistrictStatsAI.py +++ b/toontown/distributed/ToontownDistrictStatsAI.py @@ -3,3 +3,48 @@ from direct.distributed.DistributedObjectAI import DistributedObjectAI class ToontownDistrictStatsAI(DistributedObjectAI): notify = DirectNotifyGlobal.directNotify.newCategory('ToontownDistrictStatsAI') + + def __init__(self, air): + DistributedObjectAI.__init__(self, air) + self.toontownDistrictId = 0 + self.avatarCount = 0 + self.newAvatarCount = 0 + + def settoontownDistrictId(self, toontownDistrictId): + self.toontownDistrictId = toontownDistrictId + + def d_settoontownDistrictId(self, toontownDistrictId): + self.sendUpdate('settoontownDistrictId', [toontownDistrictId]) + + def b_settoontownDistrictId(self, toontownDistrictId): + self.settoontownDistrictId(toontownDistrictId) + self.d_settoontownDistrictId(toontownDistrictId) + + def gettoontownDistrictId(self): + return self.toontownDistrictId + + def setAvatarCount(self, avatarCount): + self.avatarCount = avatarCount + + def d_setAvatarCount(self, avatarCount): + self.sendUpdate('setAvatarCount', [avatarCount]) + + def b_setAvatarCount(self, avatarCount): + self.setAvatarCount(avatarCount) + self.d_setAvatarCount(avatarCount) + + def getAvatarCount(self): + return self.avatarCount + + def setNewAvatarCount(self, newAvatarCount): + self.newAvatarCount = newAvatarCount + + def d_setNewAvatarCount(self, newAvatarCount): + self.sendUpdate('setNewAvatarCount', [newAvatarCount]) + + def b_setNewAvatarCount(self, newAvatarCount): + self.setNewAvatarCount(newAvatarCount) + self.d_setNewAvatarCount(newAvatarCount) + + def getNewAvatarCount(self): + return self.newAvatarCount diff --git a/toontown/toon/DistributedToonAI.py b/toontown/toon/DistributedToonAI.py index 215ac97..bf78bee 100644 --- a/toontown/toon/DistributedToonAI.py +++ b/toontown/toon/DistributedToonAI.py @@ -410,7 +410,7 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo def announceZoneChange(self, newZoneId, oldZoneId): from toontown.pets import PetObserve - #self.air.welcomeValleyManager.toonSetZone(self.doId, newZoneId) # TODO + self.air.welcomeValleyManager.toonSetZone(self.doId, newZoneId) broadcastZones = [oldZoneId, newZoneId] if self.isInEstate() or self.wasInEstate(): broadcastZones = union(broadcastZones, self.estateZones)