oldschool-toontown/toontown/coghq/DistributedSinkingPlatformAI.py

25 lines
1,008 B
Python
Raw Normal View History

2019-11-02 17:27:54 -05:00
from otp.ai.AIBase import *
from direct.directnotify import DirectNotifyGlobal
from otp.level import DistributedEntityAI
from . import SinkingPlatformGlobals
2019-11-02 17:27:54 -05:00
class DistributedSinkingPlatformAI(DistributedEntityAI.DistributedEntityAI):
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedSinkingPlatformAI')
def __init__(self, levelDoId, entId):
DistributedEntityAI.DistributedEntityAI.__init__(self, levelDoId, entId)
self.numStanding = 0
def setOnOff(self, on, timestamp):
avId = self.air.getAvatarIdFromSender()
self.notify.debug('setOnOff %s' % on)
if on:
self.numStanding += 1
else:
self.numStanding -= 1
self.notify.debug('numStanding = %s' % self.numStanding)
if self.numStanding > 0:
self.sendUpdate('setSinkMode', [avId, SinkingPlatformGlobals.SINKING, timestamp])
else:
self.sendUpdate('setSinkMode', [avId, SinkingPlatformGlobals.RISING, timestamp])