mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2024-12-23 19:52:37 -06:00
35b646c4e6
This reverts commit 1e4bad8c6b
.
57 lines
1.8 KiB
Python
Executable file
57 lines
1.8 KiB
Python
Executable file
# File: D (Python 2.4)
|
|
|
|
from otp.level import DistributedEntityAI
|
|
from direct.directnotify import DirectNotifyGlobal
|
|
|
|
class DistributedCrusherEntityAI(DistributedEntityAI.DistributedEntityAI):
|
|
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedCrusherEntityAI')
|
|
|
|
def __init__(self, level, entId):
|
|
self.isCrusher = 0
|
|
self.crushCell = None
|
|
DistributedEntityAI.DistributedEntityAI.__init__(self, level, entId)
|
|
self.crushMsg = self.getUniqueName('crusherDoCrush')
|
|
|
|
|
|
def generate(self):
|
|
DistributedEntityAI.DistributedEntityAI.generate(self)
|
|
self.setActiveCrushCell()
|
|
|
|
|
|
def delete(self):
|
|
self.ignoreAll()
|
|
DistributedEntityAI.DistributedEntityAI.delete(self)
|
|
|
|
|
|
def destroy(self):
|
|
self.notify.info('destroy entity %s' % self.entId)
|
|
if self.crushCell != None:
|
|
self.crushCell.unregisterCrusher(self.entId)
|
|
self.crushCell = None
|
|
|
|
DistributedEntityAI.DistributedEntityAI.destroy(self)
|
|
|
|
|
|
def setActiveCrushCell(self):
|
|
self.notify.debug('setActiveCrushCell, entId: %d' % self.entId)
|
|
if self.crushCellId != None:
|
|
self.crushCell = self.level.entities.get(self.crushCellId, None)
|
|
if self.crushCell == None:
|
|
self.accept(self.level.getEntityCreateEvent(self.crushCellId), self.setActiveCrushCell)
|
|
else:
|
|
self.isCrusher = 1
|
|
self.crushCell.registerCrusher(self.entId)
|
|
|
|
|
|
|
|
def sendCrushMsg(self, axis = 0):
|
|
if self.isCrusher:
|
|
messenger.send(self.crushMsg, [
|
|
self.entId,
|
|
axis])
|
|
|
|
|
|
|
|
def getPosition(self):
|
|
if hasattr(self, 'pos'):
|
|
return self.pos
|