예제 #1
0
        private IEnumerable <IntVec3> GetSuggestedRoofCells()
        {
            if (Empty)
            {
                yield break;
            }
            CellRect occupiedRect = OccupiedRect;

            tmpSuggestedRoofCellsVisited.Clear();
            tmpYieldedSuggestedRoofCells.Clear();
            foreach (IntVec3 item in OccupiedRect)
            {
                if (tmpSuggestedRoofCellsVisited.Contains(item) || AnyRoofHolderAt(item))
                {
                    continue;
                }
                tmpSuggestedRoofCells.Clear();
                FloodFill(item, (IntVec3 c) => !AnyRoofHolderAt(c), delegate(IntVec3 c, int dist)
                {
                    tmpSuggestedRoofCellsVisited.Add(c);
                    tmpSuggestedRoofCells.Add(c);
                    return(false);
                });
                bool flag = false;
                for (int k = 0; k < tmpSuggestedRoofCells.Count; k++)
                {
                    if (occupiedRect.IsOnEdge(tmpSuggestedRoofCells[k]))
                    {
                        flag = true;
                        break;
                    }
                }
                if (flag)
                {
                    continue;
                }
                for (int i = 0; i < tmpSuggestedRoofCells.Count; i++)
                {
                    for (int j = 0; j < 9; j++)
                    {
                        IntVec3 intVec = tmpSuggestedRoofCells[i] + GenAdj.AdjacentCellsAndInside[j];
                        if (!tmpYieldedSuggestedRoofCells.Contains(intVec) && occupiedRect.Contains(intVec) && (j == 8 || AnyRoofHolderAt(intVec)))
                        {
                            tmpYieldedSuggestedRoofCells.Add(intVec);
                            yield return(intVec);
                        }
                    }
                }
            }
            tmpSuggestedRoofCellsVisited.Clear();
            tmpYieldedSuggestedRoofCells.Clear();
            bool AnyRoofHolderAt(IntVec3 c)
            {
                return(EdificeAt(c)?.def.holdsRoof ?? false);
            }
        }
예제 #2
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);
            }
예제 #3
0
        private CellRect FindRandomRectToDefend(Map map)
        {
            if (!MapGenerator.TryGetVar("UsedRects", out List <CellRect> usedRects))
            {
                usedRects = null;
            }
            int           rectRadius     = Mathf.Max(Mathf.RoundToInt((float)Mathf.Min(map.Size.x, map.Size.z) * 0.07f), 1);
            TraverseParms traverseParams = TraverseParms.For(TraverseMode.PassDoors);

            if (RCellFinder.TryFindRandomCellNearTheCenterOfTheMapWith(delegate(IntVec3 x)
            {
                if (!map.reachability.CanReachMapEdge(x, traverseParams))
                {
                    return(false);
                }
                CellRect cellRect = CellRect.CenteredOn(x, rectRadius);
                int num = 0;
                foreach (IntVec3 c in cellRect)
                {
                    if (!c.InBounds(map))
                    {
                        return(false);
                    }
                    if (usedRects != null && cellRect.IsOnEdge(c) && usedRects.Any((CellRect y) => y.Contains(c)))
                    {
                        return(false);
                    }
                    if (c.Standable(map) || c.GetPlant(map) != null)
                    {
                        num++;
                    }
                }
                return((float)num / (float)cellRect.Area >= 0.6f);
            }, map, out IntVec3 result))
            {
                return(CellRect.CenteredOn(result, rectRadius));
            }
            if (RCellFinder.TryFindRandomCellNearTheCenterOfTheMapWith((IntVec3 x) => x.Standable(map), map, out result))
            {
                return(CellRect.CenteredOn(result, rectRadius));
            }
            return(CellRect.CenteredOn(CellFinder.RandomCell(map), rectRadius).ClipInsideMap(map));
        }
