public override void Resolve(ResolveParams rp)
        {
            int zOffset = 7;
            int xOffset = 6;

            rp.faction = rp.faction ?? BaseGen.globalSettings.map.ParentFaction; //Find.FactionManager.RandomNonHostileFaction();
            Faction enemyFaction = FindEnemyFaction(rp.faction);

            CellRect settlementRect = new CellRect(rp.rect.minX, rp.rect.minZ, rp.rect.Width, rp.rect.Height - zOffset);
            CellRect prisonerRect   = new CellRect(rp.rect.minX + xOffset, rp.rect.minZ + rp.rect.Height - zOffset + 1, rp.rect.Width - xOffset * 2, zOffset);

            ResolveParams resolveParmsPrisoners = rp;

            resolveParmsPrisoners.rect = prisonerRect.ContractedBy(1);
            //resolveParmsPrisoners.faction = rp.faction ?? Find.FactionManager.RandomNonHostileFaction();
            BaseGen.symbolStack.Push("relaxedPrisonersLGE", resolveParmsPrisoners);

            ResolveParams resolveParmsInterior = rp;

            resolveParmsInterior.faction = enemyFaction;
            resolveParmsInterior.rect    = prisonerRect.ContractedBy(1);
            //Multiple times for multiple beds and some additional food
            BaseGen.symbolStack.Push("interior_prisonCell", resolveParmsInterior);
            BaseGen.symbolStack.Push("interior_prisonCell", resolveParmsInterior);

            MapGenerator.rootsToUnfog.Add(resolveParmsInterior.rect.CenterCell);

            ResolveParams resolveParmsDoors = rp;

            resolveParmsDoors.rect    = prisonerRect;
            resolveParmsDoors.faction = enemyFaction;
            BaseGen.symbolStack.Push("doors", resolveParmsDoors);

            ResolveParams resolveParmsRoom = rp;

            resolveParmsRoom.rect    = prisonerRect;
            resolveParmsRoom.faction = enemyFaction;
            BaseGen.symbolStack.Push("emptyRoom", resolveParmsRoom);

            /*ResolveParams resolveParmsPrisonRoom = rp;
             * resolveParmsPrisonRoom.rect = prisonerRect;
             * BaseGen.symbolStack.Push("prisonRoomLGE", resolveParmsPrisonRoom);
             */

            ResolveParams resolveParmsSettlement = rp;

            resolveParmsSettlement.rect    = settlementRect;
            resolveParmsSettlement.faction = enemyFaction;
            BaseGen.symbolStack.Push("settlement", resolveParmsSettlement);
        }
Exemple #2
0
 private void SetupSecondPass(CellRect rect)
 {
     foreach (IntVec3 c in rect.ContractedBy(2))
     {
         Map.terrainGrid.SetTerrain(c, QuarryDefOf.QRY_QuarriedGround);
     }
 }
        public override void Resolve(ResolveParams rp)
        {
            ThingDef thingDef = rp.cultivatedPlantDef ?? SymbolResolver_CultivatedPlants.DeterminePlantDef(rp.rect);
            bool     flag     = rp.rect.Width >= 7 && rp.rect.Height >= 7 && (rp.rect.Width > 12 || rp.rect.Height > 12 || Rand.Bool) && thingDef.plant.Harvestable;

            if (flag)
            {
                CellRect rect = new CellRect(rp.rect.maxX - 3, rp.rect.maxZ - 3, 4, 4);
                ThingDef harvestedThingDef = thingDef.plant.harvestedThingDef;
                int      num = Rand.RangeInclusive(2, 3);
                for (int i = 0; i < num; i++)
                {
                    ResolveParams resolveParams = rp;
                    resolveParams.rect                  = rect.ContractedBy(1);
                    resolveParams.singleThingDef        = harvestedThingDef;
                    resolveParams.singleThingStackCount = new int?(Rand.RangeInclusive(Mathf.Min(10, harvestedThingDef.stackLimit), Mathf.Min(50, harvestedThingDef.stackLimit)));
                    BaseGen.symbolStack.Push("thing", resolveParams);
                }
                ResolveParams resolveParams2 = rp;
                resolveParams2.rect = rect;
                BaseGen.symbolStack.Push("ensureCanReachMapEdge", resolveParams2);
                ResolveParams resolveParams3 = rp;
                resolveParams3.rect = rect;
                BaseGen.symbolStack.Push("emptyRoom", resolveParams3);
            }
            ResolveParams resolveParams4 = rp;

            resolveParams4.cultivatedPlantDef = thingDef;
            BaseGen.symbolStack.Push("cultivatedPlants", resolveParams4);
        }
Exemple #4
0
        public override void Resolve(ResolveParams rp)
        {
            var rect          = new CellRect(rp.rect.maxX - 3, rp.rect.maxZ - 3, 4, 4);
            var gloriousPotat = ThingDefOf.RawPotatoes;
            var num           = Rand.RangeInclusive(2, 3);

            for (var i = 0; i < num; i++)
            {
                var resolveParams = rp;
                resolveParams.rect                  = rect.ContractedBy(1);
                resolveParams.singleThingDef        = gloriousPotat;
                resolveParams.singleThingStackCount = Rand.RangeInclusive(Mathf.Min(10, gloriousPotat.stackLimit),
                                                                          Mathf.Min(50, gloriousPotat.stackLimit));
                BaseGen.symbolStack.Push("thing", resolveParams);
            }

            var resolveParams2 = rp;

            resolveParams2.rect = rect;
            BaseGen.symbolStack.Push("ensureCanReachMapEdge", resolveParams2);
            var resolveParams3 = rp;

            resolveParams3.rect = rect;
            BaseGen.symbolStack.Push("emptyRoom", resolveParams3);
        }
Exemple #5
0
        // Token: 0x06000004 RID: 4 RVA: 0x000020B0 File Offset: 0x000002B0
        public override void PostDrawExtraSelectionOverlays()
        {
            base.PostDrawExtraSelectionOverlays();
            Map      currentMap = Find.CurrentMap;
            CellRect cellRect   = CellRect.CenteredOn(this.parent.Position, 1).ExpandedBy(Mathf.RoundToInt(this.radius));
            CellRect cellRect2  = cellRect.ContractedBy(1);

            GenDraw.DrawFieldEdges(this.ValidCellsAround(this.parent.Position, currentMap, cellRect), Color.gray);
            GenDraw.DrawFieldEdges(this.ValidCellsAround(this.parent.Position, currentMap, cellRect2));
        }
Exemple #6
0
            internal bool <> m__0(IntVec3 x)
            {
                CellRect cellRect = this.rp.rect;

                for (int i = 0; i < this.width; i++)
                {
                    if (cellRect.IsOnEdge(x))
                    {
                        return(true);
                    }
                    cellRect = cellRect.ContractedBy(1);
                }
                return(true);
            }
