Exemplo n.º 1
0
        public static void GenerateLaserFence(ZoneProperties[,] zoneMap, ref OG_OutpostData outpostData)
        {
            if (OG_Util.IsModActive("MiningCo. LaserFence") == false)
            {
                Log.Warning("MiningCo. OutpostGenerator: MiningCo. LaserFence mod is not active. Cannot generate laser fences.");
                return;
            }

            int horizontalZonesNumber = 0;
            int verticalZonesNumber = 0;

            if (outpostData.size == OG_OutpostSize.SmallOutpost)
            {
                horizontalZonesNumber = OG_SmallOutpost.horizontalZonesNumber;
                verticalZonesNumber = OG_SmallOutpost.verticalZonesNumber;

                GenerateLaseFenceForSmallOutpost(zoneMap, horizontalZonesNumber, verticalZonesNumber, ref outpostData);
            }
            else
            {
                horizontalZonesNumber = OG_BigOutpost.horizontalZonesNumber;
                verticalZonesNumber = OG_BigOutpost.verticalZonesNumber;
                GenerateLaseFenceForBigOutpost(zoneMap, horizontalZonesNumber, verticalZonesNumber, ref outpostData);
            }
        }
Exemplo n.º 2
0
 public static bool GetRandomFreeCardinalZoneAdjacentTo(int zoneAbs, int zoneOrd, out Rot4 cardinal, ZoneProperties[,] zoneMap, int horizontalZonesNumber, int verticalZonesNumber)
 {
     // Get the free zones.
     List<Rot4> cardinalList = new List<Rot4>();
     for (int cardinalAsInt = 0; cardinalAsInt < 4; cardinalAsInt++)
     {
         int testedZoneAbs = 0;
         int testedZoneOrd = 0;
         Rot4 testedCardinal = new Rot4(cardinalAsInt);
         Zone.GetAdjacentZone(zoneAbs, zoneOrd, testedCardinal, out testedZoneAbs, out testedZoneOrd);
         if (ZoneIsInArea(testedZoneAbs, testedZoneOrd, horizontalZonesNumber, verticalZonesNumber))
         {
             if (zoneMap[testedZoneOrd, testedZoneAbs].zoneType == ZoneType.NotYetGenerated)
             {
                 cardinalList.Add(testedCardinal);
             }
         }
     }
     if (cardinalList.Count == 0)
     {
         cardinal = Rot4.North;
         return false;
     }
     else
     {
         cardinal = cardinalList.RandomElement<Rot4>();
         return true;
     }
 }
Exemplo n.º 3
0
        static void GenerateOutpostLayoutMainRoom()
        {
            ZoneType mainRoomType     = OG_Common.GetRandomZoneTypeBigRoom(outpostData);
            Rot4     mainRoomRotation = Rot4.Random;

            zoneMap[mainRoomZoneOrd, mainRoomZoneAbs] = new ZoneProperties(mainRoomType, mainRoomRotation, Rot4.North);
        }
        private static bool GetBattleZoneAbsAndOrd(ZoneProperties[,] zoneMap, int horizontalZonesNumber, int verticalZonesNumber, out int battleZoneAbs, out int battleZoneOrd)
        {
            battleZoneAbs = 0;
            battleZoneOrd = 0;

            // Look for an entranched zone.
            for (int zoneAbs = 0; zoneAbs < horizontalZonesNumber; zoneAbs++)
            {
                for (int zoneOrd = 0; zoneOrd < verticalZonesNumber; zoneOrd++)
                {
                    if ((zoneMap[zoneOrd, zoneAbs].zoneType == ZoneType.SecondaryEntrance)
                        || (zoneMap[zoneOrd, zoneAbs].zoneType == ZoneType.MainEntrance))
                    {
                        battleZoneAbs = zoneAbs;
                        battleZoneOrd = zoneOrd;
                        return true;
                    }
                }
            }
            // Else, look for an empty zone.
            for (int zoneAbs = 0; zoneAbs < horizontalZonesNumber; zoneAbs++)
            {
                for (int zoneOrd = 0; zoneOrd < verticalZonesNumber; zoneOrd++)
                {
                    if ((zoneMap[zoneOrd, zoneAbs].zoneType == ZoneType.NotYetGenerated)
                        || (zoneMap[zoneOrd, zoneAbs].zoneType == ZoneType.Empty))
                    {
                        battleZoneAbs = zoneAbs;
                        battleZoneOrd = zoneOrd;
                        return true;
                    }
                }
            }
            return false;
        }
Exemplo n.º 5
0
        static void GenerateOutpostLayoutPowerSupply()
        {
            Rot4 batteryRoomCardinal;
            bool freeZoneIsFound = Zone.GetRandomFreeCardinalZoneAdjacentTo(mainRoomZoneAbs, mainRoomZoneOrd, out batteryRoomCardinal, zoneMap, horizontalZonesNumber, verticalZonesNumber);

            if (freeZoneIsFound == false)
            {
                Log.Warning("MiningCo. OutpostGenerator: failed to find a free zone for the battery room.");
                return;
            }
            int batteryRoomZoneAbs = 0;
            int batteryRoomZoneOrd = 0;

            Zone.GetAdjacentZone(mainRoomZoneAbs, mainRoomZoneOrd, batteryRoomCardinal, out batteryRoomZoneAbs, out batteryRoomZoneOrd);

            float solarPanelZoneSideSelector = Rand.Value;
            Rot4  relativeRotation           = Rot4.North;
            Rot4  absoluteRotation           = Rot4.North;

            if (solarPanelZoneSideSelector < 0.5f)
            {
                // Solar zone is "on the west" of battery room.
                relativeRotation = Rot4.West;
                absoluteRotation = new Rot4((batteryRoomCardinal.AsInt + relativeRotation.AsInt) % 4);
            }
            else
            {
                // Solar zone is "on the east" of battery room.
                relativeRotation = Rot4.East;
                absoluteRotation = new Rot4((batteryRoomCardinal.AsInt + relativeRotation.AsInt) % 4);
            }
            int solarPanelZoneAbs = 0;
            int solarPanelZoneOrd = 0;

            Zone.GetAdjacentZone(batteryRoomZoneAbs, batteryRoomZoneOrd, absoluteRotation, out solarPanelZoneAbs, out solarPanelZoneOrd);
            if ((Zone.ZoneIsInArea(solarPanelZoneAbs, solarPanelZoneOrd, horizontalZonesNumber, verticalZonesNumber) == false) ||
                (zoneMap[solarPanelZoneOrd, solarPanelZoneAbs].zoneType != ZoneType.NotYetGenerated))
            {
                // Get the opposite side.
                relativeRotation = new Rot4((relativeRotation.AsInt + 2) % 4);
                absoluteRotation = new Rot4((absoluteRotation.AsInt + 2) % 4);
                Zone.GetAdjacentZone(batteryRoomZoneAbs, batteryRoomZoneOrd, absoluteRotation, out solarPanelZoneAbs, out solarPanelZoneOrd);
                if ((Zone.ZoneIsInArea(solarPanelZoneAbs, solarPanelZoneOrd, horizontalZonesNumber, verticalZonesNumber) == false) ||
                    (zoneMap[solarPanelZoneOrd, solarPanelZoneAbs].zoneType != ZoneType.NotYetGenerated))
                {
                    Log.Warning("MiningCo. OutpostGenerator: failed to find a free zone for the solar panels.");
                    return;
                }
            }
            zoneMap[batteryRoomZoneOrd, batteryRoomZoneAbs] = new ZoneProperties(ZoneType.SmallRoomBatteryRoom, batteryRoomCardinal, relativeRotation);
            relativeRotation.Rotate(RotationDirection.Clockwise); // Rotate 2 times to get the opposite direction.
            relativeRotation.Rotate(RotationDirection.Clockwise);
            zoneMap[solarPanelZoneOrd, solarPanelZoneAbs] = new ZoneProperties(ZoneType.SolarPanelZone, batteryRoomCardinal, relativeRotation);
        }