예제 #4
0
        private void RemoveIslands(Map map)
        {
            CellRect mapRect = CellRect.WholeMap(map);
            int      num     = 0;

            tmpVisited.Clear();
            foreach (IntVec3 allCell in map.AllCells)
            {
                if (tmpVisited.Contains(allCell) || Impassable(allCell))
                {
                    continue;
                }
                int  area            = 0;
                bool touchesMapEdge2 = false;
                map.floodFiller.FloodFill(allCell, (IntVec3 x) => !Impassable(x), delegate(IntVec3 x)
                {
                    tmpVisited.Add(x);
                    area++;
                    if (mapRect.IsOnEdge(x))
                    {
                        touchesMapEdge2 = true;
                    }
                });
                if (touchesMapEdge2)
                {
                    num = Mathf.Max(num, area);
                }
            }
            if (num < 30)
            {
                return;
            }
            tmpVisited.Clear();
            foreach (IntVec3 allCell2 in map.AllCells)
            {
                if (tmpVisited.Contains(allCell2) || Impassable(allCell2))
                {
                    continue;
                }
                tmpIsland.Clear();
                TerrainDef adjacentImpassableTerrain = null;
                bool       touchesMapEdge            = false;
                map.floodFiller.FloodFill(allCell2, delegate(IntVec3 x)
                {
                    if (Impassable(x))
                    {
                        adjacentImpassableTerrain = x.GetTerrain(map);
                        return(false);
                    }
                    return(true);
                }, delegate(IntVec3 x)
                {
                    tmpVisited.Add(x);
                    tmpIsland.Add(x);
                    if (mapRect.IsOnEdge(x))
                    {
                        touchesMapEdge = true;
                    }
                });
                if ((tmpIsland.Count <= num / 20 || (!touchesMapEdge && tmpIsland.Count < num / 2)) && adjacentImpassableTerrain != null)
                {
                    for (int i = 0; i < tmpIsland.Count; i++)
                    {
                        map.terrainGrid.SetTerrain(tmpIsland[i], adjacentImpassableTerrain);
                    }
                }
            }
            bool Impassable(IntVec3 x)
            {
                return(x.GetTerrain(base.map).passability == Traversability.Impassable);
            }
        }
        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);
            }
        }
        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);
            }
        }