Exemple #7
0
        public override void SpawnSetup(Map map, bool respawningAfterLoad)
        {
            base.SpawnSetup(map, respawningAfterLoad);

            facilityComp = GetComp <CompAffectedByFacilities>();

            if (firstSpawn)
            {
                // Set the initial quarry health
                quarryPercent = 1f;

                CellRect rect = this.OccupiedRect();
                // Remove this area from the quarry grid. Quarries can never be built here again
                map.GetComponent <QuarryGrid>().RemoveFromGrid(rect);

                foreach (IntVec3 c in rect)
                {
                    // What type of terrain are we over?
                    string rockType = c.GetTerrain(Map).label.Split(' ').Last().CapitalizeFirst();
                    // If this is a valid rock type, add it to the list
                    if (QuarryUtility.IsValidQuarryRock(rockType))
                    {
                        rockTypesUnder.Add(rockType);
                    }
                    // Change the terrain here to be quarried stone
                    if (rect.ContractedBy(WallThickness).Contains(c))
                    {
                        Map.terrainGrid.SetTerrain(c, QuarryDefOf.QRY_QuarriedGround);
                    }
                    else
                    {
                        Map.terrainGrid.SetTerrain(c, QuarryDefOf.QRY_QuarriedGroundWall);
                    }
                }
                // Now that all the cells have been processed, create ThingDef lists
                MakeThingDefListsFrom(RockTypesUnder);
                // Spawn filth for the quarry
                foreach (IntVec3 c in rect)
                {
                    SpawnFilth(c);
                }
                // Change the ground back to normal quarried stone where the ladders are
                // This is to negate the speed decrease and encourages pawns to use the ladders
                foreach (IntVec3 offset in LadderOffsets)
                {
                    Map.terrainGrid.SetTerrain(Position + offset.RotatedBy(Rotation), QuarryDefOf.QRY_QuarriedGround);
                }
            }
        }
Exemple #8
0
        public override void SpawnSetup(Map map, bool respawningAfterLoad)
        {
            base.SpawnSetup(map, respawningAfterLoad);

            facilityComp = GetComp <CompAffectedByFacilities>();

            if (!respawningAfterLoad)
            {
                // Set the initial quarry health
                quarryPercent = 1f;

                CellRect rect = this.OccupiedRect();
                // Remove this area from the quarry grid. Quarries can never be built here again
                //    map.GetComponent<QuarryGrid>().RemoveFromGrid(rect);
                RockTypesFromUnder();
                // Now that all the cells have been processed, create ThingDef lists
                // Change the terrain here to be quarried stone
                // Spawn filth for the quarry
                foreach (IntVec3 c in rect)
                {
                    SpawnFilth(c);
                    if (rect.ContractedBy(WallThickness).Contains(c))
                    {
                        Map.terrainGrid.SetTerrain(c, QuarryDefOf.QRY_QuarriedGround);
                    }
                    else
                    {
                        Map.terrainGrid.SetTerrain(c, QuarryDefOf.QRY_QuarriedGroundWall);
                    }
                }
                // Change the ground back to normal quarried stone where the ladders are
                // This is to negate the speed decrease and encourages pawns to use the ladders
                foreach (IntVec3 offset in LadderOffsets)
                {
                    Map.terrainGrid.SetTerrain(Position + offset.RotatedBy(Rotation), QuarryDefOf.QRY_QuarriedGround);
                }
            }
        }
        private static bool TryFindSiegePosition(IntVec3 entrySpot, float minDistToColony, Map map, out IntVec3 result)
        {
            CellRect cellRect = CellRect.CenteredOn(entrySpot, 60);

            cellRect.ClipInsideMap(map);
            cellRect = cellRect.ContractedBy(14);
            List <IntVec3> list = new List <IntVec3>();

            foreach (Pawn item in map.mapPawns.FreeColonistsSpawned)
            {
                list.Add(item.Position);
            }
            foreach (Building allBuildingsColonistCombatTarget in map.listerBuildings.allBuildingsColonistCombatTargets)
            {
                list.Add(allBuildingsColonistCombatTarget.Position);
            }
            float num  = minDistToColony * minDistToColony;
            int   num2 = 0;

            goto IL_00bc;
IL_00bc:
            while (true)
            {
                num2++;
                if (num2 <= 200)
                {
                    IntVec3 randomCell = cellRect.RandomCell;
                    if (!randomCell.Standable(map))
                    {
                        continue;
                    }
                    if (!randomCell.SupportsStructureType(map, TerrainAffordance.Heavy))
                    {
                        continue;
                    }
                    if (!randomCell.SupportsStructureType(map, TerrainAffordance.Light))
                    {
                        continue;
                    }
                    if (!map.reachability.CanReach(randomCell, entrySpot, PathEndMode.OnCell, TraverseMode.NoPassClosedDoors, Danger.Some))
                    {
                        continue;
                    }
                    if (!map.reachability.CanReachColony(randomCell))
                    {
                        continue;
                    }
                    bool flag = false;
                    int  num3 = 0;
                    while (num3 < list.Count)
                    {
                        if (!((float)(list[num3] - randomCell).LengthHorizontalSquared < num))
                        {
                            num3++;
                            continue;
                        }
                        flag = true;
                        break;
                    }
                    if (flag)
                    {
                        continue;
                    }
                    if (randomCell.Roofed(map))
                    {
                        continue;
                    }
                    result = randomCell;
                    return(true);
                }
                break;
            }
            result = IntVec3.Invalid;
            return(false);

IL_01b4:
            goto IL_00bc;
        }
Exemple #10
0
        public override void SpawnSetup(Map map, bool respawningAfterLoad)
        {
            base.SpawnSetup(map, respawningAfterLoad);

            facilityComp = GetComp <CompAffectedByFacilities>();

            if (firstSpawn)
            {
                // Set the initial quarry health
                quarryPercent = 1f;

                CellRect rect = this.OccupiedRect();
                // Remove this area from the quarry grid. Quarries can never be built here again
                //    map.GetComponent<QuarryGrid>().RemoveFromGrid(rect);

                foreach (IntVec3 c in rect)
                {
                    // What type of terrain are we over?
                    TerrainDef td = c.GetTerrain(Map);
                    // Original method, problem here is that mods that use prefixes like Alpha Biomes "AB_" trigger the split and only pass the prefix, not the defname
                    //    string rockType = td.defName.Split('_').First();
                    // this seems like a better method, mods with prfixes are a little easier to handle stone from
                    string rockType = td.defName;
                    if (rockType.EndsWith("_Rough"))
                    {
                        rockType = rockType.Replace("_Rough", "");
                    }
                    else
                    if (rockType.EndsWith("_RoughHewn"))
                    {
                        rockType = rockType.Replace("_RoughHewn", "");
                    }
                    else
                    if (rockType.EndsWith("_Smooth"))
                    {
                        rockType = rockType.Replace("_Smooth", "");
                    }
                    else
                    {
                        continue;
                    }
                    //   crappy alpha biomes compatability, gotta be a better method
                    if (rockType.StartsWith("GU_"))
                    {
                        rockType = rockType.Replace("GU_", "");
                    }
                    if (rockType.StartsWith("AB_"))
                    {
                        rockType = rockType.Replace("AB_", "");
                    }
                    // If this is a valid rock type, add it to the list
                    if (QuarryUtility.IsValidQuarryRock(rockType))
                    {
                        rockTypesUnder.Add(rockType);
                    }
                    // Change the terrain here to be quarried stone
                    if (rect.ContractedBy(WallThickness).Contains(c))
                    {
                        Map.terrainGrid.SetTerrain(c, QuarryDefOf.QRY_QuarriedGround);
                    }
                    else
                    {
                        Map.terrainGrid.SetTerrain(c, QuarryDefOf.QRY_QuarriedGroundWall);
                    }
                }
                // Now that all the cells have been processed, create ThingDef lists
                MakeThingDefListsFrom(RockTypesUnder);
                // Spawn filth for the quarry
                foreach (IntVec3 c in rect)
                {
                    SpawnFilth(c);
                }
                // Change the ground back to normal quarried stone where the ladders are
                // This is to negate the speed decrease and encourages pawns to use the ladders
                foreach (IntVec3 offset in LadderOffsets)
                {
                    Map.terrainGrid.SetTerrain(Position + offset.RotatedBy(Rotation), QuarryDefOf.QRY_QuarriedGround);
                }
            }
        }