Exemplo n.º 6
0
        static void GenerateOutpostLayoutCommandRoom()
        {
            Rot4 commandRoomCardinal;
            bool freeZoneIsFound = Zone.GetRandomFreeCardinalZoneAdjacentTo(mainRoomZoneAbs, mainRoomZoneOrd, out commandRoomCardinal, zoneMap, horizontalZonesNumber, verticalZonesNumber);

            if (freeZoneIsFound == false)
            {
                Log.Warning("MiningCo. OutpostGenerator: failed to find a free zone for the command room.");
                return;
            }
            int commandRoomZoneAbs = 0;
            int commandRoomZoneOrd = 0;

            Zone.GetAdjacentZone(mainRoomZoneAbs, mainRoomZoneOrd, commandRoomCardinal, out commandRoomZoneAbs, out commandRoomZoneOrd);

            float dropZoneSideSelector = Rand.Value;
            Rot4  relativeRotation     = Rot4.North;
            Rot4  absoluteRotation     = Rot4.North;

            if (dropZoneSideSelector < 0.5f)
            {
                // Drop zone is "on the west" of command room.
                relativeRotation = Rot4.West;
                absoluteRotation = new Rot4((commandRoomCardinal.AsInt + relativeRotation.AsInt) % 4);
            }
            else
            {
                // Drop zone is "on the east" of command room.
                relativeRotation = Rot4.East;
                absoluteRotation = new Rot4((commandRoomCardinal.AsInt + relativeRotation.AsInt) % 4);
            }
            int dropZoneAbs = 0;
            int dropZoneOrd = 0;

            Zone.GetAdjacentZone(commandRoomZoneAbs, commandRoomZoneOrd, absoluteRotation, out dropZoneAbs, out dropZoneOrd);
            if ((Zone.ZoneIsInArea(dropZoneAbs, dropZoneOrd, horizontalZonesNumber, verticalZonesNumber) == false) ||
                (zoneMap[dropZoneOrd, dropZoneAbs].zoneType != ZoneType.NotYetGenerated))
            {
                // Get the opposite side.
                relativeRotation = new Rot4((relativeRotation.AsInt + 2) % 4);
                absoluteRotation = new Rot4((absoluteRotation.AsInt + 2) % 4);
                Zone.GetAdjacentZone(commandRoomZoneAbs, commandRoomZoneOrd, absoluteRotation, out dropZoneAbs, out dropZoneOrd);
                if ((Zone.ZoneIsInArea(dropZoneAbs, dropZoneOrd, horizontalZonesNumber, verticalZonesNumber) == false) ||
                    (zoneMap[dropZoneOrd, dropZoneAbs].zoneType != ZoneType.NotYetGenerated))
                {
                    Log.Warning("MiningCo. OutpostGenerator: failed to find a free zone for the drop zone.");
                    return;
                }
            }
            zoneMap[commandRoomZoneOrd, commandRoomZoneAbs] = new ZoneProperties(ZoneType.SmallRoomCommandRoom, commandRoomCardinal, relativeRotation);
            relativeRotation.Rotate(RotationDirection.Clockwise); // Rotate 2 times to get the opposite direction.
            relativeRotation.Rotate(RotationDirection.Clockwise);
            zoneMap[dropZoneOrd, dropZoneAbs] = new ZoneProperties(ZoneType.DropZone, commandRoomCardinal, relativeRotation);
        }
Exemplo n.º 7
0
 static void GenerateOutpostLayoutSecondaryRooms()
 {
     for (int rotationAsInt = 0; rotationAsInt < 4; rotationAsInt++)
     {
         int  zoneAbs  = 0;
         int  zoneOrd  = 0;
         Rot4 rotation = new Rot4(rotationAsInt);
         Zone.GetAdjacentZone(mainRoomZoneAbs, mainRoomZoneOrd, rotation, out zoneAbs, out zoneOrd);
         if (zoneMap[zoneOrd, zoneAbs].zoneType == ZoneType.NotYetGenerated)
         {
             ZoneType secondaryRoomType = OG_Common.GetRandomZoneTypeSmallRoom(outpostData);
             zoneMap[zoneOrd, zoneAbs] = new ZoneProperties(secondaryRoomType, rotation, Rot4.North);
         }
     }
 }
        public static void GenerateWarfieldEffects(ZoneProperties[,] zoneMap, int horizontalZonesNumber, int verticalZonesNumber, OG_OutpostData outpostData)
        {
            bool battleZoneIsFound = false;
            int battleZoneAbs = 0;
            int battleZoneOrd = 0;

            if (outpostData.battleOccured == false)
            {
                return;
            }
            battleZoneIsFound = GetBattleZoneAbsAndOrd(zoneMap, horizontalZonesNumber, verticalZonesNumber, out battleZoneAbs, out battleZoneOrd);
            if (battleZoneIsFound == false)
            {
                Log.Warning("MiningCo. OutpostGenerator: failed to find an appropriate zone to generate warfield.");
                return;
            }

            Building_WarfieldGenerator warfieldGenerator = ThingMaker.MakeThing(ThingDef.Named("WarfieldGenerator")) as Building_WarfieldGenerator;
            warfieldGenerator.battleZoneAbs = battleZoneAbs;
            warfieldGenerator.battleZoneOrd = battleZoneOrd;
            warfieldGenerator.outpostData = outpostData;
            IntVec3 warfieldCenter = Zone.GetZoneOrigin(outpostData.areaSouthWestOrigin, battleZoneAbs, battleZoneOrd) + new IntVec3(Genstep_GenerateOutpost.zoneSideCenterOffset, 0, Genstep_GenerateOutpost.zoneSideCenterOffset);
            GenSpawn.Spawn(warfieldGenerator, warfieldCenter);
        }
