protected override void ResolveInt(ResolveParams parms)
        {
            CellRect outerRect    = parms.rect ?? parms.sketch.OccupiedRect;
            bool     allowWood    = parms.allowWood ?? true;
            ThingDef stuff        = GenStuff.RandomStuffInexpensiveFor(parms.wallEdgeThing, null, (ThingDef x) => SketchGenUtility.IsStuffAllowed(x, allowWood, parms.useOnlyStonesAvailableOnMap, allowFlammableWalls: true, parms.wallEdgeThing));
            Rot4     rot          = ((parms.wallEdgeThing.size.z > parms.wallEdgeThing.size.x) ? Rot4.North : Rot4.East);
            Rot4     rot2         = ((parms.wallEdgeThing.size.z > parms.wallEdgeThing.size.x) ? Rot4.East : Rot4.North);
            CellRect cellRect     = GenAdj.OccupiedRect(default(IntVec3), rot, parms.wallEdgeThing.size);
            CellRect cellRect2    = GenAdj.OccupiedRect(default(IntVec3), rot2, parms.wallEdgeThing.size);
            bool     requireFloor = parms.requireFloor ?? false;

            processed.Clear();
            try
            {
                foreach (IntVec3 item in outerRect.Cells.InRandomOrder())
                {
                    CellRect cellRect3 = SketchGenUtility.FindBiggestRectAt(item, outerRect, parms.sketch, processed, (IntVec3 x) => !parms.sketch.ThingsAt(x).Any() && (!requireFloor || (parms.sketch.TerrainAt(x) != null && parms.sketch.TerrainAt(x).layerable)));
                    if (cellRect3.Width < cellRect.Width || cellRect3.Height < cellRect.Height || cellRect3.Width < cellRect2.Width || cellRect3.Height < cellRect2.Height || !Rand.Chance(0.2f))
                    {
                        continue;
                    }
                    CellRect rect  = new CellRect(cellRect3.minX, cellRect3.CenterCell.z - cellRect.Height / 2, cellRect.Width, cellRect.Height);
                    CellRect rect2 = new CellRect(cellRect3.maxX - (cellRect.Width - 1), cellRect3.CenterCell.z - cellRect.Height / 2, cellRect.Width, cellRect.Height);
                    CellRect rect3 = new CellRect(cellRect3.CenterCell.x - cellRect2.Width / 2, cellRect3.maxZ - (cellRect2.Height - 1), cellRect2.Width, cellRect2.Height);
                    CellRect rect4 = new CellRect(cellRect3.CenterCell.x - cellRect2.Width / 2, cellRect3.minZ, cellRect2.Width, cellRect2.Height);
                    if ((Rand.Bool && CanPlaceAt(rect, Rot4.West, parms.sketch)) || CanPlaceAt(rect2, Rot4.East, parms.sketch))
                    {
                        if (Rand.Bool && CanPlaceAt(rect, Rot4.West, parms.sketch))
                        {
                            parms.sketch.AddThing(parms.wallEdgeThing, new IntVec3(rect.minX - cellRect.minX, 0, rect.minZ - cellRect.minZ), rot, stuff, 1, null, null, wipeIfCollides: false);
                        }
                        else if (CanPlaceAt(rect2, Rot4.East, parms.sketch))
                        {
                            parms.sketch.AddThing(parms.wallEdgeThing, new IntVec3(rect2.minX - cellRect.minX, 0, rect2.minZ - cellRect.minZ), rot, stuff, 1, null, null, wipeIfCollides: false);
                        }
                    }
                    else if (Rand.Bool && CanPlaceAt(rect3, Rot4.North, parms.sketch))
                    {
                        parms.sketch.AddThing(parms.wallEdgeThing, new IntVec3(rect3.minX - cellRect2.minX, 0, rect3.minZ - cellRect2.minZ), rot2, stuff, 1, null, null, wipeIfCollides: false);
                    }
                    else if (CanPlaceAt(rect4, Rot4.South, parms.sketch))
                    {
                        parms.sketch.AddThing(parms.wallEdgeThing, new IntVec3(rect4.minX - cellRect2.minX, 0, rect4.minZ - cellRect2.minZ), rot2, stuff, 1, null, null, wipeIfCollides: false);
                    }
                }
            }
            finally
            {
                processed.Clear();
            }
        }
