def delete(self): ButterflyGlobals.recycleIndex(self.curIndex, self.playground, self.area, self.ownerId) ButterflyGlobals.recycleIndex(self.destIndex, self.playground, self.area, self.ownerId) self.fsm.request('off') del self.fsm DistributedObjectAI.delete(self)
def generate(self): ButterflyGlobals.generateIndexes(self.doId, self.playground) fr = ButterflyGlobals.getFirstRoute(self.playground, self.area, self.doId) self.b_setState(ButterflyGlobals.FLYING, fr[1], fr[3], fr[4], globalClockDelta.getRealNetworkTime()) taskMgr.doMethodLater(fr[4], self.__land, 'landButterfly%i' % self.doId, [])
def enterFlying(self): self.stateIndex = ButterflyGlobals.FLYING ButterflyGlobals.recycleIndex(self.curIndex, self.playground, self.area, self.ownerId) self.d_setState(ButterflyGlobals.FLYING, self.curIndex, self.destIndex, self.time) taskMgr.doMethodLater(self.time, self._DistributedButterflyAI__handleArrival, self.uniqueName('butter-flying'))
def enterFlying(self): self.stateIndex = ButterflyGlobals.FLYING # We can let someone else fly to curPos now ButterflyGlobals.recycleIndex(self.curIndex, self.playground, self.area, self.ownerId) self.d_setState(ButterflyGlobals.FLYING, self.curIndex, self.destIndex, self.time) taskMgr.doMethodLater(self.time, self.__handleArrival, self.uniqueName('butter-flying')) return None
def delete(self): try: pass except: self.butterfly_deleted = 1 ButterflyGlobals.recycleIndex(self.curIndex, self.playground, self.area, self.ownerId) ButterflyGlobals.recycleIndex(self.destIndex, self.playground, self.area, self.ownerId) self.fsm.request('off') del self.fsm DistributedObjectAI.DistributedObjectAI.delete(self)
def delete(self): try: self.butterfly_deleted assert (self.notify.debug("butterfly already deleted")) except: self.butterfly_deleted = 1 ButterflyGlobals.recycleIndex(self.curIndex, self.playground, self.area, self.ownerId) ButterflyGlobals.recycleIndex(self.destIndex, self.playground, self.area, self.ownerId) self.fsm.request('off') del self.fsm DistributedObjectAI.DistributedObjectAI.delete(self)
def __ready(self, task=None): # Figure out where to go (self.destPos, self.destIndex, self.time) = ButterflyGlobals.getNextPos(self.curPos, self.playground, self.area, self.ownerId) self.fsm.request('Flying') return Task.done
def __init__(self, air, playground, area, ownerId): """__init__(air, area) """ DistributedObjectAI.DistributedObjectAI.__init__(self, air) self.playground = playground self.area = area self.ownerId = ownerId self.fsm = ClassicFSM.ClassicFSM( 'DistributedButterfliesAI', [ State.State('off', self.enterOff, self.exitOff, ['Flying', 'Landed']), State.State('Flying', self.enterFlying, self.exitFlying, ['Landed']), State.State('Landed', self.enterLanded, self.exitLanded, ['Flying']), ], # Initial State 'off', # Final State 'off', ) self.fsm.enterInitialState() (self.curPos, self.curIndex, self.destPos, self.destIndex, self.time) = ButterflyGlobals.getFirstRoute(self.playground, self.area, self.ownerId) return None
def __fly(self): next = ButterflyGlobals.getNextPos( ButterflyGlobals.ButterflyPoints[self.playground][self.area][ self.destIndex], self.playground, self.area, self.doId) self.b_setState(ButterflyGlobals.FLYING, self.destIndex, next[1], next[2], globalClockDelta.getRealNetworkTime()) taskMgr.doMethodLater(next[2], self.__land, 'landButterfly%i' % self.doId, [])
def __init__(self, air, playground, area, ownerId): DistributedObjectAI.__init__(self, air) self.playground = playground self.area = area self.ownerId = ownerId self.fsm = ClassicFSM.ClassicFSM('DistributedButterfliesAI', [State.State('off', self.enterOff, self.exitOff, ['Flying', 'Landed']), State.State('Flying', self.enterFlying, self.exitFlying, ['Landed']), State.State('Landed', self.enterLanded, self.exitLanded, ['Flying'])], 'off', 'off') self.fsm.enterInitialState() self.curPos, self.curIndex, self.destPos, self.destIndex, self.time = ButterflyGlobals.getFirstRoute(self.playground, self.area, self.ownerId) return None
def __fly(self): next = ButterflyGlobals.getNextPos(ButterflyGlobals.ButterflyPoints[self.playground][self.area][self.destIndex], self.playground, self.area, self.doId) self.b_setState(ButterflyGlobals.FLYING, self.destIndex, next[1], next[2], globalClockDelta.getRealNetworkTime()) taskMgr.doMethodLater(next[2], self.__land, 'landButterfly%i' % self.doId, [])
def __ready(self, task = None): self.destPos, self.destIndex, self.time = ButterflyGlobals.getNextPos(self.curPos, self.playground, self.area, self.ownerId) self.fsm.request('Flying') return Task.done
def enterFlying(self): self.stateIndex = ButterflyGlobals.FLYING ButterflyGlobals.recycleIndex(self.curIndex, self.playground, self.area, self.ownerId) self.d_setState(ButterflyGlobals.FLYING, self.curIndex, self.destIndex, self.time) taskMgr.doMethodLater(self.time, self.__handleArrival, self.uniqueName('butter-flying')) return None
def _DistributedButterflyAI__ready(self, task=None): (self.destPos, self.destIndex, self.time) = ButterflyGlobals.getNextPos(self.curPos, self.playground, self.area, self.ownerId) self.fsm.request('Flying') return Task.done