Пример #1
0
 def enterToon(self):
     self.d_setState('toon')
     (exteriorZoneId, interiorZoneId) = self.getExteriorAndInteriorZoneId()
     if simbase.config.GetBool(
             'want-new-toonhall',
             1) and ZoneUtil.getCanonicalZoneId(interiorZoneId) == ToonHall:
         self.interior = DistributedToonHallInteriorAI.DistributedToonHallInteriorAI(
             self.block, self.air, interiorZoneId, self)
     else:
         self.interior = DistributedToonInteriorAI.DistributedToonInteriorAI(
             self.block, self.air, interiorZoneId, self)
     self.interior.generateWithRequired(interiorZoneId)
     door = self.createExteriorDoor()
     insideDoor = DistributedDoorAI.DistributedDoorAI(
         self.air, self.block, DoorTypes.INT_STANDARD)
     door.setOtherDoor(insideDoor)
     insideDoor.setOtherDoor(door)
     door.zoneId = exteriorZoneId
     insideDoor.zoneId = interiorZoneId
     door.generateWithRequired(exteriorZoneId)
     insideDoor.generateWithRequired(interiorZoneId)
     self.door = door
     self.insideDoor = insideDoor
     self.becameSuitTime = 0
     self.knockKnock = DistributedKnockKnockDoorAI.DistributedKnockKnockDoorAI(
         self.air, self.block)
     self.knockKnock.generateWithRequired(exteriorZoneId)
     self.air.writeServerEvent('building-toon', self.doId,
                               '%s|%s' % (self.zoneId, self.block))
Пример #2
0
    def enterToon(self):
        assert (self.debugPrint("enterToon()"))
        self.d_setState('toon')
        # Create the DistributedDoor:
        exteriorZoneId, interiorZoneId = self.getExteriorAndInteriorZoneId()
        # Toon interior:
        if simbase.config.GetBool("want-new-toonhall",1) and \
           ZoneUtil.getCanonicalZoneId(interiorZoneId)== ToonHall:
            self.interior = DistributedToonHallInteriorAI.DistributedToonHallInteriorAI(
                self.block, self.air, interiorZoneId, self)
        else:
            self.interior = DistributedToonInteriorAI.DistributedToonInteriorAI(
                self.block, self.air, interiorZoneId, self)
        self.interior.generateWithRequired(interiorZoneId)

        # Outside door:
        door = self.createExteriorDoor()
        # Inside of the same door (different zone, and different distributed object):
        insideDoor = DistributedDoorAI.DistributedDoorAI(
            self.air, self.block, DoorTypes.INT_STANDARD)
        # Tell them about each other:
        door.setOtherDoor(insideDoor)
        insideDoor.setOtherDoor(door)
        door.zoneId = exteriorZoneId
        insideDoor.zoneId = interiorZoneId
        # Now that they both now about each other, generate them:
        door.generateWithRequired(exteriorZoneId)
        insideDoor.generateWithRequired(interiorZoneId)
        # keep track of them:
        self.door = door
        self.insideDoor = insideDoor
        self.becameSuitTime = 0

        self.knockKnock = DistributedKnockKnockDoorAI.DistributedKnockKnockDoorAI(
            self.air, self.block)
        self.knockKnock.generateWithRequired(exteriorZoneId)

        self.air.writeServerEvent('building-toon', self.doId,
                                  "%s|%s" % (self.zoneId, self.block))
 def enterToon(self):
     self.d_setState('toon')
     (exteriorZoneId, interiorZoneId) = self.getExteriorAndInteriorZoneId()
     self.interior = DistributedToonInteriorAI.DistributedToonInteriorAI(
         self.block, self.air, interiorZoneId, self)
     self.interior.generateWithRequired(interiorZoneId)
     door = self.createExteriorDoor()
     insideDoor = DistributedDoorAI.DistributedDoorAI(
         self.air, self.block, DoorTypes.INT_STANDARD)
     door.setOtherDoor(insideDoor)
     insideDoor.setOtherDoor(door)
     door.zoneId = exteriorZoneId
     insideDoor.zoneId = interiorZoneId
     door.generateWithRequired(exteriorZoneId)
     insideDoor.generateWithRequired(interiorZoneId)
     self.door = door
     self.insideDoor = insideDoor
     self.becameSuitTime = 0
     self.knockKnock = DistributedKnockKnockDoorAI.DistributedKnockKnockDoorAI(
         self.air, self.block)
     self.knockKnock.generateWithRequired(exteriorZoneId)
     self.air.writeServerEvent('building-toon', self.doId,
                               '%s|%s' % (self.zoneId, self.block))
