2019-11-02 17:27:54 -05:00
|
|
|
from direct.directnotify import DirectNotifyGlobal
|
2019-12-30 00:07:56 -06:00
|
|
|
from . import DistributedLawOfficeAI, DistributedStageAI
|
2019-11-02 17:27:54 -05:00
|
|
|
from toontown.coghq import StageLayout
|
|
|
|
from toontown.toonbase import ToontownGlobals
|
|
|
|
from direct.showbase import DirectObject
|
|
|
|
import random
|
|
|
|
StageId2Layouts = {ToontownGlobals.LawbotStageIntA: (0, 1, 2), ToontownGlobals.LawbotStageIntB: (3, 4, 5), ToontownGlobals.LawbotStageIntC: (6, 7, 8), ToontownGlobals.LawbotStageIntD: (9, 10, 11)}
|
|
|
|
|
|
|
|
class LawOfficeManagerAI(DirectObject.DirectObject):
|
|
|
|
notify = DirectNotifyGlobal.directNotify.newCategory('LawOfficeManagerAI')
|
|
|
|
lawOfficeId = None
|
|
|
|
|
|
|
|
def __init__(self, air):
|
|
|
|
DirectObject.DirectObject.__init__(self)
|
|
|
|
self.air = air
|
|
|
|
|
|
|
|
def getDoId(self):
|
|
|
|
return 0
|
|
|
|
|
|
|
|
def createLawOffice(self, StageId, entranceId, players):
|
|
|
|
for avId in players:
|
|
|
|
if bboard.has('StageId-%s' % avId):
|
|
|
|
StageId = bboard.get('StageId-%s' % avId)
|
|
|
|
break
|
|
|
|
|
|
|
|
floor = 0
|
|
|
|
layoutIndex = None
|
|
|
|
for avId in players:
|
|
|
|
if bboard.has('stageRoom-%s' % avId):
|
|
|
|
roomId = bboard.get('stageRoom-%s' % avId)
|
|
|
|
for lt in StageId2Layouts[StageId]:
|
2019-12-30 00:07:56 -06:00
|
|
|
for i in range(StageLayout.getNumFloors(lt)):
|
2019-11-02 17:27:54 -05:00
|
|
|
layout = StageLayout.StageLayout(StageId, i, stageLayout=lt)
|
|
|
|
if roomId in layout.getRoomIds():
|
|
|
|
layoutIndex = lt
|
|
|
|
floor = i
|
|
|
|
|
|
|
|
else:
|
|
|
|
from toontown.coghq import StageRoomSpecs
|
|
|
|
roomName = StageRoomSpecs.CashbotStageRoomId2RoomName[roomId]
|
|
|
|
LawOfficeManagerAI.notify.warning('room %s (%s) not found in any floor of Stage %s' % (roomId, roomName, StageId))
|
|
|
|
|
|
|
|
StageZone = self.air.allocateZone()
|
|
|
|
if layoutIndex is None:
|
|
|
|
layoutIndex = random.choice(StageId2Layouts[StageId])
|
|
|
|
Stage = DistributedStageAI.DistributedStageAI(self.air, StageId, StageZone, floor, players, layoutIndex)
|
|
|
|
Stage.generateWithRequired(StageZone)
|
|
|
|
return StageZone
|