Exemplo n.º 9
0
 private static void GenerateLaseFenceForBigOutpost(ZoneProperties[,] zoneMap, int horizontalZonesNumber, int verticalZonesNumber, ref OG_OutpostData outpostData)
 {
     for (int zoneOrd = 0; zoneOrd < verticalZonesNumber; zoneOrd++)
     {
         for (int zoneAbs = 0; zoneAbs < horizontalZonesNumber; zoneAbs++)
         {
             ZoneProperties zone = zoneMap[zoneOrd, zoneAbs];
             IntVec3 zoneOrigin = Zone.GetZoneOrigin(outpostData.areaSouthWestOrigin, zoneAbs, zoneOrd);
             IntVec3 zoneRotatedOrigin = Zone.GetZoneRotatedOrigin(outpostData.areaSouthWestOrigin, zoneAbs, zoneOrd, zone.rotation);
             if (zone.zoneType == ZoneType.MainEntrance)
             {
                 SpawnLaserFenceTwoPylons(zoneRotatedOrigin + new IntVec3(0, 0, 5).RotatedBy(zone.rotation), new Rot4(Rot4.North.AsInt + zone.rotation.AsInt), 4, ref outpostData);
                 SpawnLaserFenceTwoPylons(zoneRotatedOrigin + new IntVec3(10, 0, 5).RotatedBy(zone.rotation), new Rot4(Rot4.North.AsInt + zone.rotation.AsInt), 4, ref outpostData);
             }
             else if (zone.zoneType == ZoneType.SecondaryEntrance)
             {
                 SpawnLaserFenceThreePylons(zoneRotatedOrigin, new Rot4(Rot4.North.AsInt + zone.rotation.AsInt), 4, ref outpostData);
                 SpawnLaserFenceThreePylons(zoneRotatedOrigin + new IntVec3(10, 0, 0).RotatedBy(zone.rotation), new Rot4(Rot4.North.AsInt + zone.rotation.AsInt), 4, ref outpostData);
                 OG_Common.SpawnFireproofPowerConduitAt(zoneRotatedOrigin + new IntVec3(0, 0, -1).RotatedBy(zone.rotation), ref outpostData);
                 OG_Common.SpawnFireproofPowerConduitAt(zoneRotatedOrigin + new IntVec3(10, 0, -1).RotatedBy(zone.rotation), ref outpostData);
             }
             else
             {
                 if (zoneOrd == 0)
                 {
                     if (Zone.IsZoneMediumRoom(zone.zoneType))
                     {
                         SpawnLaserFenceTwoPylons(zoneOrigin, Rot4.East, 2, ref outpostData);
                         SpawnLaserFenceTwoPylons(zoneOrigin + new IntVec3(10, 0, 0), Rot4.West, 2, ref outpostData);
                     }
                     else
                     {
                         SpawnLaserFenceThreePylons(zoneOrigin, Rot4.East, 4, ref outpostData);
                     }
                 }
                 if (zoneOrd == verticalZonesNumber - 1)
                 {
                     if (Zone.IsZoneMediumRoom(zone.zoneType))
                     {
                         SpawnLaserFenceTwoPylons(zoneOrigin + new IntVec3(0, 0, 10), Rot4.East, 2, ref outpostData);
                         SpawnLaserFenceTwoPylons(zoneOrigin + new IntVec3(10, 0, 10), Rot4.West, 2, ref outpostData);
                     }
                     else
                     {
                         SpawnLaserFenceThreePylons(zoneOrigin + new IntVec3(0, 0, 10), Rot4.East, 4, ref outpostData);
                     }
                 }
                 if (zoneAbs == 0)
                 {
                     if (Zone.IsZoneMediumRoom(zone.zoneType))
                     {
                         SpawnLaserFenceTwoPylons(zoneOrigin, Rot4.North, 2, ref outpostData);
                         SpawnLaserFenceTwoPylons(zoneOrigin + new IntVec3(0, 0, 10), Rot4.South, 2, ref outpostData);
                     }
                     else
                     {
                         SpawnLaserFenceThreePylons(zoneOrigin, Rot4.North, 4, ref outpostData);
                     }
                 }
                 if (zoneAbs == horizontalZonesNumber - 1)
                 {
                     if (Zone.IsZoneMediumRoom(zone.zoneType))
                     {
                         SpawnLaserFenceTwoPylons(zoneOrigin + new IntVec3(10, 0, 0), Rot4.North, 2, ref outpostData);
                         SpawnLaserFenceTwoPylons(zoneOrigin + new IntVec3(10, 0, 10), Rot4.South, 2, ref outpostData);
                     }
                     else
                     {
                         SpawnLaserFenceThreePylons(zoneOrigin + new IntVec3(10, 0, 0), Rot4.North, 4, ref outpostData);
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 10
0
        static void GenerateOutpostLayoutPowerSupply()
        {
            Rot4 batteryRoomCardinal;
            bool freeZoneIsFound = Zone.GetRandomFreeCardinalZoneAdjacentTo(mainRoomZoneAbs, mainRoomZoneOrd, out batteryRoomCardinal, zoneMap, horizontalZonesNumber, verticalZonesNumber);
            if (freeZoneIsFound == false)
            {
                Log.Warning("MiningCo. OutpostGenerator: failed to find a free zone for the battery room.");
                return;
            }
            int batteryRoomZoneAbs = 0;
            int batteryRoomZoneOrd = 0;
            Zone.GetAdjacentZone(mainRoomZoneAbs, mainRoomZoneOrd, batteryRoomCardinal, out batteryRoomZoneAbs, out batteryRoomZoneOrd);

            float solarPanelZoneSideSelector = Rand.Value;
            Rot4 relativeRotation = Rot4.North;
            Rot4 absoluteRotation = Rot4.North;
            if (solarPanelZoneSideSelector < 0.5f)
            {
                // Solar zone is "on the west" of battery room.
                relativeRotation = Rot4.West;
                absoluteRotation = new Rot4((batteryRoomCardinal.AsInt + relativeRotation.AsInt) % 4);
            }
            else
            {
                // Solar zone is "on the east" of battery room.
                relativeRotation = Rot4.East;
                absoluteRotation = new Rot4((batteryRoomCardinal.AsInt + relativeRotation.AsInt) % 4);
            }
            int solarPanelZoneAbs = 0;
            int solarPanelZoneOrd = 0;
            Zone.GetAdjacentZone(batteryRoomZoneAbs, batteryRoomZoneOrd, absoluteRotation, out solarPanelZoneAbs, out solarPanelZoneOrd);
            if ((Zone.ZoneIsInArea(solarPanelZoneAbs, solarPanelZoneOrd, horizontalZonesNumber, verticalZonesNumber) == false)
                || (zoneMap[solarPanelZoneOrd, solarPanelZoneAbs].zoneType != ZoneType.NotYetGenerated))
            {
                // Get the opposite side.
                relativeRotation = new Rot4((relativeRotation.AsInt + 2) % 4);
                absoluteRotation = new Rot4((absoluteRotation.AsInt + 2) % 4);
                Zone.GetAdjacentZone(batteryRoomZoneAbs, batteryRoomZoneOrd, absoluteRotation, out solarPanelZoneAbs, out solarPanelZoneOrd);
                if ((Zone.ZoneIsInArea(solarPanelZoneAbs, solarPanelZoneOrd, horizontalZonesNumber, verticalZonesNumber) == false)
                    || (zoneMap[solarPanelZoneOrd, solarPanelZoneAbs].zoneType != ZoneType.NotYetGenerated))
                {
                    Log.Warning("MiningCo. OutpostGenerator: failed to find a free zone for the solar panels.");
                    return;
                }
            }
            zoneMap[batteryRoomZoneOrd, batteryRoomZoneAbs] = new ZoneProperties(ZoneType.SmallRoomBatteryRoom, batteryRoomCardinal, relativeRotation);
            relativeRotation.Rotate(RotationDirection.Clockwise); // Rotate 2 times to get the opposite direction.
            relativeRotation.Rotate(RotationDirection.Clockwise);
            zoneMap[solarPanelZoneOrd, solarPanelZoneAbs] = new ZoneProperties(ZoneType.SolarPanelZone, batteryRoomCardinal, relativeRotation);
        }
Exemplo n.º 11
0
        static void GenerateOutpostLayoutCommandRoom()
        {
            Rot4 commandRoomCardinal;
            bool freeZoneIsFound = Zone.GetRandomFreeCardinalZoneAdjacentTo(mainRoomZoneAbs, mainRoomZoneOrd, out commandRoomCardinal, zoneMap, horizontalZonesNumber, verticalZonesNumber);
            if (freeZoneIsFound == false)
            {
                Log.Warning("MiningCo. OutpostGenerator: failed to find a free zone for the command room.");
                return;
            }
            int commandRoomZoneAbs = 0;
            int commandRoomZoneOrd = 0;
            Zone.GetAdjacentZone(mainRoomZoneAbs, mainRoomZoneOrd, commandRoomCardinal, out commandRoomZoneAbs, out commandRoomZoneOrd);

            float dropZoneSideSelector = Rand.Value;
            Rot4 relativeRotation = Rot4.North;
            Rot4 absoluteRotation = Rot4.North;
            if (dropZoneSideSelector < 0.5f)
            {
                // Drop zone is "on the west" of command room.
                relativeRotation = Rot4.West;
                absoluteRotation = new Rot4((commandRoomCardinal.AsInt + relativeRotation.AsInt) % 4);
            }
            else
            {
                // Drop zone is "on the east" of command room.
                relativeRotation = Rot4.East;
                absoluteRotation = new Rot4((commandRoomCardinal.AsInt + relativeRotation.AsInt) % 4);
            }
            int dropZoneAbs = 0;
            int dropZoneOrd = 0;
            Zone.GetAdjacentZone(commandRoomZoneAbs, commandRoomZoneOrd, absoluteRotation, out dropZoneAbs, out dropZoneOrd);
            if ((Zone.ZoneIsInArea(dropZoneAbs, dropZoneOrd, horizontalZonesNumber, verticalZonesNumber) == false)
                || (zoneMap[dropZoneOrd, dropZoneAbs].zoneType != ZoneType.NotYetGenerated))
            {
                // Get the opposite side.
                relativeRotation = new Rot4((relativeRotation.AsInt + 2) % 4);
                absoluteRotation = new Rot4((absoluteRotation.AsInt + 2) % 4);
                Zone.GetAdjacentZone(commandRoomZoneAbs, commandRoomZoneOrd, absoluteRotation, out dropZoneAbs, out dropZoneOrd);
                if ((Zone.ZoneIsInArea(dropZoneAbs, dropZoneOrd, horizontalZonesNumber, verticalZonesNumber) == false)
                    || (zoneMap[dropZoneOrd, dropZoneAbs].zoneType != ZoneType.NotYetGenerated))
                {
                    Log.Warning("MiningCo. OutpostGenerator: failed to find a free zone for the drop zone.");
                    return;
                }
            }
            zoneMap[commandRoomZoneOrd, commandRoomZoneAbs] = new ZoneProperties(ZoneType.SmallRoomCommandRoom, commandRoomCardinal, relativeRotation);
            relativeRotation.Rotate(RotationDirection.Clockwise); // Rotate 2 times to get the opposite direction.
            relativeRotation.Rotate(RotationDirection.Clockwise);
            zoneMap[dropZoneOrd, dropZoneAbs] = new ZoneProperties(ZoneType.DropZone, commandRoomCardinal, relativeRotation);
        }
Exemplo n.º 12
0
        public static void GenerateOutpost(OG_OutpostData outpostDataParameter)
        {
            outpostData = outpostDataParameter;
            outpostData.triggerIntrusion = null;
            outpostData.outpostThingList = new List <Thing>();

            // Reset zoneMap.
            for (int zoneOrd = 0; zoneOrd < verticalZonesNumber; zoneOrd++)
            {
                for (int zoneAbs = 0; zoneAbs < horizontalZonesNumber; zoneAbs++)
                {
                    zoneMap[zoneOrd, zoneAbs] = new ZoneProperties(ZoneType.NotYetGenerated, Rot4.North, Rot4.North);
                }
            }
            // Clear the whole area and remove any roof.
            CellRect rect = new CellRect(outpostData.areaSouthWestOrigin.x - 1, outpostData.areaSouthWestOrigin.z - 1, areaSideLength + 2, areaSideLength + 2);

            foreach (IntVec3 cell in rect.Cells)
            {
                Find.RoofGrid.SetRoof(cell, null);
                List <Thing> thingList = cell.GetThingList();
                for (int j = thingList.Count - 1; j >= 0; j--)
                {
                    Thing thing = thingList[j];
                    if (thing.def.destroyable)
                    {
                        thing.Destroy(DestroyMode.Vanish);
                    }
                }
            }
            // Create the intrusion trigger.
            outpostData.triggerIntrusion = (TriggerIntrusion)ThingMaker.MakeThing(ThingDef.Named("TriggerIntrusion"));
            GenSpawn.Spawn(outpostData.triggerIntrusion, rect.CenterCell);

            GenerateOutpostLayout();

            // TODO: debug. Display the generated layout.

            /*for (int zoneOrd = 0; zoneOrd < verticalZonesNumber; zoneOrd++)
             * {
             *  for (int zoneAbs = 0; zoneAbs < horizontalZonesNumber; zoneAbs++)
             *  {
             *      ZoneProperties zone = zoneMap[zoneOrd, zoneAbs];
             *      Log.Message("Layout: zoneMap[" + zoneOrd + "," + zoneAbs + "] => " + zone.zoneType.ToString() + "," + zone.rotation.ToString() + "," + zone.linkedZoneRelativeRotation.ToString());
             *  }
             * }*/
            GenerateOutpostZones(outpostData.areaSouthWestOrigin);

            IntVec3 mainRoomZoneOrigin = Zone.GetZoneOrigin(outpostData.areaSouthWestOrigin, mainRoomZoneAbs, mainRoomZoneOrd);

            OG_Common.GenerateSas(mainRoomZoneOrigin + new IntVec3(5, 0, 10), Rot4.North, 3, smallRoomWallOffset * 2, ref outpostData);
            OG_Common.GenerateSas(mainRoomZoneOrigin + new IntVec3(10, 0, 5), Rot4.East, 3, smallRoomWallOffset * 2, ref outpostData);
            OG_Common.GenerateSas(mainRoomZoneOrigin + new IntVec3(5, 0, 0), Rot4.South, 3, smallRoomWallOffset * 2, ref outpostData);
            OG_Common.GenerateSas(mainRoomZoneOrigin + new IntVec3(0, 0, 5), Rot4.West, 3, smallRoomWallOffset * 2, ref outpostData);

            // Generate laser fences.
            OG_LaserFence.GenerateLaserFence(zoneMap, ref outpostData);
            // Generate battle remains.
            OG_WarfieldEffects.GenerateWarfieldEffects(zoneMap, horizontalZonesNumber, verticalZonesNumber, outpostData);
            // Damage outpost to reflect its history.
            OG_RuinEffects.GenerateRuinEffects(ref outpostData);
            // Don't generate permanent inhabitants for small outposts. Those are just used as a shack by exploration teams.

            // Initialize command console data.
            outpostData.outpostThingList    = OG_Util.RefreshThingList(outpostData.outpostThingList);
            commandConsole.outpostThingList = outpostData.outpostThingList.ListFullCopy <Thing>();
            commandConsole.dropZoneCenter   = outpostData.dropZoneCenter;
            // Initialize intrusion trigger data.
            outpostData.triggerIntrusion.commandConsole = commandConsole;

            SendWelcomeLetter(outpostData);
        }
Exemplo n.º 13
0
        // ######## Zone generation functions ######## //

        static void GenerateOutpostZones(IntVec3 areaSouthWestOrigin)
        {
            for (int zoneOrd = 0; zoneOrd < verticalZonesNumber; zoneOrd++)
            {
                for (int zoneAbs = 0; zoneAbs < horizontalZonesNumber; zoneAbs++)
                {
                    ZoneProperties zone = zoneMap[zoneOrd, zoneAbs];
                    switch (zone.zoneType)
                    {
                    // Standard big rooms.
                    case ZoneType.BigRoomLivingRoom:
                        OG_ZoneBigRoom.GenerateBigRoomLivingRoom(areaSouthWestOrigin, zoneAbs, zoneOrd, zone.rotation, ref outpostData);
                        break;

                    case ZoneType.BigRoomWarehouse:
                        OG_ZoneBigRoom.GenerateBigRoomWarehouse(areaSouthWestOrigin, zoneAbs, zoneOrd, zone.rotation, ref outpostData);
                        break;

                    case ZoneType.BigRoomPrison:
                        OG_ZoneBigRoom.GenerateBigRoomPrison(areaSouthWestOrigin, zoneAbs, zoneOrd, zone.rotation, ref outpostData);
                        break;

                    // Standard small rooms.
                    case ZoneType.SmallRoomBarracks:
                        OG_ZoneSmallRoom.GenerateSmallRoomBarracks(areaSouthWestOrigin, zoneAbs, zoneOrd, zone.rotation, ref outpostData);
                        break;

                    case ZoneType.SmallRoomMedibay:
                        OG_ZoneSmallRoom.GenerateSmallRoomMedibay(areaSouthWestOrigin, zoneAbs, zoneOrd, zone.rotation, ref outpostData);
                        break;

                    case ZoneType.SmallRoomWeaponRoom:
                        OG_ZoneSmallRoom.GenerateSmallRoomWeaponRoom(areaSouthWestOrigin, zoneAbs, zoneOrd, zone.rotation, ref outpostData);
                        break;

                    // Special small rooms.
                    case ZoneType.SmallRoomBatteryRoom:
                        OG_ZoneSmallRoomSpecial.GenerateBatteryRoomZone(areaSouthWestOrigin, zoneAbs, zoneOrd, zone.rotation, zone.linkedZoneRelativeRotation, ref outpostData);
                        break;

                    case ZoneType.SmallRoomCommandRoom:
                        commandConsole = OG_ZoneSmallRoomSpecial.GenerateCommandRoomZone(areaSouthWestOrigin, zoneAbs, zoneOrd, zone.rotation, zone.linkedZoneRelativeRotation, ref outpostData);
                        break;

                    // Special zones.
                    case ZoneType.SolarPanelZone:
                        OG_ZoneSpecial.GenerateSolarPanelZone(areaSouthWestOrigin, zoneAbs, zoneOrd, ref outpostData);
                        break;

                    case ZoneType.DropZone:
                        OG_ZoneSpecial.GenerateDropZone(areaSouthWestOrigin, zoneAbs, zoneOrd, ref outpostData);
                        break;

                    // Other zones.
                    case ZoneType.Empty:
                        // Nothing to do;
                        break;

                    case ZoneType.SecondaryEntrance:
                        OG_ZoneOther.GenerateSecondaryEntranceZone(areaSouthWestOrigin, zoneAbs, zoneOrd, zone.rotation, ref outpostData);
                        break;
                    }
                }
            }
        }
Exemplo n.º 14
0
 static void GenerateOutpostLayoutMainRoom()
 {
     ZoneType mainRoomType = OG_Common.GetRandomZoneTypeBigRoom(outpostData);
     Rot4 mainRoomRotation = Rot4.Random;
     zoneMap[mainRoomZoneOrd, mainRoomZoneAbs] = new ZoneProperties(mainRoomType, mainRoomRotation, Rot4.North);
 }
Exemplo n.º 15
0
 static void GenerateOutpostLayoutSecondaryRooms()
 {
     for (int rotationAsInt = 0; rotationAsInt < 4; rotationAsInt++)
     {
         int zoneAbs = 0;
         int zoneOrd = 0;
         Rot4 rotation = new Rot4(rotationAsInt);
         Zone.GetAdjacentZone(mainRoomZoneAbs, mainRoomZoneOrd, rotation, out zoneAbs, out zoneOrd);
         if (zoneMap[zoneOrd, zoneAbs].zoneType == ZoneType.NotYetGenerated)
         {
             ZoneType secondaryRoomType = OG_Common.GetRandomZoneTypeSmallRoom(outpostData);
             zoneMap[zoneOrd, zoneAbs] = new ZoneProperties(secondaryRoomType, rotation, Rot4.North);
         }
     }
 }
Exemplo n.º 16
0
        public static void GenerateOutpost(OG_OutpostData outpostDataParameter)
        {
            outpostData = outpostDataParameter;
            outpostData.triggerIntrusion = null;
            outpostData.outpostThingList = new List<Thing>();

            // Reset zoneMap.
            for (int zoneOrd = 0; zoneOrd < verticalZonesNumber; zoneOrd++)
            {
                for (int zoneAbs = 0; zoneAbs < horizontalZonesNumber; zoneAbs++)
                {
                    zoneMap[zoneOrd, zoneAbs] = new ZoneProperties(ZoneType.NotYetGenerated, Rot4.North, Rot4.North);
                }
            }
            // Clear the whole area and remove any roof.
            CellRect rect = new CellRect(outpostData.areaSouthWestOrigin.x - 1, outpostData.areaSouthWestOrigin.z - 1, areaSideLength + 2, areaSideLength + 2);
            foreach (IntVec3 cell in rect.Cells)
            {
                Find.RoofGrid.SetRoof(cell, null);
                List<Thing> thingList = cell.GetThingList();
                for (int j = thingList.Count - 1; j >= 0; j--)
                {
                    Thing thing = thingList[j];
                    if (thing.def.destroyable)
                    {
                        thing.Destroy(DestroyMode.Vanish);
                    }
                }
            }
            // Create the intrusion trigger.
            outpostData.triggerIntrusion = (TriggerIntrusion)ThingMaker.MakeThing(ThingDef.Named("TriggerIntrusion"));
            GenSpawn.Spawn(outpostData.triggerIntrusion, rect.CenterCell);

            GenerateOutpostLayout();
            
            // TODO: debug. Display the generated layout.
            /*for (int zoneOrd = 0; zoneOrd < verticalZonesNumber; zoneOrd++)
            {
                for (int zoneAbs = 0; zoneAbs < horizontalZonesNumber; zoneAbs++)
                {
                    ZoneProperties zone = zoneMap[zoneOrd, zoneAbs];
                    Log.Message("Layout: zoneMap[" + zoneOrd + "," + zoneAbs + "] => " + zone.zoneType.ToString() + "," + zone.rotation.ToString() + "," + zone.linkedZoneRelativeRotation.ToString());
                }
            }*/
            GenerateOutpostZones(outpostData.areaSouthWestOrigin);
            
            IntVec3 mainRoomZoneOrigin = Zone.GetZoneOrigin(outpostData.areaSouthWestOrigin, mainRoomZoneAbs, mainRoomZoneOrd);
            OG_Common.GenerateSas(mainRoomZoneOrigin + new IntVec3(5, 0, 10), Rot4.North, 3, smallRoomWallOffset * 2, ref outpostData);
            OG_Common.GenerateSas(mainRoomZoneOrigin + new IntVec3(10, 0, 5), Rot4.East, 3, smallRoomWallOffset * 2, ref outpostData);
            OG_Common.GenerateSas(mainRoomZoneOrigin + new IntVec3(5, 0, 0), Rot4.South, 3, smallRoomWallOffset * 2, ref outpostData);
            OG_Common.GenerateSas(mainRoomZoneOrigin + new IntVec3(0, 0, 5), Rot4.West, 3, smallRoomWallOffset * 2, ref outpostData);
            
            // Generate laser fences.
            OG_LaserFence.GenerateLaserFence(zoneMap, ref outpostData);
            // Generate battle remains.
            OG_WarfieldEffects.GenerateWarfieldEffects(zoneMap, horizontalZonesNumber, verticalZonesNumber, outpostData);
            // Damage outpost to reflect its history.
            OG_RuinEffects.GenerateRuinEffects(ref outpostData);
            // Don't generate permanent inhabitants for small outposts. Those are just used as a shack by exploration teams.

            // Initialize command console data.
            outpostData.outpostThingList = OG_Util.RefreshThingList(outpostData.outpostThingList);
            commandConsole.outpostThingList = outpostData.outpostThingList.ListFullCopy<Thing>();
            commandConsole.dropZoneCenter = outpostData.dropZoneCenter;
            // Initialize intrusion trigger data.
            outpostData.triggerIntrusion.commandConsole = commandConsole;

            SendWelcomeLetter(outpostData);
        }
Exemplo n.º 17
0
        private static void GenerateLaseFenceForSmallOutpost(ZoneProperties[,] zoneMap, int horizontalZonesNumber, int verticalZonesNumber, ref OG_OutpostData outpostData)
        {
            for (int zoneOrd = 0; zoneOrd < verticalZonesNumber; zoneOrd++)
            {
                for (int zoneAbs = 0; zoneAbs < horizontalZonesNumber; zoneAbs++)
                {
                    // Standard case: only generate laser fence on border zones.
                    if ((zoneOrd == 0) || (zoneOrd == verticalZonesNumber - 1) || (zoneAbs == 0) || (zoneAbs == horizontalZonesNumber - 1))
                    {
                        ZoneProperties zone              = zoneMap[zoneOrd, zoneAbs];
                        IntVec3        zoneOrigin        = Zone.GetZoneOrigin(outpostData.areaSouthWestOrigin, zoneAbs, zoneOrd);
                        IntVec3        zoneRotatedOrigin = Zone.GetZoneRotatedOrigin(outpostData.areaSouthWestOrigin, zoneAbs, zoneOrd, zone.rotation);
                        IntVec3        laserFenceOrigin;
                        switch (zone.zoneType)
                        {
                        case ZoneType.NotYetGenerated:
                            if (zoneAbs == 0)
                            {
                                // Try to spawn laser fence along absolute east side.
                                laserFenceOrigin = zoneOrigin + new IntVec3(Genstep_GenerateOutpost.zoneSideSize, 0, 0);
                                SpawnLaserFenceWithoutEntrance(laserFenceOrigin, Rot4.West, ref outpostData);
                            }
                            else if (zoneAbs == horizontalZonesNumber - 1)
                            {
                                // Try to spawn laser fence along absolute west side.
                                laserFenceOrigin = zoneOrigin + new IntVec3(-1, 0, Genstep_GenerateOutpost.zoneSideSize - 1);
                                SpawnLaserFenceWithoutEntrance(laserFenceOrigin, Rot4.East, ref outpostData);
                            }
                            if (zoneOrd == 0)
                            {
                                // Try to spawn laser fence along absolute north side.
                                laserFenceOrigin = zoneOrigin + new IntVec3(Genstep_GenerateOutpost.zoneSideSize - 1, 0, Genstep_GenerateOutpost.zoneSideSize);
                                SpawnLaserFenceWithoutEntrance(laserFenceOrigin, Rot4.South, ref outpostData);
                            }
                            else if (zoneOrd == verticalZonesNumber - 1)
                            {
                                // Try to spawn laser fence along absolute south side.
                                laserFenceOrigin = zoneOrigin + new IntVec3(0, 0, -1);
                                SpawnLaserFenceWithoutEntrance(laserFenceOrigin, Rot4.North, ref outpostData);
                            }
                            break;

                        case ZoneType.SmallRoomBarracks:
                        case ZoneType.SmallRoomMedibay:
                        case ZoneType.SmallRoomWeaponRoom:
                        case ZoneType.SmallRoomBatteryRoom:
                            laserFenceOrigin = zoneRotatedOrigin + new IntVec3(0, 0, Genstep_GenerateOutpost.zoneSideSize - 1).RotatedBy(new Rot4(zone.rotation.AsInt));
                            SpawnLaserFenceWithEntrance(laserFenceOrigin, zone.rotation, 1, ref outpostData);
                            break;

                        case ZoneType.SmallRoomCommandRoom:
                            laserFenceOrigin = zoneRotatedOrigin + new IntVec3(0, 0, Genstep_GenerateOutpost.zoneSideSize - 1).RotatedBy(new Rot4(zone.rotation.AsInt));
                            SpawnLaserFenceWithoutEntrance(laserFenceOrigin, zone.rotation, ref outpostData);
                            // Try to spawn laser fence along linked side.
                            if (zone.linkedZoneRelativeRotation == Rot4.West)
                            {
                                laserFenceOrigin = zoneRotatedOrigin;
                            }
                            else if (zone.linkedZoneRelativeRotation == Rot4.East)
                            {
                                laserFenceOrigin = zoneRotatedOrigin + new IntVec3(Genstep_GenerateOutpost.zoneSideSize - 1, 0, Genstep_GenerateOutpost.zoneSideSize - 1).RotatedBy(new Rot4(zone.rotation.AsInt));
                            }
                            SpawnLaserFenceWithEntrance(laserFenceOrigin, new Rot4(zone.rotation.AsInt + zone.linkedZoneRelativeRotation.AsInt), 1, ref outpostData);
                            break;

                        case ZoneType.SolarPanelZone:
                            laserFenceOrigin = zoneRotatedOrigin + new IntVec3(0, 0, Genstep_GenerateOutpost.zoneSideSize - 1).RotatedBy(new Rot4(zone.rotation.AsInt));
                            SpawnLaserFenceWithoutEntrance(laserFenceOrigin, zone.rotation, ref outpostData);
                            // Try to spawn laser fence along opposite linked side.
                            laserFenceOrigin = zoneRotatedOrigin;
                            if (zone.linkedZoneRelativeRotation == Rot4.West)
                            {
                                laserFenceOrigin = zoneRotatedOrigin + new IntVec3(Genstep_GenerateOutpost.zoneSideSize - 1, 0, Genstep_GenerateOutpost.zoneSideSize - 1).RotatedBy(new Rot4(zone.rotation.AsInt));
                                SpawnLaserFenceWithoutEntrance(laserFenceOrigin, new Rot4(zone.rotation.AsInt + Rot4.East.AsInt), ref outpostData);
                            }
                            else if (zone.linkedZoneRelativeRotation == Rot4.East)
                            {
                                laserFenceOrigin = zoneRotatedOrigin;
                                SpawnLaserFenceWithoutEntrance(laserFenceOrigin, new Rot4(zone.rotation.AsInt + Rot4.West.AsInt), ref outpostData);
                            }
                            break;

                        case ZoneType.DropZone:
                            // Try to spawn laser fence along relative south side.
                            laserFenceOrigin = zoneRotatedOrigin + new IntVec3(Genstep_GenerateOutpost.zoneSideSize - 1, 0, -1).RotatedBy(new Rot4(zone.rotation.AsInt));
                            SpawnLaserFenceWithoutEntrance(laserFenceOrigin, new Rot4(zone.rotation.AsInt + Rot4.South.AsInt), ref outpostData);
                            break;

                        case ZoneType.Empty:
                            laserFenceOrigin = zoneRotatedOrigin + new IntVec3(0, 0, Genstep_GenerateOutpost.zoneSideSize - 1).RotatedBy(new Rot4(zone.rotation.AsInt));
                            SpawnLaserFenceWithEntrance(laserFenceOrigin, zone.rotation, 1, ref outpostData);
                            break;

                        case ZoneType.SecondaryEntrance:
                            laserFenceOrigin = zoneRotatedOrigin + new IntVec3(0, 0, Genstep_GenerateOutpost.zoneSideSize - 1).RotatedBy(new Rot4(zone.rotation.AsInt));
                            SpawnLaserFenceWithEntrance(laserFenceOrigin, zone.rotation, 3, ref outpostData);
                            break;
                        }
                    }
                }
            }
        }
Exemplo n.º 18
0
 private static void GenerateLaseFenceForBigOutpost(ZoneProperties[,] zoneMap, int horizontalZonesNumber, int verticalZonesNumber, ref OG_OutpostData outpostData)
 {
     for (int zoneOrd = 0; zoneOrd < verticalZonesNumber; zoneOrd++)
     {
         for (int zoneAbs = 0; zoneAbs < horizontalZonesNumber; zoneAbs++)
         {
             ZoneProperties zone              = zoneMap[zoneOrd, zoneAbs];
             IntVec3        zoneOrigin        = Zone.GetZoneOrigin(outpostData.areaSouthWestOrigin, zoneAbs, zoneOrd);
             IntVec3        zoneRotatedOrigin = Zone.GetZoneRotatedOrigin(outpostData.areaSouthWestOrigin, zoneAbs, zoneOrd, zone.rotation);
             if (zone.zoneType == ZoneType.MainEntrance)
             {
                 SpawnLaserFenceTwoPylons(zoneRotatedOrigin + new IntVec3(0, 0, 5).RotatedBy(zone.rotation), new Rot4(Rot4.North.AsInt + zone.rotation.AsInt), 4, ref outpostData);
                 SpawnLaserFenceTwoPylons(zoneRotatedOrigin + new IntVec3(10, 0, 5).RotatedBy(zone.rotation), new Rot4(Rot4.North.AsInt + zone.rotation.AsInt), 4, ref outpostData);
             }
             else if (zone.zoneType == ZoneType.SecondaryEntrance)
             {
                 SpawnLaserFenceThreePylons(zoneRotatedOrigin, new Rot4(Rot4.North.AsInt + zone.rotation.AsInt), 4, ref outpostData);
                 SpawnLaserFenceThreePylons(zoneRotatedOrigin + new IntVec3(10, 0, 0).RotatedBy(zone.rotation), new Rot4(Rot4.North.AsInt + zone.rotation.AsInt), 4, ref outpostData);
                 OG_Common.SpawnFireproofPowerConduitAt(zoneRotatedOrigin + new IntVec3(0, 0, -1).RotatedBy(zone.rotation), ref outpostData);
                 OG_Common.SpawnFireproofPowerConduitAt(zoneRotatedOrigin + new IntVec3(10, 0, -1).RotatedBy(zone.rotation), ref outpostData);
             }
             else
             {
                 if (zoneOrd == 0)
                 {
                     if (Zone.IsZoneMediumRoom(zone.zoneType))
                     {
                         SpawnLaserFenceTwoPylons(zoneOrigin, Rot4.East, 2, ref outpostData);
                         SpawnLaserFenceTwoPylons(zoneOrigin + new IntVec3(7, 0, 0), Rot4.East, 2, ref outpostData);
                     }
                     else
                     {
                         SpawnLaserFenceThreePylons(zoneOrigin, Rot4.East, 4, ref outpostData);
                     }
                 }
                 if (zoneOrd == verticalZonesNumber - 1)
                 {
                     if (Zone.IsZoneMediumRoom(zone.zoneType))
                     {
                         SpawnLaserFenceTwoPylons(zoneOrigin + new IntVec3(0, 0, 10), Rot4.East, 2, ref outpostData);
                         SpawnLaserFenceTwoPylons(zoneOrigin + new IntVec3(7, 0, 10), Rot4.East, 2, ref outpostData);
                     }
                     else
                     {
                         SpawnLaserFenceThreePylons(zoneOrigin + new IntVec3(0, 0, 10), Rot4.East, 4, ref outpostData);
                     }
                 }
                 if (zoneAbs == 0)
                 {
                     if (Zone.IsZoneMediumRoom(zone.zoneType))
                     {
                         SpawnLaserFenceTwoPylons(zoneOrigin, Rot4.North, 2, ref outpostData);
                         SpawnLaserFenceTwoPylons(zoneOrigin + new IntVec3(0, 0, 7), Rot4.North, 2, ref outpostData);
                     }
                     else
                     {
                         SpawnLaserFenceThreePylons(zoneOrigin, Rot4.North, 4, ref outpostData);
                     }
                 }
                 if (zoneAbs == horizontalZonesNumber - 1)
                 {
                     if (Zone.IsZoneMediumRoom(zone.zoneType))
                     {
                         SpawnLaserFenceTwoPylons(zoneOrigin + new IntVec3(10, 0, 0), Rot4.North, 2, ref outpostData);
                         SpawnLaserFenceTwoPylons(zoneOrigin + new IntVec3(10, 0, 7), Rot4.North, 2, ref outpostData);
                     }
                     else
                     {
                         SpawnLaserFenceThreePylons(zoneOrigin + new IntVec3(10, 0, 0), Rot4.North, 4, ref outpostData);
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 19
0
        private static void GenerateLaseFenceForSmallOutpost(ZoneProperties[,] zoneMap, int horizontalZonesNumber, int verticalZonesNumber, ref OG_OutpostData outpostData)
        {
            for (int zoneOrd = 0; zoneOrd < verticalZonesNumber; zoneOrd++)
            {
                for (int zoneAbs = 0; zoneAbs < horizontalZonesNumber; zoneAbs++)
                {
                    // Standard case: only generate laser fence on border zones.
                    if ((zoneOrd == 0) || (zoneOrd == verticalZonesNumber - 1) || (zoneAbs == 0) || (zoneAbs == horizontalZonesNumber - 1))
                    {
                        ZoneProperties zone = zoneMap[zoneOrd, zoneAbs];
                        IntVec3 zoneOrigin = Zone.GetZoneOrigin(outpostData.areaSouthWestOrigin, zoneAbs, zoneOrd);
                        IntVec3 zoneRotatedOrigin = Zone.GetZoneRotatedOrigin(outpostData.areaSouthWestOrigin, zoneAbs, zoneOrd, zone.rotation);
                        IntVec3 laserFenceOrigin;
                        switch (zone.zoneType)
                        {
                            case ZoneType.NotYetGenerated:
                                if (zoneAbs == 0)
                                {
                                    // Try to spawn laser fence along absolute east side.
                                    laserFenceOrigin = zoneOrigin + new IntVec3(Genstep_GenerateOutpost.zoneSideSize, 0, 0);
                                    SpawnLaserFenceWithoutEntrance(laserFenceOrigin, Rot4.West, ref outpostData);
                                }
                                else if (zoneAbs == horizontalZonesNumber - 1)
                                {
                                    // Try to spawn laser fence along absolute west side.
                                    laserFenceOrigin = zoneOrigin + new IntVec3(-1, 0, Genstep_GenerateOutpost.zoneSideSize - 1);
                                    SpawnLaserFenceWithoutEntrance(laserFenceOrigin, Rot4.East, ref outpostData);
                                }
                                if (zoneOrd == 0)
                                {
                                    // Try to spawn laser fence along absolute north side.
                                    laserFenceOrigin = zoneOrigin + new IntVec3(Genstep_GenerateOutpost.zoneSideSize - 1, 0, Genstep_GenerateOutpost.zoneSideSize);
                                    SpawnLaserFenceWithoutEntrance(laserFenceOrigin, Rot4.South, ref outpostData);
                                }
                                else if (zoneOrd == verticalZonesNumber - 1)
                                {
                                    // Try to spawn laser fence along absolute south side.
                                    laserFenceOrigin = zoneOrigin + new IntVec3(0, 0, -1);
                                    SpawnLaserFenceWithoutEntrance(laserFenceOrigin, Rot4.North, ref outpostData);
                                }
                                break;

                            case ZoneType.SmallRoomBarracks:
                            case ZoneType.SmallRoomMedibay:
                            case ZoneType.SmallRoomWeaponRoom:
                            case ZoneType.SmallRoomBatteryRoom:
                                laserFenceOrigin = zoneRotatedOrigin + new IntVec3(0, 0, Genstep_GenerateOutpost.zoneSideSize - 1).RotatedBy(new Rot4(zone.rotation.AsInt));
                                SpawnLaserFenceWithEntrance(laserFenceOrigin, zone.rotation, 1, ref outpostData);
                                break;

                            case ZoneType.SmallRoomCommandRoom:
                                laserFenceOrigin = zoneRotatedOrigin + new IntVec3(0, 0, Genstep_GenerateOutpost.zoneSideSize - 1).RotatedBy(new Rot4(zone.rotation.AsInt));
                                SpawnLaserFenceWithoutEntrance(laserFenceOrigin, zone.rotation, ref outpostData);
                                // Try to spawn laser fence along linked side.
                                if (zone.linkedZoneRelativeRotation == Rot4.West)
                                {
                                    laserFenceOrigin = zoneRotatedOrigin;
                                }
                                else if (zone.linkedZoneRelativeRotation == Rot4.East)
                                {
                                    laserFenceOrigin = zoneRotatedOrigin + new IntVec3(Genstep_GenerateOutpost.zoneSideSize - 1, 0, Genstep_GenerateOutpost.zoneSideSize - 1).RotatedBy(new Rot4(zone.rotation.AsInt));
                                }
                                SpawnLaserFenceWithEntrance(laserFenceOrigin, new Rot4(zone.rotation.AsInt + zone.linkedZoneRelativeRotation.AsInt), 1, ref outpostData);
                                break;

                            case ZoneType.SolarPanelZone:
                                laserFenceOrigin = zoneRotatedOrigin + new IntVec3(0, 0, Genstep_GenerateOutpost.zoneSideSize - 1).RotatedBy(new Rot4(zone.rotation.AsInt));
                                SpawnLaserFenceWithoutEntrance(laserFenceOrigin, zone.rotation, ref outpostData);
                                // Try to spawn laser fence along opposite linked side.
                                laserFenceOrigin = zoneRotatedOrigin;
                                if (zone.linkedZoneRelativeRotation == Rot4.West)
                                {
                                    laserFenceOrigin = zoneRotatedOrigin + new IntVec3(Genstep_GenerateOutpost.zoneSideSize - 1, 0, Genstep_GenerateOutpost.zoneSideSize - 1).RotatedBy(new Rot4(zone.rotation.AsInt));
                                    SpawnLaserFenceWithoutEntrance(laserFenceOrigin, new Rot4(zone.rotation.AsInt + Rot4.East.AsInt), ref outpostData);
                                }
                                else if (zone.linkedZoneRelativeRotation == Rot4.East)
                                {
                                    laserFenceOrigin = zoneRotatedOrigin;
                                    SpawnLaserFenceWithoutEntrance(laserFenceOrigin, new Rot4(zone.rotation.AsInt + Rot4.West.AsInt), ref outpostData);
                                }
                                break;
                            case ZoneType.DropZone:
                                // Try to spawn laser fence along relative south side.
                                laserFenceOrigin = zoneRotatedOrigin + new IntVec3(Genstep_GenerateOutpost.zoneSideSize - 1, 0, -1).RotatedBy(new Rot4(zone.rotation.AsInt));
                                SpawnLaserFenceWithoutEntrance(laserFenceOrigin, new Rot4(zone.rotation.AsInt + Rot4.South.AsInt), ref outpostData);
                                break;

                            case ZoneType.Empty:
                                laserFenceOrigin = zoneRotatedOrigin + new IntVec3(0, 0, Genstep_GenerateOutpost.zoneSideSize - 1).RotatedBy(new Rot4(zone.rotation.AsInt));
                                SpawnLaserFenceWithEntrance(laserFenceOrigin, zone.rotation, 1, ref outpostData);
                                break;
                            case ZoneType.SecondaryEntrance:
                                laserFenceOrigin = zoneRotatedOrigin + new IntVec3(0, 0, Genstep_GenerateOutpost.zoneSideSize - 1).RotatedBy(new Rot4(zone.rotation.AsInt));
                                SpawnLaserFenceWithEntrance(laserFenceOrigin, zone.rotation, 3, ref outpostData);
                                break;
                        }
                    }
                }
            }
        }
        public static void GenerateBigRoomBatteryRoom(IntVec3 areaSouthWestOrigin, int zoneAbs, int zoneOrd, Rot4 rotation, ZoneProperties[,] zoneMap, ref OG_OutpostData outpostData)
        {
            IntVec3 origin = Zone.GetZoneOrigin(areaSouthWestOrigin, zoneAbs, zoneOrd);
            IntVec3 rotatedOrigin = Zone.GetZoneRotatedOrigin(areaSouthWestOrigin, zoneAbs, zoneOrd, rotation);

            OG_Common.GenerateEmptyRoomAt(rotatedOrigin, Genstep_GenerateOutpost.zoneSideSize, Genstep_GenerateOutpost.zoneSideSize, rotation, TerrainDefOf.Concrete, TerrainDef.Named("MetalTile"), ref outpostData);

            // Spawn doors.
            OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(5, 0, 10).RotatedBy(rotation), ref outpostData);
            OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(10, 0, 5).RotatedBy(rotation), ref outpostData);
            OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(5, 0, 0).RotatedBy(rotation), ref outpostData);
            OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(0, 0, 5).RotatedBy(rotation), ref outpostData);

            // Spawn generators.
            OG_Common.TrySpawnThingAt(OG_Util.CompactAutonomousGeneratorDef, null, rotatedOrigin + new IntVec3(1, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(OG_Util.CompactAutonomousGeneratorDef, null, rotatedOrigin + new IntVec3(1, 0, 8).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(OG_Util.CompactAutonomousGeneratorDef, null, rotatedOrigin + new IntVec3(8, 0, 8).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);

            // Spawn batteries.
            OG_Common.TrySpawnThingAt(ThingDefOf.Battery, null, rotatedOrigin + new IntVec3(1, 0, 3).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Battery, null, rotatedOrigin + new IntVec3(3, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.East.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Battery, null, rotatedOrigin + new IntVec3(1, 0, 7).RotatedBy(rotation), true, new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Battery, null, rotatedOrigin + new IntVec3(3, 0, 9).RotatedBy(rotation), true, new Rot4(Rot4.East.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Battery, null, rotatedOrigin + new IntVec3(9, 0, 7).RotatedBy(rotation), true, new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDefOf.Battery, null, rotatedOrigin + new IntVec3(7, 0, 9).RotatedBy(rotation), true, new Rot4(Rot4.West.AsInt + rotation.AsInt), ref outpostData);

            // Spawn power controller.
            OG_Common.TrySpawnThingAt(ThingDef.Named("MultiAnalyzer"), null, rotatedOrigin + new IntVec3(7, 0, 2).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);

            // Spawn lamp and vents.
            OG_Common.TrySpawnLampAt(rotatedOrigin + new IntVec3(3, 0, 7).RotatedBy(rotation), Color.blue, ref outpostData);
            for (int cardinalAsInt = 0; cardinalAsInt < 4; cardinalAsInt++)
            {
                Rot4 cardinal = new Rot4(cardinalAsInt);
                int adjacentZoneAbs = 0;
                int adjacentZoneOrd = 0;
                Zone.GetAdjacentZone(zoneAbs, zoneOrd, cardinal, out adjacentZoneAbs, out adjacentZoneOrd);
                if (zoneMap[adjacentZoneOrd, adjacentZoneAbs].zoneType == ZoneType.SolarPanelZone)
                {
                    if (cardinal == Rot4.North)
                    {
                        OG_Common.SpawnVentAt(origin + new IntVec3(4, 0, 10), Rot4.North, ref outpostData);
                        OG_Common.SpawnVentAt(origin + new IntVec3(6, 0, 10), Rot4.North, ref outpostData);
                    }
                    else if (cardinal == Rot4.East)
                    {
                        OG_Common.SpawnVentAt(origin + new IntVec3(10, 0, 4), Rot4.East, ref outpostData);
                        OG_Common.SpawnVentAt(origin + new IntVec3(10, 0, 6), Rot4.East, ref outpostData);
                    }
                    else if (cardinal == Rot4.South)
                    {
                        OG_Common.SpawnVentAt(origin + new IntVec3(4, 0, 0), Rot4.South, ref outpostData);
                        OG_Common.SpawnVentAt(origin + new IntVec3(6, 0, 0), Rot4.West, ref outpostData);
                    }
                    else if (cardinal == Rot4.West)
                    {
                        OG_Common.SpawnVentAt(origin + new IntVec3(0, 0, 4), Rot4.West, ref outpostData);
                        OG_Common.SpawnVentAt(origin + new IntVec3(0, 0, 6), Rot4.West, ref outpostData);
                    }
                }
            }

            OG_Common.GenerateHorizontalAndVerticalPavedAlleys(origin);
        }