Exemple #11
0
        public static Building_OutpostCommandConsole GenerateBigRoomCommandRoom(IntVec3 areaSouthWestOrigin, int zoneAbs, int zoneOrd, Rot4 rotation, ref OG_OutpostData outpostData)
        {
            Building_OutpostCommandConsole commandConsole = null;

            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("CarpetDark"), 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 weapon racks.
            Building_Storage rack = OG_Common.TrySpawnThingAt(ThingDefOf.EquipmentRack, ThingDefOf.Steel, rotatedOrigin + new IntVec3(2, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData) as Building_Storage;

            OG_Common.TrySpawnWeaponOnRack(rack);
            rack.GetStoreSettings().filter.SetAllow(ThingCategoryDef.Named("WeaponsMelee"), false);
            rack.GetStoreSettings().Priority = StoragePriority.Critical;
            rack = OG_Common.TrySpawnThingAt(ThingDefOf.EquipmentRack, ThingDefOf.Steel, rotatedOrigin + new IntVec3(1, 0, 3).RotatedBy(rotation), true, new Rot4(Rot4.East.AsInt + rotation.AsInt), ref outpostData) as Building_Storage;
            OG_Common.TrySpawnWeaponOnRack(rack);
            rack.GetStoreSettings().filter.SetAllow(ThingCategoryDef.Named("WeaponsMelee"), false);
            rack.GetStoreSettings().Priority = StoragePriority.Critical;

            // Spawn lamps.
            OG_Common.TrySpawnLampAt(rotatedOrigin + new IntVec3(1, 0, 1).RotatedBy(rotation), Color.white, ref outpostData);
            OG_Common.TrySpawnLampAt(rotatedOrigin + new IntVec3(9, 0, 9).RotatedBy(rotation), Color.white, ref outpostData);

            // Spawn table and stools.
            OG_Common.TrySpawnThingAt(ThingDef.Named("Stool"), ThingDefOf.Steel, rotatedOrigin + new IntVec3(7, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.East.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDef.Named("Stool"), ThingDefOf.Steel, rotatedOrigin + new IntVec3(8, 0, 3).RotatedBy(rotation), true, new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDef.Named("TableShort"), ThingDefOf.Steel, rotatedOrigin + new IntVec3(8, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);

            // Spawn outpost command console, battery and spare parts cabinet.
            OG_Common.TrySpawnThingAt(ThingDefOf.Battery, null, rotatedOrigin + new IntVec3(1, 0, 9).RotatedBy(rotation), true, new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(OG_Util.SparePartsCabinetDef, null, rotatedOrigin + new IntVec3(1, 0, 7).RotatedBy(rotation), true, new Rot4(Rot4.East.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.SpawnResourceAt(ThingDefOf.Component, 10, rotatedOrigin + new IntVec3(1, 0, 7).RotatedBy(rotation), true);
            OG_Common.SpawnResourceAt(ThingDefOf.Component, 10, rotatedOrigin + new IntVec3(1, 0, 6).RotatedBy(rotation), true);
            commandConsole = OG_Common.TrySpawnThingAt(OG_Util.OutpostCommandConsoleDef, null, rotatedOrigin + new IntVec3(3, 0, 9).RotatedBy(rotation), true, new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData) as Building_OutpostCommandConsole;

            // Spawn workbenches.
            OG_Common.TrySpawnThingAt(ThingDef.Named("TableMachining"), null, rotatedOrigin + new IntVec3(7, 0, 9).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDef.Named("ElectricSmithy"), null, rotatedOrigin + new IntVec3(9, 0, 7).RotatedBy(rotation), true, new Rot4(Rot4.East.AsInt + rotation.AsInt), ref outpostData);

            // Spawn heaters and coolers.
            OG_Common.TrySpawnHeaterAt(rotatedOrigin + new IntVec3(1, 0, 4).RotatedBy(rotation), ref outpostData);
            OG_Common.TrySpawnHeaterAt(rotatedOrigin + new IntVec3(4, 0, 1).RotatedBy(rotation), ref outpostData);
            OG_Common.SpawnCoolerAt(rotatedOrigin + new IntVec3(0, 0, 1).RotatedBy(rotation), new Rot4(Rot4.West.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.SpawnCoolerAt(rotatedOrigin + new IntVec3(1, 0, 0).RotatedBy(rotation), new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData);

            // Spawn floor and tactical computer.
            for (int xOffset = 0; xOffset <= 10; xOffset++)
            {
                Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, 5).RotatedBy(rotation), TerrainDef.Named("PavedTile"));
            }
            for (int zOffset = 0; zOffset <= 10; zOffset++)
            {
                Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(5, 0, zOffset).RotatedBy(rotation), TerrainDef.Named("PavedTile"));
            }
            CellRect rect = new CellRect(origin.x + 3, origin.z + 3, 5, 5);

            foreach (IntVec3 cell in rect)
            {
                Find.TerrainGrid.SetTerrain(cell, TerrainDef.Named("PavedTile"));
            }
            foreach (IntVec3 cell in rect.ContractedBy(1))
            {
                Find.TerrainGrid.SetTerrain(cell, TerrainDef.Named("CarpetRed"));
            }
            if (OG_Util.IsModActive("Misc. Incidents"))
            {
                OG_Common.TrySpawnThingAt(ThingDef.Named("TacticalComputer"), null, rotatedOrigin + new IntVec3(5, 0, 5).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);
            }

            return(commandConsole);
        }
        public override void Resolve(ResolveParams rp)
        {
            Map     map     = BaseGen.globalSettings.map;
            Faction faction = rp.faction ?? Find.FactionManager.RandomEnemyFaction(false, false, true, TechLevel.Undefined);
            int?    edgeDefenseGuardsCount = rp.edgeDefenseGuardsCount;
            int     num = (!edgeDefenseGuardsCount.HasValue) ? 0 : edgeDefenseGuardsCount.Value;
            int     width;

            if (rp.edgeDefenseWidth.HasValue)
            {
                width = rp.edgeDefenseWidth.Value;
            }
            else if (rp.edgeDefenseMortarsCount.HasValue && rp.edgeDefenseMortarsCount.Value > 0)
            {
                width = 4;
            }
            else
            {
                width = ((!Rand.Bool) ? 4 : 2);
            }
            width = Mathf.Clamp(width, 1, Mathf.Min(rp.rect.Width, rp.rect.Height) / 2);
            int  num2;
            int  num3;
            bool flag;
            bool flag2;
            bool flag3;

            switch (width)
            {
            case 1:
            {
                int?edgeDefenseTurretsCount = rp.edgeDefenseTurretsCount;
                num2  = ((!edgeDefenseTurretsCount.HasValue) ? 0 : edgeDefenseTurretsCount.Value);
                num3  = 0;
                flag  = false;
                flag2 = true;
                flag3 = true;
                break;
            }

            case 2:
            {
                int?edgeDefenseTurretsCount2 = rp.edgeDefenseTurretsCount;
                num2  = ((!edgeDefenseTurretsCount2.HasValue) ? (rp.rect.EdgeCellsCount / 30) : edgeDefenseTurretsCount2.Value);
                num3  = 0;
                flag  = false;
                flag2 = false;
                flag3 = true;
                break;
            }

            case 3:
            {
                int?edgeDefenseTurretsCount3 = rp.edgeDefenseTurretsCount;
                num2 = ((!edgeDefenseTurretsCount3.HasValue) ? (rp.rect.EdgeCellsCount / 30) : edgeDefenseTurretsCount3.Value);
                int?edgeDefenseMortarsCount = rp.edgeDefenseMortarsCount;
                num3  = ((!edgeDefenseMortarsCount.HasValue) ? (rp.rect.EdgeCellsCount / 75) : edgeDefenseMortarsCount.Value);
                flag  = (num3 == 0);
                flag2 = false;
                flag3 = true;
                break;
            }

            default:
            {
                int?edgeDefenseTurretsCount4 = rp.edgeDefenseTurretsCount;
                num2 = ((!edgeDefenseTurretsCount4.HasValue) ? (rp.rect.EdgeCellsCount / 30) : edgeDefenseTurretsCount4.Value);
                int?edgeDefenseMortarsCount2 = rp.edgeDefenseMortarsCount;
                num3  = ((!edgeDefenseMortarsCount2.HasValue) ? (rp.rect.EdgeCellsCount / 75) : edgeDefenseMortarsCount2.Value);
                flag  = true;
                flag2 = false;
                flag3 = false;
                break;
            }
            }
            if (faction != null && faction.def.techLevel < TechLevel.Industrial)
            {
                num2 = 0;
                num3 = 0;
            }
            if (num > 0)
            {
                Lord singlePawnLord = rp.singlePawnLord ?? LordMaker.MakeNewLord(faction, new LordJob_DefendBase(faction, rp.rect.CenterCell), map, null);
                for (int i = 0; i < num; i++)
                {
                    PawnGenerationRequest value = new PawnGenerationRequest(faction.RandomPawnKind(), faction, PawnGenerationContext.NonPlayer, -1, false, false, false, false, true, true, 1f, false, true, true, false, false, false, false, null, null, null, null, null, null, null, null);
                    ResolveParams         rp2   = rp;
                    rp2.faction        = faction;
                    rp2.singlePawnLord = singlePawnLord;
                    rp2.singlePawnGenerationRequest       = new PawnGenerationRequest?(value);
                    rp2.singlePawnSpawnCellExtraPredicate = (rp2.singlePawnSpawnCellExtraPredicate ?? delegate(IntVec3 x)
                    {
                        CellRect cellRect = rp.rect;
                        for (int m = 0; m < width; m++)
                        {
                            if (cellRect.IsOnEdge(x))
                            {
                                return(true);
                            }
                            cellRect = cellRect.ContractedBy(1);
                        }
                        return(true);
                    });
                    BaseGen.symbolStack.Push("pawn", rp2);
                }
            }
            CellRect rect = rp.rect;

            for (int j = 0; j < width; j++)
            {
                if (j % 2 == 0)
                {
                    ResolveParams rp3 = rp;
                    rp3.faction = faction;
                    rp3.rect    = rect;
                    BaseGen.symbolStack.Push("edgeSandbags", rp3);
                    if (!flag)
                    {
                        break;
                    }
                }
                rect = rect.ContractedBy(1);
            }
            CellRect rect2 = (!flag3) ? rp.rect.ContractedBy(1) : rp.rect;

            for (int k = 0; k < num3; k++)
            {
                ResolveParams rp4 = rp;
                rp4.faction = faction;
                rp4.rect    = rect2;
                BaseGen.symbolStack.Push("edgeMannedMortar", rp4);
            }
            CellRect rect3 = (!flag2) ? rp.rect.ContractedBy(1) : rp.rect;

            for (int l = 0; l < num2; l++)
            {
                ResolveParams rp5 = rp;
                rp5.faction        = faction;
                rp5.singleThingDef = ThingDefOf.Turret_MiniTurret;
                rp5.rect           = rect3;
                bool?edgeThingAvoidOtherEdgeThings = rp.edgeThingAvoidOtherEdgeThings;
                rp5.edgeThingAvoidOtherEdgeThings = new bool?(!edgeThingAvoidOtherEdgeThings.HasValue || edgeThingAvoidOtherEdgeThings.Value);
                BaseGen.symbolStack.Push("edgeThing", rp5);
            }
        }
Exemple #13
0
        public void RoomGeneration(DungeonNode node, bool isStartingRoom)
        {
            //Clear base space
            if (isStartingRoom)
            {
                var finalRoom = new CellRect(node.room.CenterCell.x - 12, node.room.CenterCell.z - 12, 24, 24);
                node.room        = finalRoom;
                startingRoomRect = finalRoom;
            }
            CellRect          rect       = node.room;
            HashSet <IntVec3> edgeCells  = new HashSet <IntVec3>(rect.EdgeCells);
            HashSet <IntVec3> innerCells = new HashSet <IntVec3>(rect.ContractedBy(1).Cells);

            foreach (IntVec3 cell in innerCells)
            {
                if (cellPainter.ContainsKey(cell))
                {
                    if (cellPainter[cell] != SpawnType.Door)
                    {
                        cellPainter[cell] = SpawnType.Floor;
                    }
                }
                else
                {
                    cellPainter.Add(cell, SpawnType.Floor);
                }
            }
            foreach (IntVec3 cell in edgeCells)
            {
                if (cellPainter.ContainsKey(cell))
                {
                    if (cellPainter[cell] == SpawnType.Door)
                    {
                        continue;
                    }
                    //if (cellPainter[cell] == SpawnType.HallwayWall)
                    //{
                    //    cellPainter[cell] = SpawnType.Door;
                    //    continue;
                    //}
                    if (cellPainter[cell] == SpawnType.HallwayFloor)
                    {
                        cellPainter[cell] = SpawnType.Door;
                        continue;
                    }
                    cellPainter[cell] = SpawnType.Wall;
                }
                else
                {
                    cellPainter.Add(cell, SpawnType.Wall);
                }
            }
            hallwaysAndRooms.Add(node.room);
            foreach (var cell in rect.Cells)
            {
                if (isStartingRoom)
                {
                    debugMap[cell.x, cell.z] = 'S';
                }
                else
                {
                    debugMap[cell.x, cell.z] = 'R';
                }
            }
        }
        public override void Resolve(ResolveParams rp)
        {
            Map     map     = BaseGen.globalSettings.map;
            Faction faction = rp.faction ?? Find.FactionManager.RandomEnemyFaction();
            int     num     = rp.edgeDefenseGuardsCount ?? 0;
            int     width;

            if (rp.edgeDefenseWidth.HasValue)
            {
                width = rp.edgeDefenseWidth.Value;
            }
            else if (rp.edgeDefenseMortarsCount.HasValue && rp.edgeDefenseMortarsCount.Value > 0)
            {
                width = 4;
            }
            else
            {
                width = (Rand.Bool ? 2 : 4);
            }
            width = Mathf.Clamp(width, 1, Mathf.Min(rp.rect.Width, rp.rect.Height) / 2);
            int  num2;
            int  num3;
            bool flag;
            bool flag2;
            bool flag3;

            switch (width)
            {
            case 1:
                num2  = rp.edgeDefenseTurretsCount ?? 0;
                num3  = 0;
                flag  = false;
                flag2 = true;
                flag3 = true;
                break;

            case 2:
                num2  = rp.edgeDefenseTurretsCount ?? (rp.rect.EdgeCellsCount / 30);
                num3  = 0;
                flag  = false;
                flag2 = false;
                flag3 = true;
                break;

            case 3:
                num2  = rp.edgeDefenseTurretsCount ?? (rp.rect.EdgeCellsCount / 30);
                num3  = rp.edgeDefenseMortarsCount ?? (rp.rect.EdgeCellsCount / 75);
                flag  = num3 == 0;
                flag2 = false;
                flag3 = true;
                break;

            default:
                num2  = rp.edgeDefenseTurretsCount ?? (rp.rect.EdgeCellsCount / 30);
                num3  = rp.edgeDefenseMortarsCount ?? (rp.rect.EdgeCellsCount / 75);
                flag  = true;
                flag2 = false;
                flag3 = false;
                break;
            }
            if (faction != null && (int)faction.def.techLevel < 4)
            {
                num2 = 0;
                num3 = 0;
            }
            if (num > 0)
            {
                Lord singlePawnLord = rp.singlePawnLord ?? LordMaker.MakeNewLord(faction, new LordJob_DefendBase(faction, rp.rect.CenterCell), map);
                for (int i = 0; i < num; i++)
                {
                    PawnGenerationRequest value         = new PawnGenerationRequest(faction.RandomPawnKind(), faction, PawnGenerationContext.NonPlayer, -1, forceGenerateNewPawn: false, newborn: false, allowDead: false, allowDowned: false, canGeneratePawnRelations: true, mustBeCapableOfViolence: true);
                    ResolveParams         resolveParams = rp;
                    resolveParams.faction        = faction;
                    resolveParams.singlePawnLord = singlePawnLord;
                    resolveParams.singlePawnGenerationRequest       = value;
                    resolveParams.singlePawnSpawnCellExtraPredicate = resolveParams.singlePawnSpawnCellExtraPredicate ?? ((Predicate <IntVec3>) delegate(IntVec3 x)
                    {
                        CellRect cellRect = rp.rect;
                        for (int m = 0; m < width; m++)
                        {
                            if (cellRect.IsOnEdge(x))
                            {
                                return(true);
                            }
                            cellRect = cellRect.ContractedBy(1);
                        }
                        return(true);
                    });
                    BaseGen.symbolStack.Push("pawn", resolveParams);
                }
            }
            CellRect rect = rp.rect;

            for (int j = 0; j < width; j++)
            {
                if (j % 2 == 0)
                {
                    ResolveParams resolveParams2 = rp;
                    resolveParams2.faction = faction;
                    resolveParams2.rect    = rect;
                    BaseGen.symbolStack.Push("edgeSandbags", resolveParams2);
                    if (!flag)
                    {
                        break;
                    }
                }
                rect = rect.ContractedBy(1);
            }
            CellRect rect2 = (flag3 ? rp.rect : rp.rect.ContractedBy(1));

            for (int k = 0; k < num3; k++)
            {
                ResolveParams resolveParams3 = rp;
                resolveParams3.faction = faction;
                resolveParams3.rect    = rect2;
                BaseGen.symbolStack.Push("edgeMannedMortar", resolveParams3);
            }
            CellRect rect3 = (flag2 ? rp.rect : rp.rect.ContractedBy(1));

            for (int l = 0; l < num2; l++)
            {
                ResolveParams resolveParams4 = rp;
                resolveParams4.faction        = faction;
                resolveParams4.singleThingDef = ThingDefOf.Turret_MiniTurret;
                resolveParams4.rect           = rect3;
                resolveParams4.edgeThingAvoidOtherEdgeThings = rp.edgeThingAvoidOtherEdgeThings ?? true;
                BaseGen.symbolStack.Push("edgeThing", resolveParams4);
            }
        }
Exemple #15
0
        private static bool TryFindSiegePosition(IntVec3 entrySpot, float minDistToColony, Map map, bool allowRoofed, out IntVec3 result)
        {
            CellRect cellRect = CellRect.CenteredOn(entrySpot, 60);

            cellRect.ClipInsideMap(map);
            cellRect = cellRect.ContractedBy(14);
            List <IntVec3> list = new List <IntVec3>();

            foreach (Pawn item in map.mapPawns.FreeColonistsSpawned)
            {
                list.Add(item.Position);
            }
            foreach (Building allBuildingsColonistCombatTarget in map.listerBuildings.allBuildingsColonistCombatTargets)
            {
                list.Add(allBuildingsColonistCombatTarget.Position);
            }
            float num  = minDistToColony * minDistToColony;
            int   num2 = 0;

            while (true)
            {
                num2++;
                if (num2 > 200)
                {
                    break;
                }
                IntVec3 randomCell = cellRect.RandomCell;
                if (!randomCell.Standable(map) || !randomCell.SupportsStructureType(map, TerrainAffordanceDefOf.Heavy) || !randomCell.SupportsStructureType(map, TerrainAffordanceDefOf.Light) || !map.reachability.CanReach(randomCell, entrySpot, PathEndMode.OnCell, TraverseMode.NoPassClosedDoors, Danger.Some) || !map.reachability.CanReachColony(randomCell))
                {
                    continue;
                }
                bool flag = false;
                for (int i = 0; i < list.Count; i++)
                {
                    if ((float)(list[i] - randomCell).LengthHorizontalSquared < num)
                    {
                        flag = true;
                        break;
                    }
                }
                if (!flag && (allowRoofed || !randomCell.Roofed(map)))
                {
                    int num3 = 0;
                    foreach (IntVec3 item2 in CellRect.CenteredOn(randomCell, 10).ClipInsideMap(map))
                    {
                        _ = item2;
                        if (randomCell.SupportsStructureType(map, TerrainAffordanceDefOf.Heavy) && randomCell.SupportsStructureType(map, TerrainAffordanceDefOf.Light))
                        {
                            num3++;
                        }
                    }
                    if (num3 >= 35)
                    {
                        result = randomCell;
                        return(true);
                    }
                }
            }
            result = IntVec3.Invalid;
            return(false);
        }
Exemple #16
0
        public static void MakeColony(params ColonyMakerFlag[] flags)
        {
            bool godMode = DebugSettings.godMode;

            DebugSettings.godMode            = true;
            Thing.allowDestroyNonDestroyable = true;
            if (Autotests_ColonyMaker.usedCells == null)
            {
                Autotests_ColonyMaker.usedCells = new BoolGrid(Autotests_ColonyMaker.Map);
            }
            else
            {
                Autotests_ColonyMaker.usedCells.ClearAndResizeTo(Autotests_ColonyMaker.Map);
            }
            IntVec3 center  = Autotests_ColonyMaker.Map.Center;
            int     minX    = center.x - 50;
            IntVec3 center2 = Autotests_ColonyMaker.Map.Center;

            Autotests_ColonyMaker.overRect = new CellRect(minX, center2.z - 50, 100, 100);
            Autotests_ColonyMaker.DeleteAllSpawnedPawns();
            GenDebug.ClearArea(Autotests_ColonyMaker.overRect, Find.VisibleMap);
            if (flags.Contains(ColonyMakerFlag.Animals))
            {
                foreach (PawnKindDef item in from k in DefDatabase <PawnKindDef> .AllDefs
                         where k.RaceProps.Animal
                         select k)
                {
                    CellRect cellRect = default(CellRect);
                    if (Autotests_ColonyMaker.TryGetFreeRect(6, 3, out cellRect))
                    {
                        cellRect = cellRect.ContractedBy(1);
                        foreach (IntVec3 item2 in cellRect)
                        {
                            Autotests_ColonyMaker.Map.terrainGrid.SetTerrain(item2, TerrainDefOf.Concrete);
                        }
                        GenSpawn.Spawn(PawnGenerator.GeneratePawn(item, null), cellRect.Cells.ElementAt(0), Autotests_ColonyMaker.Map);
                        IntVec3 intVec = cellRect.Cells.ElementAt(1);
                        Pawn    p      = (Pawn)GenSpawn.Spawn(PawnGenerator.GeneratePawn(item, null), intVec, Autotests_ColonyMaker.Map);
                        HealthUtility.DamageUntilDead(p);
                        Corpse       thing        = (Corpse)intVec.GetThingList(Find.VisibleMap).First((Thing t) => t is Corpse);
                        CompRottable compRottable = thing.TryGetComp <CompRottable>();
                        if (compRottable != null)
                        {
                            compRottable.RotProgress += 1200000f;
                        }
                        if (item.RaceProps.leatherDef != null)
                        {
                            GenSpawn.Spawn(item.RaceProps.leatherDef, cellRect.Cells.ElementAt(2), Autotests_ColonyMaker.Map);
                        }
                        if (item.RaceProps.meatDef != null)
                        {
                            GenSpawn.Spawn(item.RaceProps.meatDef, cellRect.Cells.ElementAt(3), Autotests_ColonyMaker.Map);
                        }
                        continue;
                    }
                    return;
                }
            }
            if (flags.Contains(ColonyMakerFlag.ConduitGrid))
            {
                Designator_Build designator_Build = new Designator_Build(ThingDefOf.PowerConduit);
                for (int i = Autotests_ColonyMaker.overRect.minX; i < Autotests_ColonyMaker.overRect.maxX; i++)
                {
                    for (int j = Autotests_ColonyMaker.overRect.minZ; j < Autotests_ColonyMaker.overRect.maxZ; j += 7)
                    {
                        designator_Build.DesignateSingleCell(new IntVec3(i, 0, j));
                    }
                }
                for (int l = Autotests_ColonyMaker.overRect.minZ; l < Autotests_ColonyMaker.overRect.maxZ; l++)
                {
                    for (int m = Autotests_ColonyMaker.overRect.minX; m < Autotests_ColonyMaker.overRect.maxX; m += 7)
                    {
                        designator_Build.DesignateSingleCell(new IntVec3(m, 0, l));
                    }
                }
            }
            if (flags.Contains(ColonyMakerFlag.PowerPlants))
            {
                List <ThingDef> list = new List <ThingDef>();
                list.Add(ThingDefOf.SolarGenerator);
                list.Add(ThingDefOf.WindTurbine);
                List <ThingDef> list2 = list;
                int             num   = 0;
                while (num < 8)
                {
                    if (Autotests_ColonyMaker.TryMakeBuilding(list2[num % list2.Count]) != null)
                    {
                        num++;
                        continue;
                    }
                    Log.Message("Could not make solar generator.");
                    break;
                }
            }
            if (flags.Contains(ColonyMakerFlag.Batteries))
            {
                for (int n = 0; n < 6; n++)
                {
                    Thing thing2 = Autotests_ColonyMaker.TryMakeBuilding(ThingDefOf.Battery);
                    if (thing2 == null)
                    {
                        Log.Message("Could not make battery.");
                        break;
                    }
                    ((Building_Battery)thing2).GetComp <CompPowerBattery>().AddEnergy(999999f);
                }
            }
            if (flags.Contains(ColonyMakerFlag.WorkTables))
            {
                IEnumerable <ThingDef> enumerable = from def in DefDatabase <ThingDef> .AllDefs
                                                    where typeof(Building_WorkTable).IsAssignableFrom(def.thingClass)
                                                    select def;
                foreach (ThingDef item3 in enumerable)
                {
                    Thing thing3 = Autotests_ColonyMaker.TryMakeBuilding(item3);
                    if (thing3 == null)
                    {
                        Log.Message("Could not make worktable: " + item3.defName);
                        break;
                    }
                    Building_WorkTable building_WorkTable = thing3 as Building_WorkTable;
                    if (building_WorkTable != null)
                    {
                        foreach (RecipeDef allRecipe in building_WorkTable.def.AllRecipes)
                        {
                            building_WorkTable.billStack.AddBill(allRecipe.MakeNewBill());
                        }
                    }
                }
            }
            if (flags.Contains(ColonyMakerFlag.AllBuildings))
            {
                IEnumerable <ThingDef> enumerable2 = from def in DefDatabase <ThingDef> .AllDefs
                                                     where def.category == ThingCategory.Building && def.designationCategory != null
                                                     select def;
                foreach (ThingDef item4 in enumerable2)
                {
                    if (item4 != ThingDefOf.PowerConduit)
                    {
                        Thing thing4 = Autotests_ColonyMaker.TryMakeBuilding(item4);
                        if (thing4 == null)
                        {
                            Log.Message("Could not make building: " + item4.defName);
                            break;
                        }
                    }
                }
            }
            CellRect rect = default(CellRect);

            if (!Autotests_ColonyMaker.TryGetFreeRect(33, 33, out rect))
            {
                Log.Error("Could not get wallable rect");
            }
            rect = rect.ContractedBy(1);
            if (flags.Contains(ColonyMakerFlag.AllItems))
            {
                List <ThingDef> itemDefs = (from def in DefDatabase <ThingDef> .AllDefs
                                            where DebugThingPlaceHelper.IsDebugSpawnable(def) && def.category == ThingCategory.Item
                                            select def).ToList();
                Autotests_ColonyMaker.FillWithItems(rect, itemDefs);
            }
            else if (flags.Contains(ColonyMakerFlag.ItemsRawFood))
            {
                List <ThingDef> list3 = new List <ThingDef>();
                list3.Add(ThingDefOf.RawPotatoes);
                Autotests_ColonyMaker.FillWithItems(rect, list3);
            }
            if (flags.Contains(ColonyMakerFlag.Filth))
            {
                foreach (IntVec3 item5 in rect)
                {
                    GenSpawn.Spawn(ThingDefOf.FilthDirt, item5, Autotests_ColonyMaker.Map);
                }
            }
            if (flags.Contains(ColonyMakerFlag.ItemsWall))
            {
                CellRect         cellRect2         = rect.ExpandedBy(1);
                Designator_Build designator_Build2 = new Designator_Build(ThingDefOf.Wall);
                designator_Build2.SetStuffDef(ThingDefOf.WoodLog);
                foreach (IntVec3 edgeCell in cellRect2.EdgeCells)
                {
                    designator_Build2.DesignateSingleCell(edgeCell);
                }
            }
            if (flags.Contains(ColonyMakerFlag.ColonistsMany))
            {
                Autotests_ColonyMaker.MakeColonists(15, Autotests_ColonyMaker.overRect.CenterCell);
            }
            else if (flags.Contains(ColonyMakerFlag.ColonistOne))
            {
                Autotests_ColonyMaker.MakeColonists(1, Autotests_ColonyMaker.overRect.CenterCell);
            }
            if (flags.Contains(ColonyMakerFlag.Fire))
            {
                CellRect cellRect3 = default(CellRect);
                if (!Autotests_ColonyMaker.TryGetFreeRect(30, 30, out cellRect3))
                {
                    Log.Error("Could not get free rect for fire.");
                }
                ThingDef plantTreeOak = ThingDefOf.PlantTreeOak;
                foreach (IntVec3 item6 in cellRect3)
                {
                    GenSpawn.Spawn(plantTreeOak, item6, Autotests_ColonyMaker.Map);
                }
                foreach (IntVec3 item7 in cellRect3)
                {
                    IntVec3 current9 = item7;
                    if (current9.x % 7 == 0 && current9.z % 7 == 0)
                    {
                        GenExplosion.DoExplosion(current9, Find.VisibleMap, 3.9f, DamageDefOf.Flame, null, -1, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false);
                    }
                }
            }
            if (flags.Contains(ColonyMakerFlag.ColonistsHungry))
            {
                Autotests_ColonyMaker.DoToColonists(0.4f, delegate(Pawn col)
                {
                    col.needs.food.CurLevel = Mathf.Max(0f, Rand.Range(-0.05f, 0.05f));
                });
            }
            if (flags.Contains(ColonyMakerFlag.ColonistsTired))
            {
                Autotests_ColonyMaker.DoToColonists(0.4f, delegate(Pawn col)
                {
                    col.needs.rest.CurLevel = Mathf.Max(0f, Rand.Range(-0.05f, 0.05f));
                });
            }
            if (flags.Contains(ColonyMakerFlag.ColonistsInjured))
            {
                Autotests_ColonyMaker.DoToColonists(0.4f, delegate(Pawn col)
                {
                    DamageDef def2 = (from d in DefDatabase <DamageDef> .AllDefs
                                      where d.externalViolence
                                      select d).RandomElement();
                    col.TakeDamage(new DamageInfo(def2, 10, -1f, null, null, null, DamageInfo.SourceCategory.ThingOrUnknown));
                });
            }
            if (flags.Contains(ColonyMakerFlag.ColonistsDiseased))
            {
                foreach (HediffDef item8 in from d in DefDatabase <HediffDef> .AllDefs
                         where d.hediffClass != typeof(Hediff_AddedPart) && (d.HasComp(typeof(HediffComp_Immunizable)) || d.HasComp(typeof(HediffComp_GrowthMode)))
                         select d)
                {
                    Pawn     pawn      = PawnGenerator.GeneratePawn(Faction.OfPlayer.def.basicMemberKind, Faction.OfPlayer);
                    CellRect cellRect4 = default(CellRect);
                    Autotests_ColonyMaker.TryGetFreeRect(1, 1, out cellRect4);
                    GenSpawn.Spawn(pawn, cellRect4.CenterCell, Autotests_ColonyMaker.Map);
                    pawn.health.AddHediff(item8, null, null);
                }
            }
            if (flags.Contains(ColonyMakerFlag.Beds))
            {
                IEnumerable <ThingDef> source = from def in DefDatabase <ThingDef> .AllDefs
                                                where def.thingClass == typeof(Building_Bed)
                                                select def;
                int freeColonistsCount = Autotests_ColonyMaker.Map.mapPawns.FreeColonistsCount;
                int num2 = 0;
                while (num2 < freeColonistsCount)
                {
                    if (Autotests_ColonyMaker.TryMakeBuilding(source.RandomElement()) != null)
                    {
                        num2++;
                        continue;
                    }
                    Log.Message("Could not make beds.");
                    break;
                }
            }
            if (flags.Contains(ColonyMakerFlag.Stockpiles))
            {
                Designator_ZoneAddStockpile_Resources designator_ZoneAddStockpile_Resources = new Designator_ZoneAddStockpile_Resources();
                IEnumerator enumerator11 = Enum.GetValues(typeof(StoragePriority)).GetEnumerator();
                try
                {
                    while (enumerator11.MoveNext())
                    {
                        StoragePriority priority  = (StoragePriority)enumerator11.Current;
                        CellRect        cellRect5 = default(CellRect);
                        Autotests_ColonyMaker.TryGetFreeRect(7, 7, out cellRect5);
                        cellRect5 = cellRect5.ContractedBy(1);
                        designator_ZoneAddStockpile_Resources.DesignateMultiCell(cellRect5.Cells);
                        Zone_Stockpile zone_Stockpile = (Zone_Stockpile)Autotests_ColonyMaker.Map.zoneManager.ZoneAt(cellRect5.CenterCell);
                        zone_Stockpile.settings.Priority = priority;
                    }
                }
                finally
                {
                    IDisposable disposable;
                    if ((disposable = (enumerator11 as IDisposable)) != null)
                    {
                        disposable.Dispose();
                    }
                }
            }
            if (flags.Contains(ColonyMakerFlag.GrowingZones))
            {
                Zone_Growing dummyZone = new Zone_Growing(Autotests_ColonyMaker.Map.zoneManager);
                foreach (ThingDef item9 in from d in DefDatabase <ThingDef> .AllDefs
                         where d.plant != null && GenPlant.CanSowOnGrower(d, dummyZone)
                         select d)
                {
                    CellRect cellRect6 = default(CellRect);
                    if (!Autotests_ColonyMaker.TryGetFreeRect(6, 6, out cellRect6))
                    {
                        Log.Error("Could not get growing zone rect.");
                    }
                    cellRect6 = cellRect6.ContractedBy(1);
                    foreach (IntVec3 item10 in cellRect6)
                    {
                        Autotests_ColonyMaker.Map.terrainGrid.SetTerrain(item10, TerrainDefOf.Soil);
                    }
                    Designator_ZoneAdd_Growing designator_ZoneAdd_Growing = new Designator_ZoneAdd_Growing();
                    designator_ZoneAdd_Growing.DesignateMultiCell(cellRect6.Cells);
                    Zone_Growing zone_Growing = (Zone_Growing)Autotests_ColonyMaker.Map.zoneManager.ZoneAt(cellRect6.CenterCell);
                    zone_Growing.SetPlantDefToGrow(item9);
                }
                dummyZone.Delete();
            }
            Autotests_ColonyMaker.ClearAllHomeArea();
            Autotests_ColonyMaker.FillWithHomeArea(Autotests_ColonyMaker.overRect);
            DebugSettings.godMode            = godMode;
            Thing.allowDestroyNonDestroyable = false;
        }
        public static Building_OutpostCommandConsole GenerateBigRoomCommandRoom(IntVec3 areaSouthWestOrigin, int zoneAbs, int zoneOrd, Rot4 rotation, ref OG_OutpostData outpostData)
        {
            Building_OutpostCommandConsole commandConsole = null;

            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("CarpetDark"), 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 weapon racks.
            Building_Storage rack = OG_Common.TrySpawnThingAt(ThingDefOf.EquipmentRack, ThingDefOf.Steel, rotatedOrigin + new IntVec3(2, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData) as Building_Storage;
            OG_Common.TrySpawnWeaponOnRack(rack);
            rack.GetStoreSettings().filter.SetAllow(ThingCategoryDef.Named("WeaponsMelee"), false);
            rack.GetStoreSettings().Priority = StoragePriority.Critical;
            rack = OG_Common.TrySpawnThingAt(ThingDefOf.EquipmentRack, ThingDefOf.Steel, rotatedOrigin + new IntVec3(1, 0, 3).RotatedBy(rotation), true, new Rot4(Rot4.East.AsInt + rotation.AsInt), ref outpostData) as Building_Storage;
            OG_Common.TrySpawnWeaponOnRack(rack);
            rack.GetStoreSettings().filter.SetAllow(ThingCategoryDef.Named("WeaponsMelee"), false);
            rack.GetStoreSettings().Priority = StoragePriority.Critical;

            // Spawn lamps.
            OG_Common.TrySpawnLampAt(rotatedOrigin + new IntVec3(1, 0, 1).RotatedBy(rotation), Color.white, ref outpostData);
            OG_Common.TrySpawnLampAt(rotatedOrigin + new IntVec3(9, 0, 9).RotatedBy(rotation), Color.white, ref outpostData);

            // Spawn table and stools.
            OG_Common.TrySpawnThingAt(ThingDef.Named("Stool"), ThingDefOf.Steel, rotatedOrigin + new IntVec3(7, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.East.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDef.Named("Stool"), ThingDefOf.Steel, rotatedOrigin + new IntVec3(8, 0, 3).RotatedBy(rotation), true, new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDef.Named("TableShort"), ThingDefOf.Steel, rotatedOrigin + new IntVec3(8, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);

            // Spawn outpost command console, battery and spare parts cabinet.
            OG_Common.TrySpawnThingAt(ThingDefOf.Battery, null, rotatedOrigin + new IntVec3(1, 0, 9).RotatedBy(rotation), true, new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(OG_Util.SparePartsCabinetDef, null, rotatedOrigin + new IntVec3(1, 0, 7).RotatedBy(rotation), true, new Rot4(Rot4.East.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.SpawnResourceAt(ThingDefOf.Component, 10, rotatedOrigin + new IntVec3(1, 0, 7).RotatedBy(rotation), true);
            OG_Common.SpawnResourceAt(ThingDefOf.Component, 10, rotatedOrigin + new IntVec3(1, 0, 6).RotatedBy(rotation), true);
            commandConsole = OG_Common.TrySpawnThingAt(OG_Util.OutpostCommandConsoleDef, null, rotatedOrigin + new IntVec3(3, 0, 9).RotatedBy(rotation), true, new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData) as Building_OutpostCommandConsole;

            // Spawn workbenches.
            OG_Common.TrySpawnThingAt(ThingDef.Named("TableMachining"), null, rotatedOrigin + new IntVec3(7, 0, 9).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.TrySpawnThingAt(ThingDef.Named("ElectricSmithy"), null, rotatedOrigin + new IntVec3(9, 0, 7).RotatedBy(rotation), true, new Rot4(Rot4.East.AsInt + rotation.AsInt), ref outpostData);

            // Spawn heaters and coolers.
            OG_Common.TrySpawnHeaterAt(rotatedOrigin + new IntVec3(1, 0, 4).RotatedBy(rotation), ref outpostData);
            OG_Common.TrySpawnHeaterAt(rotatedOrigin + new IntVec3(4, 0, 1).RotatedBy(rotation), ref outpostData);
            OG_Common.SpawnCoolerAt(rotatedOrigin + new IntVec3(0, 0, 1).RotatedBy(rotation), new Rot4(Rot4.West.AsInt + rotation.AsInt), ref outpostData);
            OG_Common.SpawnCoolerAt(rotatedOrigin + new IntVec3(1, 0, 0).RotatedBy(rotation), new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData);

            // Spawn floor and tactical computer.
            for (int xOffset = 0; xOffset <= 10; xOffset++)
            {
                Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, 5).RotatedBy(rotation), TerrainDef.Named("PavedTile"));
            }
            for (int zOffset = 0; zOffset <= 10; zOffset++)
            {
                Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(5, 0, zOffset).RotatedBy(rotation), TerrainDef.Named("PavedTile"));
            }
            CellRect rect = new CellRect(origin.x + 3, origin.z + 3, 5, 5);
            foreach (IntVec3 cell in rect)
            {
                Find.TerrainGrid.SetTerrain(cell, TerrainDef.Named("PavedTile"));
            }
            foreach (IntVec3 cell in rect.ContractedBy(1))
            {
                Find.TerrainGrid.SetTerrain(cell, TerrainDef.Named("CarpetRed"));
            }
            if (OG_Util.IsModActive("Misc. Incidents"))
            {
                OG_Common.TrySpawnThingAt(ThingDef.Named("TacticalComputer"), null, rotatedOrigin + new IntVec3(5, 0, 5).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData);
            }

            return commandConsole;
        }