def shutdown(self): self.ignore('holidayStart-%d' % ToontownGlobals.APRIL_FOOLS_COSTUMES) self.ignore('holidayEnd-%d' % ToontownGlobals.APRIL_FOOLS_COSTUMES) self.setRedirect(None) if self.treasurePlanner: self.treasurePlanner.stop() self.treasurePlanner.deleteAllTreasuresNow() self.treasurePlanner = None for suitPlanner in self.suitPlanners: suitPlanner.requestDelete() del self.air.suitPlanners[suitPlanner.zoneId] self.suitPlanners = [] for buildingManager in self.buildingManagers: buildingManager.cleanup() del self.air.buildingManagers[buildingManager.branchID] self.buildingManagers = [] ButterflyGlobals.clearIndexes(self.zoneId) for distObj in self.doId2do.values(): distObj.requestDelete() del self.doId2do del self.air return
def shutdown(self): self.setRedirect(None) if self.treasurePlanner: self.treasurePlanner.stop() self.treasurePlanner.deleteAllTreasuresNow() self.treasurePlanner = None for suitPlanner in self.suitPlanners: suitPlanner.requestDelete() del self.air.suitPlanners[suitPlanner.zoneId] self.suitPlanners = [] for buildingManager in self.buildingManagers: buildingManager.cleanup() del self.air.buildingManagers[buildingManager.branchID] self.buildingManagers = [] ButterflyGlobals.clearIndexes(self.zoneId) del self.fishingPonds for distObj in self.doId2do.values(): distObj.requestDelete() del self.doId2do # Break back-pointers del self.air
def createButterflies(self): ButterflyGlobals.generateIndexes(self.zoneId, ButterflyGlobals.TTC) for i in xrange(0, ButterflyGlobals.NUM_BUTTERFLY_AREAS[ButterflyGlobals.TTC]): for _ in xrange(0, ButterflyGlobals.NUM_BUTTERFLIES[ButterflyGlobals.TTC]): butterfly = DistributedButterflyAI(self.air, playground, i, self.zoneId) butterfly.generateWithRequired(self.zoneId) butterfly.start()
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 createButterflies(self, playground): ButterflyGlobals.generateIndexes(self.zoneId, playground) for i in range(0, ButterflyGlobals.NUM_BUTTERFLY_AREAS[playground]): for j in range(0, ButterflyGlobals.NUM_BUTTERFLIES[playground]): bfly = DistributedButterflyAI.DistributedButterflyAI(self.air, playground, i, self.zoneId) bfly.generateWithRequired(self.zoneId) bfly.start() self.addDistObj(bfly)
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 generate(self): DistributedObjectAI.generate(self) self.pond = DistributedFishingPondAI(simbase.air) self.pond.setArea(ToontownGlobals.MyEstate) self.pond.generateWithRequired(self.zoneId) for i in range( FishingTargetGlobals.getNumTargets(ToontownGlobals.MyEstate)): target = DistributedFishingTargetAI(self.air) target.setPondDoId(self.pond.getDoId()) target.generateWithRequired(self.zoneId) self.targets.append(target) self.treasurePlanner = ETreasurePlannerAI.ETreasurePlannerAI( self.zoneId) self.treasurePlanner.start() spot = DistributedFishingSpotAI(self.air) spot.setPondDoId(self.pond.getDoId()) spot.setPosHpr(49.1029, -124.805, 0.344704, 90, 0, 0) spot.generateWithRequired(self.zoneId) self.spots.append(spot) spot = DistributedFishingSpotAI(self.air) spot.setPondDoId(self.pond.getDoId()) spot.setPosHpr(46.5222, -134.739, 0.390713, 75, 0, 0) spot.generateWithRequired(self.zoneId) self.spots.append(spot) spot = DistributedFishingSpotAI(self.air) spot.setPondDoId(self.pond.getDoId()) spot.setPosHpr(41.31, -144.559, 0.375978, 45, 0, 0) spot.generateWithRequired(self.zoneId) self.spots.append(spot) spot = DistributedFishingSpotAI(self.air) spot.setPondDoId(self.pond.getDoId()) spot.setPosHpr(46.8254, -113.682, 0.46015, 135, 0, 0) spot.generateWithRequired(self.zoneId) self.spots.append(spot) ButterflyGlobals.generateIndexes(self.zoneId, ButterflyGlobals.ESTATE) for i in range( 0, ButterflyGlobals.NUM_BUTTERFLY_AREAS[ButterflyGlobals.ESTATE]): for j in range( 0, ButterflyGlobals.NUM_BUTTERFLIES[ButterflyGlobals.ESTATE]): bfly = DistributedButterflyAI.DistributedButterflyAI( self.air, ButterflyGlobals.ESTATE, i, self.zoneId) bfly.generateWithRequired(self.zoneId) bfly.start() self.addDistObj(bfly)
def delete(self): try: self.butterfly_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 generate(self): DistributedObjectAI.generate(self) self.pond = DistributedFishingPondAI(simbase.air) self.pond.setArea(ToontownGlobals.MyEstate) self.pond.generateWithRequired(self.zoneId) self.pond.start() treasureType, healAmount, spawnPoints, spawnRate, maxTreasures = TreasureGlobals.SafeZoneTreasureSpawns[ToontownGlobals.MyEstate] self.treasurePlanner = SZTreasurePlannerAI(self.zoneId, treasureType, healAmount, spawnPoints, spawnRate, maxTreasures) self.treasurePlanner.start() spot = DistributedFishingSpotAI(self.air) spot.setPondDoId(self.pond.getDoId()) spot.setPosHpr(49.1029, -124.805, 0.344704, 90, 0, 0) spot.generateWithRequired(self.zoneId) self.spots.append(spot) spot = DistributedFishingSpotAI(self.air) spot.setPondDoId(self.pond.getDoId()) spot.setPosHpr(46.5222, -134.739, 0.390713, 75, 0, 0) spot.generateWithRequired(self.zoneId) self.spots.append(spot) spot = DistributedFishingSpotAI(self.air) spot.setPondDoId(self.pond.getDoId()) spot.setPosHpr(41.31, -144.559, 0.375978, 45, 0, 0) spot.generateWithRequired(self.zoneId) self.spots.append(spot) spot = DistributedFishingSpotAI(self.air) spot.setPondDoId(self.pond.getDoId()) spot.setPosHpr(46.8254, -113.682, 0.46015, 135, 0, 0) spot.generateWithRequired(self.zoneId) self.spots.append(spot) self.jukebox = DistributedPartyJukeboxActivityAI(self.air, self.doId, (0, 0, 0, 0)) self.jukebox.generateWithRequired(self.zoneId) self.jukebox.sendUpdate('setX', [-21.8630]) self.jukebox.sendUpdate('setY', [-154.669]) self.jukebox.sendUpdate('setH', [148.7050]) self.jukebox.sendUpdate('unloadSign') ButterflyGlobals.generateIndexes(self.zoneId, ButterflyGlobals.ESTATE) for i in xrange(0, ButterflyGlobals.NUM_BUTTERFLY_AREAS[ButterflyGlobals.ESTATE]): for j in xrange(0, ButterflyGlobals.NUM_BUTTERFLIES[ButterflyGlobals.ESTATE]): butterfly = DistributedButterflyAI.DistributedButterflyAI(self.air, ButterflyGlobals.ESTATE, i, self.zoneId) butterfly.generateWithRequired(self.zoneId) butterfly.start() self.butterflies.append(butterfly)
def generate(self): DistributedObjectAI.generate(self) self.pond = DistributedFishingPondAI(simbase.air) self.pond.setArea(ToontownGlobals.MyEstate) self.pond.generateWithRequired(self.zoneId) for i in range(FishingTargetGlobals.getNumTargets(ToontownGlobals.MyEstate)): target = DistributedFishingTargetAI(self.air) target.setPondDoId(self.pond.getDoId()) target.generateWithRequired(self.zoneId) self.targets.append(target) self.treasurePlanner = ETreasurePlannerAI.ETreasurePlannerAI(self.zoneId) self.treasurePlanner.start() spot = DistributedFishingSpotAI(self.air) spot.setPondDoId(self.pond.getDoId()) spot.setPosHpr(49.1029, -124.805, 0.344704, 90, 0, 0) spot.generateWithRequired(self.zoneId) self.spots.append(spot) spot = DistributedFishingSpotAI(self.air) spot.setPondDoId(self.pond.getDoId()) spot.setPosHpr(46.5222, -134.739, 0.390713, 75, 0, 0) spot.generateWithRequired(self.zoneId) self.spots.append(spot) spot = DistributedFishingSpotAI(self.air) spot.setPondDoId(self.pond.getDoId()) spot.setPosHpr(41.31, -144.559, 0.375978, 45, 0, 0) spot.generateWithRequired(self.zoneId) self.spots.append(spot) spot = DistributedFishingSpotAI(self.air) spot.setPondDoId(self.pond.getDoId()) spot.setPosHpr(46.8254, -113.682, 0.46015, 135, 0, 0) spot.generateWithRequired(self.zoneId) self.spots.append(spot) ButterflyGlobals.generateIndexes(self.zoneId, ButterflyGlobals.ESTATE) for i in range(0, ButterflyGlobals.NUM_BUTTERFLY_AREAS[ButterflyGlobals.ESTATE]): for j in range(0, ButterflyGlobals.NUM_BUTTERFLIES[ButterflyGlobals.ESTATE]): bfly = DistributedButterflyAI.DistributedButterflyAI(self.air, ButterflyGlobals.ESTATE, i, self.zoneId) bfly.generateWithRequired(self.zoneId) bfly.start() self.addDistObj(bfly)
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 generate(self): DistributedObjectAI.generate(self) self.pond = DistributedFishingPondAI(simbase.air) self.pond.setArea(ToontownGlobals.MyEstate) self.pond.generateWithRequired(self.zoneId) self.pond.start() treasureType, healAmount, spawnPoints, spawnRate, maxTreasures = TreasureGlobals.SafeZoneTreasureSpawns[ToontownGlobals.MyEstate] self.treasurePlanner = SZTreasurePlannerAI(self.zoneId, treasureType, healAmount, spawnPoints, spawnRate, maxTreasures) self.treasurePlanner.start() spot = DistributedFishingSpotAI(self.air) spot.setPondDoId(self.pond.getDoId()) spot.setPosHpr(49.1029, -124.805, 0.344704, 90, 0, 0) spot.generateWithRequired(self.zoneId) self.spots.append(spot) spot = DistributedFishingSpotAI(self.air) spot.setPondDoId(self.pond.getDoId()) spot.setPosHpr(46.5222, -134.739, 0.390713, 75, 0, 0) spot.generateWithRequired(self.zoneId) self.spots.append(spot) spot = DistributedFishingSpotAI(self.air) spot.setPondDoId(self.pond.getDoId()) spot.setPosHpr(41.31, -144.559, 0.375978, 45, 0, 0) spot.generateWithRequired(self.zoneId) self.spots.append(spot) spot = DistributedFishingSpotAI(self.air) spot.setPondDoId(self.pond.getDoId()) spot.setPosHpr(46.8254, -113.682, 0.46015, 135, 0, 0) spot.generateWithRequired(self.zoneId) self.spots.append(spot) ButterflyGlobals.generateIndexes(self.zoneId, ButterflyGlobals.ESTATE) for i in xrange(0, ButterflyGlobals.NUM_BUTTERFLY_AREAS[ButterflyGlobals.ESTATE]): for j in xrange(0, ButterflyGlobals.NUM_BUTTERFLIES[ButterflyGlobals.ESTATE]): butterfly = DistributedButterflyAI.DistributedButterflyAI(self.air, ButterflyGlobals.ESTATE, i, self.zoneId) butterfly.generateWithRequired(self.zoneId) butterfly.start() self.butterflies.append(butterfly)
def shutdown(self): self.setRedirect(None) if self.treasurePlanner: self.treasurePlanner.stop() self.treasurePlanner.deleteAllTreasuresNow() self.treasurePlanner = None for suitPlanner in self.suitPlanners: suitPlanner.requestDelete() del self.air.suitPlanners[suitPlanner.zoneId] self.suitPlanners = [] for buildingManager in self.buildingManagers: buildingManager.cleanup() del self.air.buildingManagers[buildingManager.branchID] self.buildingManagers = [] ButterflyGlobals.clearIndexes(self.zoneId) del self.fishingPonds for distObj in self.doId2do.values(): distObj.requestDelete() del self.doId2do del self.air
def __init__(self, air, playground, area, ownerId): 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']) ], '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 shutdown(self): HoodAI.HoodAI.shutdown(self) ButterflyGlobals.clearIndexes(self.zoneId)
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