Poodletooth-iLand/toontown/estate/DistributedPlantBaseAI.py

81 lines
2.5 KiB
Python
Raw Normal View History

2015-03-03 16:10:12 -06:00
from direct.directnotify import DirectNotifyGlobal
from toontown.estate.DistributedLawnDecorAI import DistributedLawnDecorAI
2015-05-24 18:23:54 -05:00
import GardenGlobals
2015-03-03 16:10:12 -06:00
class DistributedPlantBaseAI(DistributedLawnDecorAI):
2015-07-20 14:53:53 -05:00
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedPlantBaseAI')
2015-05-24 18:23:54 -05:00
2015-07-20 14:53:53 -05:00
def __init__(self, mgr):
DistributedLawnDecorAI.__init__(self, mgr)
self.typeIndex = 0
self.waterLevel = 0
self.growthLevel = 0
2015-05-24 18:23:54 -05:00
def setTypeIndex(self, typeIndex):
self.typeIndex = typeIndex
self.attributes = GardenGlobals.PlantAttributes[typeIndex]
self.growthThresholds = self.attributes['growthThresholds']
2015-07-20 14:53:53 -05:00
def d_setTypeIndex(self, typeIndex):
self.sendUpdate('setTypeIndex', [typeIndex])
def b_setTypeIndex(self, typeIndex):
self.setTypeIndex(typeIndex)
self.d_setTypeIndex(typeIndex)
2015-05-24 18:23:54 -05:00
def getTypeIndex(self):
return self.typeIndex
2015-03-03 16:10:12 -06:00
2015-07-20 14:53:53 -05:00
def setWaterLevel(self, waterLevel):
self.waterLevel = waterLevel
def d_setWaterLevel(self, waterLevel):
self.sendUpdate('setWaterLevel', [waterLevel])
def b_setWaterLevel(self, waterLevel):
self.setWaterLevel(waterLevel)
self.d_setWaterLevel(waterLevel)
2015-05-24 18:23:54 -05:00
def getWaterLevel(self):
return self.waterLevel
2015-03-03 16:10:12 -06:00
2015-07-20 14:53:53 -05:00
def setGrowthLevel(self, growthLevel):
self.growthLevel = growthLevel
def d_setGrowthLevel(self, growthLevel):
self.sendUpdate('setGrowthLevel', [growthLevel])
def b_setGrowthLevel(self, growthLevel):
self.setGrowthLevel(growthLevel)
self.d_setGrowthLevel(growthLevel)
2015-05-24 18:23:54 -05:00
def getGrowthLevel(self):
return self.growthLevel
2015-03-03 16:10:12 -06:00
2015-07-20 14:53:53 -05:00
def waterPlant(self):
av = self.air.doId2do.get(self.air.getAvatarIdFromSender())
if not av:
return
level = max(1, self.getWaterLevel() + av.getWateringCan() + 1)
level = min(20, level)
self.b_setWaterLevel(level)
self.d_setMovie(GardenGlobals.MOVIE_WATER)
self.update()
2015-03-03 16:10:12 -06:00
def waterPlantDone(self):
2015-07-20 14:53:53 -05:00
av = self.air.doId2do.get(self.air.getAvatarIdFromSender())
if not av:
return
if self.waterLevel < 6:
av.b_setWateringCanSkill(av.getWateringCanSkill() + 1)
else:
av.b_setWateringCanSkill(av.getWateringCanSkill())
self.d_setMovie(GardenGlobals.MOVIE_CLEAR)
def update(self):
pass