Poodletooth-iLand/toontown/coghq/DistributedStomperAI.py

43 lines
1.7 KiB
Python
Raw Normal View History

2015-03-03 22:10:12 +00:00
from otp.ai.AIBase import *
from direct.interval.IntervalGlobal import *
from direct.directnotify import DirectNotifyGlobal
import DistributedCrusherEntityAI
import StomperGlobals
from direct.distributed import ClockDelta
from toontown.coghq import CrusherCellAI
class DistributedStomperAI(DistributedCrusherEntityAI.DistributedCrusherEntityAI):
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedStomperAI')
def __init__(self, level, entId, pairId = -1):
DistributedCrusherEntityAI.DistributedCrusherEntityAI.__init__(self, level, entId)
self.pairId = pairId
def generate(self):
DistributedCrusherEntityAI.DistributedCrusherEntityAI.generate(self)
if self.switchId != 0:
self.accept(self.getOutputEventName(self.switchId), self.reactToSwitch)
self.d_startStomper()
def delete(self):
del self.pos
self.ignoreAll()
DistributedCrusherEntityAI.DistributedCrusherEntityAI.delete(self)
def d_startStomper(self):
self.sendUpdate('setMovie', [StomperGlobals.STOMPER_START, ClockDelta.globalClockDelta.getRealNetworkTime(), []])
def reactToSwitch(self, on):
if on:
crushedList = []
if self.crushCell:
self.crushCell.updateCrushables()
for id in self.crushCell.occupantIds:
if id in self.crushCell.crushables:
crushedList.append(id)
self.sendCrushMsg()
self.sendUpdate('setMovie', [StomperGlobals.STOMPER_STOMP, ClockDelta.globalClockDelta.getRealNetworkTime(), crushedList])
else:
self.sendUpdate('setMovie', [StomperGlobals.STOMPER_RISE, ClockDelta.globalClockDelta.getRealNetworkTime(), []])