oldschool-toontown/toontown/coghq/DistributedFactoryElevatorExtAI.py

51 lines
1.9 KiB
Python
Raw Normal View History

2019-11-02 22:27:54 +00:00
from otp.ai.AIBase import *
from toontown.toonbase import ToontownGlobals
from direct.distributed.ClockDelta import *
from toontown.building.ElevatorConstants import *
from toontown.building import DistributedElevatorExtAI
from direct.fsm import ClassicFSM
from direct.fsm import State
from direct.task import Task
class DistributedFactoryElevatorExtAI(DistributedElevatorExtAI.DistributedElevatorExtAI):
def __init__(self, air, bldg, factoryId, entranceId, antiShuffle=0, minLaff=0):
DistributedElevatorExtAI.DistributedElevatorExtAI.__init__(self, air, bldg, antiShuffle=antiShuffle, minLaff=minLaff)
self.factoryId = factoryId
self.entranceId = entranceId
def getEntranceId(self):
return self.entranceId
def elevatorClosed(self):
numPlayers = self.countFullSeats()
if numPlayers > 0:
players = []
for i in self.seats:
if i not in [None, 0]:
players.append(i)
factoryZone = self.bldg.createFactory(self.factoryId, self.entranceId, players)
for seatIndex in range(len(self.seats)):
avId = self.seats[seatIndex]
if avId:
self.sendUpdateToAvatarId(avId, 'setFactoryInteriorZone', [factoryZone])
self.clearFullNow(seatIndex)
else:
self.notify.warning('The elevator left, but was empty.')
self.fsm.request('closed')
return
def enterClosed(self):
DistributedElevatorExtAI.DistributedElevatorExtAI.enterClosed(self)
self.fsm.request('opening')
def sendAvatarsToDestination(self, avIdList):
if len(avIdList) > 0:
factoryZone = self.bldg.createFactory(self.factoryId, self.entranceId, avIdList)
for avId in avIdList:
if avId:
self.sendUpdateToAvatarId(avId, 'setFactoryInteriorZoneForce', [
factoryZone])