Exemplo n.º 2
0
        protected override void ResolveInt(ResolveParams parms)
        {
            CellRect          outerRect = parms.rect ?? parms.sketch.OccupiedRect;
            HashSet <IntVec3> processed = new HashSet <IntVec3>();

            foreach (IntVec3 c in outerRect.Cells.InRandomOrder())
            {
                CellRect cellRect = SketchGenUtility.FindBiggestRectAt(c, outerRect, parms.sketch, processed, (IntVec3 x) => !parms.sketch.ThingsAt(x).Any() && parms.sketch.AnyTerrainAt(c));
                if (cellRect.Width >= 7 && cellRect.Height >= 7)
                {
                    int           newX   = Rand.RangeInclusive(5, cellRect.Width - 2);
                    int           newZ   = Rand.RangeInclusive(5, cellRect.Height - 2);
                    Sketch        sketch = new Sketch();
                    ResolveParams parms2 = parms;
                    parms2.sketch       = sketch;
                    parms2.monumentSize = new IntVec2(newX, newZ);
                    parms2.rect         = null;
                    SketchResolverDefOf.Monument.Resolve(parms2);
                    parms.sketch.MergeAt(sketch, cellRect.CenterCell, Sketch.SpawnPosType.OccupiedCenter, wipeIfCollides: false);
                }
            }
        }
        protected override void ResolveInt(ResolveParams parms)
        {
            CellRect outerRect    = parms.rect ?? parms.sketch.OccupiedRect;
            bool     allowWood    = parms.allowWood ?? true;
            ThingDef stuff        = GenStuff.RandomStuffInexpensiveFor(parms.thingCentral, null, (ThingDef x) => SketchGenUtility.IsStuffAllowed(x, allowWood, parms.useOnlyStonesAvailableOnMap, allowFlammableWalls: true, parms.thingCentral));
            bool     requireFloor = parms.requireFloor ?? false;

            processed.Clear();
            try
            {
                foreach (IntVec3 item in outerRect.Cells.InRandomOrder())
                {
                    CellRect cellRect = SketchGenUtility.FindBiggestRectAt(item, outerRect, parms.sketch, processed, (IntVec3 x) => !parms.sketch.ThingsAt(x).Any() && (!requireFloor || (parms.sketch.TerrainAt(x) != null && parms.sketch.TerrainAt(x).layerable)));
                    if (cellRect.Width >= parms.thingCentral.size.x + 2 && cellRect.Height >= parms.thingCentral.size.z + 2 && Rand.Chance(0.4f))
                    {
                        parms.sketch.AddThing(parms.thingCentral, new IntVec3(cellRect.CenterCell.x - parms.thingCentral.size.x / 2, 0, cellRect.CenterCell.z - parms.thingCentral.size.z / 2), Rot4.North, stuff, 1, null, null, wipeIfCollides: false);
                    }
                }
            }
            finally
            {
                processed.Clear();
            }
        }
Exemplo n.º 4
0
        protected override void ResolveInt(ResolveParams parms)
        {
            CellRect outerRect = parms.rect ?? parms.sketch.OccupiedRect;
            bool     allowWood = parms.allowWood ?? true;
            bool     flag      = parms.requireFloor ?? false;

            rects.Clear();
            processed.Clear();
            foreach (IntVec3 item2 in outerRect.Cells.InRandomOrder())
            {
                CellRect item = SketchGenUtility.FindBiggestRectAt(item2, outerRect, parms.sketch, processed, (IntVec3 x) => !AnyColumnBlockerAt(x, parms.sketch));
                if (!item.IsEmpty)
                {
                    rects.Add(item);
                }
            }
            ThingDef stuff = GenStuff.RandomStuffInexpensiveFor(ThingDefOf.Column, null, (ThingDef x) => SketchGenUtility.IsStuffAllowed(x, allowWood, parms.useOnlyStonesAvailableOnMap, allowFlammableWalls: true, ThingDefOf.Column));

            for (int i = 0; i < rects.Count; i++)
            {
                if (rects[i].Width < 3 || rects[i].Height < 3 || !Rand.Chance(0.8f))
                {
                    continue;
                }
                CellRect cellRect = rects[i].ContractedBy(1);
                Sketch   sketch   = new Sketch();
                if (Rand.Bool)
                {
                    int newZ = Rand.RangeInclusive(cellRect.minZ, cellRect.CenterCell.z);
                    int num  = ((cellRect.Width >= 4) ? Rand.Element(2, 3) : 2);
                    for (int j = cellRect.minX; j <= cellRect.maxX; j += num)
                    {
                        if (!flag || parms.sketch.AnyTerrainAt(new IntVec3(j, 0, newZ)))
                        {
                            sketch.AddThing(ThingDefOf.Column, new IntVec3(j, 0, newZ), Rot4.North, stuff);
                        }
                    }
                    ResolveParams parms2 = parms;
                    parms2.sketch                 = sketch;
                    parms2.symmetryOrigin         = rects[i].minZ + rects[i].Height / 2;
                    parms2.symmetryOriginIncluded = rects[i].Height % 2 == 1;
                    SketchResolverDefOf.Symmetry.Resolve(parms2);
                }
                else
                {
                    int newX = Rand.RangeInclusive(cellRect.minX, cellRect.CenterCell.x);
                    int num2 = ((cellRect.Height >= 4) ? Rand.Element(2, 3) : 2);
                    for (int k = cellRect.minZ; k <= cellRect.maxZ; k += num2)
                    {
                        if (!flag || parms.sketch.AnyTerrainAt(new IntVec3(newX, 0, k)))
                        {
                            sketch.AddThing(ThingDefOf.Column, new IntVec3(newX, 0, k), Rot4.North, stuff);
                        }
                    }
                    ResolveParams parms3 = parms;
                    parms3.sketch                 = sketch;
                    parms3.symmetryOrigin         = rects[i].minX + rects[i].Width / 2;
                    parms3.symmetryOriginIncluded = rects[i].Width % 2 == 1;
                    SketchResolverDefOf.Symmetry.Resolve(parms3);
                }
                parms.sketch.Merge(sketch, wipeIfCollides: false);
            }
            rects.Clear();
            processed.Clear();
        }