2019-11-02 17:27:54 -05:00
|
|
|
from toontown.toonbase.ToontownGlobals import *
|
|
|
|
from otp.ai.AIBaseGlobal import *
|
|
|
|
from direct.distributed.ClockDelta import *
|
2019-12-30 00:07:56 -06:00
|
|
|
import pickle
|
2019-11-02 17:27:54 -05:00
|
|
|
from direct.directnotify import DirectNotifyGlobal
|
|
|
|
from direct.fsm import ClassicFSM, State
|
|
|
|
from direct.distributed import DistributedObjectAI
|
|
|
|
from direct.fsm import State
|
|
|
|
from toontown.toon import NPCToons
|
2021-07-21 23:42:56 -05:00
|
|
|
from toontown.toon.ToonDNA import ToonDNA
|
2019-11-02 17:27:54 -05:00
|
|
|
|
|
|
|
class DistributedToonInteriorAI(DistributedObjectAI.DistributedObjectAI):
|
|
|
|
|
|
|
|
def __init__(self, block, air, zoneId, building):
|
|
|
|
DistributedObjectAI.DistributedObjectAI.__init__(self, air)
|
|
|
|
self.block = block
|
|
|
|
self.zoneId = zoneId
|
|
|
|
self.building = building
|
|
|
|
self.npcs = NPCToons.createNpcsInZone(air, zoneId)
|
|
|
|
self.fsm = ClassicFSM.ClassicFSM('DistributedToonInteriorAI', [
|
|
|
|
State.State('toon', self.enterToon, self.exitToon, [
|
|
|
|
'beingTakenOver']),
|
|
|
|
State.State('beingTakenOver', self.enterBeingTakenOver, self.exitBeingTakenOver, []),
|
|
|
|
State.State('off', self.enterOff, self.exitOff, [])], 'toon', 'off')
|
|
|
|
self.fsm.enterInitialState()
|
|
|
|
|
|
|
|
def delete(self):
|
|
|
|
self.ignoreAll()
|
|
|
|
for npc in self.npcs:
|
|
|
|
npc.requestDelete()
|
|
|
|
|
|
|
|
del self.npcs
|
|
|
|
del self.fsm
|
|
|
|
del self.building
|
|
|
|
DistributedObjectAI.DistributedObjectAI.delete(self)
|
|
|
|
|
|
|
|
def getZoneIdAndBlock(self):
|
|
|
|
r = [
|
|
|
|
self.zoneId, self.block]
|
|
|
|
return r
|
|
|
|
|
2021-07-21 23:42:56 -05:00
|
|
|
def getSavedBy(self):
|
|
|
|
savedBy = []
|
|
|
|
for avId, name, dnaTuple in self.building.savedBy:
|
|
|
|
dna = ToonDNA()
|
|
|
|
dna.newToonFromProperties(*dnaTuple)
|
|
|
|
savedBy.append([avId, name, dna.makeNetString()])
|
|
|
|
return savedBy
|
2019-11-02 17:27:54 -05:00
|
|
|
|
|
|
|
def getState(self):
|
|
|
|
r = [
|
|
|
|
self.fsm.getCurrentState().getName(), globalClockDelta.getRealNetworkTime()]
|
|
|
|
return r
|
|
|
|
|
|
|
|
def setState(self, state):
|
|
|
|
self.sendUpdate('setState', [state, globalClockDelta.getRealNetworkTime()])
|
|
|
|
self.fsm.request(state)
|
|
|
|
|
|
|
|
def enterOff(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def exitOff(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def enterToon(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def exitToon(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def enterBeingTakenOver(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def exitBeingTakenOver(self):
|
|
|
|
pass
|