Пример #4
0
    def startup(self):
        self.createTreasurePlanner()

        self.notify.info("Creating objects in hood %s.." % self.hood)
        interiorZoneAllocator = UniqueIdAllocator(self.zoneId + 400,
                                                  self.zoneId + 999)
        for dnaFile in self.dnaFiles:
            zoneId = 0
            isSZ = False
            if 'sz' in dnaFile:
                isSZ = True
                zoneId = self.zoneId
            else:
                for segment in dnaFile.split('_'):
                    if segment.endswith('dna'):
                        segment = segment[:4]
                        if segment.isdigit():
                            zoneId = int(segment)
                            break
            dnaStore = DNAStorage()
            dnaData = loadDNAFileAI(dnaStore, dnaFile)
            self.air.dnaStoreMap[zoneId] = dnaStore
            self.air.dnaDataMap[zoneId] = dnaData
            self.buildings[zoneId] = []
            blockZoneByNumber = {}
            for i in range(dnaStore.get_num_block_numbers()):
                blockNumber = dnaStore.get_block_number_at(i)
                blockZoneByNumber[
                    blockNumber] = dnaStore.get_zone_from_block_number(
                        blockNumber)
            for block, exteriorZone in blockZoneByNumber.items():
                buildingType = dnaStore.get_block_building_type(block)
                interiorZone = (
                    ZoneUtil.getBranchZone(zoneId) -
                    (ZoneUtil.getBranchZone(zoneId) % 100)) + 500 + block
                if isSZ or (not isSZ and buildingType in ['hq']):
                    if not buildingType:
                        interior = DistributedToonInteriorAI.DistributedToonInteriorAI(
                            self.air, block, exteriorZone)
                        interior.generateWithRequired(interiorZone)
                        door = DistributedDoorAI.DistributedDoorAI(
                            self.air, block, interiorZone, 1)
                        door.generateWithRequired(exteriorZone)
                        self.exteriorDoors.append(door)
                        self.interiors.append(interior)
                    elif buildingType == 'cinema':
                        cinemaIndex = CinemaGlobals.Zone2Block2CinemaIndex[
                            zoneId][block]
                        interior = DistributedCinemaInteriorAI.DistributedCinemaInteriorAI(
                            self.air, block, exteriorZone, cinemaIndex)
                        interior.generateWithRequired(interiorZone)
                        door = DistributedDoorAI.DistributedDoorAI(
                            self.air, block, interiorZone, 1)
                        door.generateWithRequired(exteriorZone)
                        self.exteriorDoors.append(door)
                        self.interiors.append(interior)
                    elif buildingType == 'hq':
                        interior = DistributedToonHQInteriorAI.DistributedToonHQInteriorAI(
                            self.air, block, exteriorZone)
                        interior.generateWithRequired(interiorZone)
                        door0 = DistributedDoorAI.DistributedDoorAI(
                            self.air, block, interiorZone, 3)
                        door0.generateWithRequired(exteriorZone)
                        door1 = DistributedDoorAI.DistributedDoorAI(
                            self.air, block, interiorZone, 3, 1)
                        door1.generateWithRequired(exteriorZone)
                        self.exteriorDoors.append(door0)
                        self.exteriorDoors.append(door1)
                        self.interiors.append(interior)
                    elif buildingType == 'clotheshop':
                        interior = DistributedTailorInteriorAI.DistributedTailorInteriorAI(
                            self.air, block, exteriorZone)
                        interior.generateWithRequired(interiorZone)
                        door = DistributedDoorAI.DistributedDoorAI(
                            self.air, block, interiorZone, 1)
                        door.generateWithRequired(exteriorZone)
                        self.exteriorDoors.append(door)
                        self.interiors.append(interior)
                    elif buildingType == 'gagshop':
                        interior = DistributedGagShopInteriorAI.DistributedGagShopInteriorAI(
                            self.air, block, exteriorZone)
                        interior.generateWithRequired(interiorZone)
                        door = DistributedDoorAI.DistributedDoorAI(
                            self.air, block, interiorZone, 4)
                        door.generateWithRequired(exteriorZone)
                        self.exteriorDoors.append(door)
                        self.interiors.append(interior)
                else:
                    if not buildingType in ["animbldg", "hq"]:
                        building = DistributedBuildingAI.DistributedBuildingAI(
                            self.air, block, exteriorZone, zoneId, self.hood)
                        building.generateWithRequired(exteriorZone)
                        building.setState('toon')
                        self.buildings[zoneId].append(building)
            if not isSZ:
                self.buildingPlanners[zoneId] = BuildingSuitPlannerAI(
                    zoneId, CIGlobals.BranchZone2StreetName[zoneId], self)

        del self.dnaFiles