예제 #7
0
        private void FloorFillRoom_NewTmp(IntVec3 c, HashSet <IntVec3> walls, HashSet <IntVec3> visited, Sketch sketch, TerrainDef def1, TerrainDef def2, CellRect outerRect, bool singleFloorType)
        {
            if (visited.Contains(c))
            {
                return;
            }
            tmpCells.Clear();
            tmpStack.Clear();
            tmpStack.Push(new Pair <int, int>(c.x, c.z));
            visited.Add(c);
            int num  = c.x;
            int num2 = c.x;
            int num3 = c.z;
            int num4 = c.z;

            while (tmpStack.Count != 0)
            {
                Pair <int, int> pair   = tmpStack.Pop();
                int             first  = pair.First;
                int             second = pair.Second;
                tmpCells.Add(new IntVec3(first, 0, second));
                num  = Mathf.Min(num, first);
                num2 = Mathf.Max(num2, first);
                num3 = Mathf.Min(num3, second);
                num4 = Mathf.Max(num4, second);
                if (first > outerRect.minX && !walls.Contains(new IntVec3(first - 1, 0, second)) && !visited.Contains(new IntVec3(first - 1, 0, second)))
                {
                    visited.Add(new IntVec3(first - 1, 0, second));
                    tmpStack.Push(new Pair <int, int>(first - 1, second));
                }
                if (second > outerRect.minZ && !walls.Contains(new IntVec3(first, 0, second - 1)) && !visited.Contains(new IntVec3(first, 0, second - 1)))
                {
                    visited.Add(new IntVec3(first, 0, second - 1));
                    tmpStack.Push(new Pair <int, int>(first, second - 1));
                }
                if (first < outerRect.maxX && !walls.Contains(new IntVec3(first + 1, 0, second)) && !visited.Contains(new IntVec3(first + 1, 0, second)))
                {
                    visited.Add(new IntVec3(first + 1, 0, second));
                    tmpStack.Push(new Pair <int, int>(first + 1, second));
                }
                if (second < outerRect.maxZ && !walls.Contains(new IntVec3(first, 0, second + 1)) && !visited.Contains(new IntVec3(first, 0, second + 1)))
                {
                    visited.Add(new IntVec3(first, 0, second + 1));
                    tmpStack.Push(new Pair <int, int>(first, second + 1));
                }
            }
            for (int i = 0; i < tmpCells.Count; i++)
            {
                if (outerRect.IsOnEdge(tmpCells[i]))
                {
                    return;
                }
            }
            CellRect cellRect = CellRect.FromLimits(num, num3, num2, num4);

            bool[,] array = AbstractShapeGenerator.Generate(cellRect.Width, cellRect.Height, horizontalSymmetry: true, verticalSymmetry: true);
            for (int j = 0; j < tmpCells.Count; j++)
            {
                IntVec3 pos = tmpCells[j];
                if (!sketch.ThingsAt(pos).Any((SketchThing x) => x.def.passability == Traversability.Impassable && x.def.Fillage == FillCategory.Full))
                {
                    if (array[pos.x - cellRect.minX, pos.z - cellRect.minZ] || singleFloorType)
                    {
                        sketch.AddTerrain(def1, pos, wipeIfCollides: false);
                    }
                    else
                    {
                        sketch.AddTerrain(def2, pos, wipeIfCollides: false);
                    }
                }
            }
        }
        private static void GenerateInt(bool[,] grid, bool horizontalSymmetry, bool verticalSymmetry, bool allowEnclosedFalses, bool preferOutlines, float wipedCircleRadiusPct)
        {
            int length  = grid.GetLength(0);
            int length2 = grid.GetLength(1);

            for (int i = 0; i < length; i++)
            {
                for (int j = 0; j < length2; j++)
                {
                    grid[i, j] = false;
                }
            }
            int num;
            int num2;
            int num3;
            int num4;
            int num5;
            int num6;

            if (preferOutlines)
            {
                num  = 0;
                num2 = 2;
                num3 = 0;
                num4 = 4;
                num5 = 2;
                num6 = ((length < 16 && length2 < 16) ? ((length < 13 && length2 < 13) ? ((length < 12 && length2 < 12) ? 1 : 2) : 3) : 4);
            }
            else
            {
                num  = Rand.RangeInclusive(1, 3);
                num2 = 0;
                num3 = Rand.RangeInclusive(1, 3);
                num6 = 0;
                num4 = 0;
                num5 = 0;
            }
            float num7  = 0.3f;
            float num8  = 0.3f;
            float num9  = 0.7f;
            float num10 = 0.7f;

            for (int k = 0; k < num; k++)
            {
                foreach (IntVec3 item in CellRect.CenteredOn(new IntVec3(Rand.RangeInclusive(0, length - 1), 0, Rand.RangeInclusive(0, length2 - 1)), Mathf.Max(Mathf.RoundToInt((float)Rand.RangeInclusive(1, length) * num7), 1), Mathf.Max(Mathf.RoundToInt((float)Rand.RangeInclusive(1, length2) * num7), 1)))
                {
                    if (item.x >= 0 && item.x < length && item.z >= 0 && item.z < length2)
                    {
                        grid[item.x, item.z] = true;
                    }
                }
            }
            for (int l = 0; l < num2; l++)
            {
                CellRect cellRect = CellRect.CenteredOn(new IntVec3(Rand.RangeInclusive(0, length - 1), 0, Rand.RangeInclusive(0, length2 - 1)), Mathf.Max(Mathf.RoundToInt((float)Rand.RangeInclusive(1, length) * num8), 1), Mathf.Max(Mathf.RoundToInt((float)Rand.RangeInclusive(1, length2) * num8), 1));
                Rot4     random   = Rot4.Random;
                foreach (IntVec3 edgeCell in cellRect.EdgeCells)
                {
                    if ((allowEnclosedFalses || !cellRect.IsOnEdge(edgeCell, random) || cellRect.IsOnEdge(edgeCell, random.Rotated(RotationDirection.Clockwise)) || cellRect.IsOnEdge(edgeCell, random.Rotated(RotationDirection.Counterclockwise))) && edgeCell.x >= 0 && edgeCell.x < length && edgeCell.z >= 0 && edgeCell.z < length2)
                    {
                        grid[edgeCell.x, edgeCell.z] = true;
                    }
                }
            }
            for (int m = 0; m < num3; m++)
            {
                IntVec2 intVec = new IntVec2(Rand.RangeInclusive(0, length - 1), Rand.RangeInclusive(0, length2 - 1));
                foreach (IntVec3 item2 in GenRadial.RadialPatternInRadius(Mathf.Max(Mathf.RoundToInt((float)(Mathf.Max(length, length2) / 2) * num9), 1)))
                {
                    IntVec3 current3 = item2;
                    current3.x += intVec.x;
                    current3.z += intVec.z;
                    if (current3.x >= 0 && current3.x < length && current3.z >= 0 && current3.z < length2)
                    {
                        grid[current3.x, current3.z] = true;
                    }
                }
            }
            for (int n = 0; n < num6; n++)
            {
                float   num11   = Rand.Range(0.7f, 1f);
                IntVec2 intVec2 = new IntVec2(Rand.RangeInclusive(0, length - 1), Rand.RangeInclusive(0, length2 - 1));
                int     num12   = Mathf.Max(Mathf.RoundToInt((float)(Mathf.Max(length, length2) / 2) * num10 * num11), 1);
                bool    @bool   = Rand.Bool;
                tmpCircleCells.Clear();
                tmpCircleCells.AddRange(GenRadial.RadialPatternInRadius(num12));
                foreach (IntVec3 tmpCircleCell in tmpCircleCells)
                {
                    if ((allowEnclosedFalses || ((!@bool || tmpCircleCell.x >= 0) && (@bool || tmpCircleCell.z >= 0))) && (!tmpCircleCells.Contains(new IntVec3(tmpCircleCell.x - 1, 0, tmpCircleCell.z - 1)) || !tmpCircleCells.Contains(new IntVec3(tmpCircleCell.x - 1, 0, tmpCircleCell.z)) || !tmpCircleCells.Contains(new IntVec3(tmpCircleCell.x - 1, 0, tmpCircleCell.z + 1)) || !tmpCircleCells.Contains(new IntVec3(tmpCircleCell.x, 0, tmpCircleCell.z - 1)) || !tmpCircleCells.Contains(new IntVec3(tmpCircleCell.x, 0, tmpCircleCell.z)) || !tmpCircleCells.Contains(new IntVec3(tmpCircleCell.x, 0, tmpCircleCell.z + 1)) || !tmpCircleCells.Contains(new IntVec3(tmpCircleCell.x + 1, 0, tmpCircleCell.z - 1)) || !tmpCircleCells.Contains(new IntVec3(tmpCircleCell.x + 1, 0, tmpCircleCell.z)) || !tmpCircleCells.Contains(new IntVec3(tmpCircleCell.x + 1, 0, tmpCircleCell.z + 1))))
                    {
                        IntVec3 intVec3 = tmpCircleCell;
                        intVec3.x += intVec2.x;
                        intVec3.z += intVec2.z;
                        if (intVec3.x >= 0 && intVec3.x < length && intVec3.z >= 0 && intVec3.z < length2)
                        {
                            grid[intVec3.x, intVec3.z] = true;
                        }
                    }
                }
            }
            for (int num13 = 0; num13 < num4; num13++)
            {
                bool bool2 = Rand.Bool;
                foreach (IntVec3 item3 in CellRect.CenteredOn(new IntVec3(Rand.RangeInclusive(0, length - 1), 0, Rand.RangeInclusive(0, length2 - 1)), (!bool2) ? 1 : Mathf.RoundToInt(Rand.RangeInclusive(1, length)), bool2 ? 1 : Mathf.RoundToInt(Rand.RangeInclusive(1, length2))))
                {
                    if (item3.x >= 0 && item3.x < length && item3.z >= 0 && item3.z < length2)
                    {
                        grid[item3.x, item3.z] = true;
                    }
                }
            }
            for (int num14 = 0; num14 < num5; num14++)
            {
                bool     bool3     = Rand.Bool;
                CellRect cellRect2 = CellRect.CenteredOn(new IntVec3(Rand.RangeInclusive(0, length - 1), 0, Rand.RangeInclusive(0, length2 - 1)), Mathf.RoundToInt(Rand.RangeInclusive(1, length)), 1);
                foreach (IntVec3 item4 in cellRect2)
                {
                    int num15 = item4.x - cellRect2.minX - cellRect2.Width / 2;
                    if (bool3)
                    {
                        num15 = -num15;
                    }
                    IntVec3 intVec4 = item4;
                    intVec4.z += num15;
                    if (intVec4.x >= 0 && intVec4.x < length && intVec4.z >= 0 && intVec4.z < length2)
                    {
                        grid[intVec4.x, intVec4.z] = true;
                    }
                }
            }
            if (preferOutlines)
            {
                for (int num16 = 0; num16 < grid.GetLength(0) - 1; num16++)
                {
                    for (int num17 = 0; num17 < grid.GetLength(1) - 1; num17++)
                    {
                        if (grid[num16, num17] && grid[num16 + 1, num17] && grid[num16, num17 + 1] && grid[num16 + 1, num17 + 1])
                        {
                            switch (Rand.Range(0, 4))
                            {
                            case 0:
                                grid[num16, num17] = false;
                                break;

                            case 1:
                                grid[num16 + 1, num17] = false;
                                break;

                            case 2:
                                grid[num16, num17 + 1] = false;
                                break;

                            default:
                                grid[num16 + 1, num17 + 1] = false;
                                break;
                            }
                        }
                    }
                }
            }
            if (wipedCircleRadiusPct > 0f)
            {
                IntVec2 intVec5 = new IntVec2(length / 2, length2 / 2);
                foreach (IntVec3 item5 in GenRadial.RadialPatternInRadius(Mathf.FloorToInt((float)Mathf.Min(length, length2) * wipedCircleRadiusPct)))
                {
                    IntVec3 current7 = item5;
                    current7.x += intVec5.x;
                    current7.z += intVec5.z;
                    if (current7.x >= 0 && current7.x < length && current7.z >= 0 && current7.z < length2)
                    {
                        grid[current7.x, current7.z] = false;
                    }
                }
            }
            if (horizontalSymmetry)
            {
                for (int num18 = grid.GetLength(0) / 2; num18 < grid.GetLength(0); num18++)
                {
                    for (int num19 = 0; num19 < grid.GetLength(1); num19++)
                    {
                        grid[num18, num19] = grid[grid.GetLength(0) - num18 - 1, num19];
                    }
                }
            }
            if (!verticalSymmetry)
            {
                return;
            }
            for (int num20 = 0; num20 < grid.GetLength(0); num20++)
            {
                for (int num21 = grid.GetLength(1) / 2; num21 < grid.GetLength(1); num21++)
                {
                    grid[num20, num21] = grid[num20, grid.GetLength(1) - num21 - 1];
                }
            }
        }