protected override void ScatterAt(IntVec3 pos, Map map, GenStepParams parms, int count)
        {
            var height  = heightRange.RandomInRange;
            var spacing = spacingRange.RandomInRange;

            var s = new Stencil(map).MoveTo(pos);

            s = s.Bound(s.MinX, 0, s.MaxX, height)
                // .Border(ThingDefOf.Wall, GenCity.RandomWallStuff(map))
                .FillRoof(RoofDefOf.RoofConstructed);

            // s.Expand(1)
            //     .FillTerrain(GenCity.RandomFloor(map), IsValidTile);

            for (var i = s.MinX + spacingRange.RandomInRange; i <= s.MaxX; i += spacing)
            {
                for (var j = s.MinZ + spacingRange.RandomInRange; j <= s.MaxZ; j += spacing)
                {
                    var point = s.pos + new IntVec3(i, 0, j);
                    if (IsValidTile(map, point))
                    {
                        s.MoveTo(point)
                        .Spawn(ThingDefOf.Column, GenCity.RandomStuff(ThingDefOf.Column, map));
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public override void Decorate(Stencil s)
        {
            s.Bound(s.RandInclusive(s.MinX, s.MinX / 2) - 1, s.RandInclusive(s.MinZ, s.MinZ / 2) - 1, s.RandInclusive(s.MaxX / 2, s.MaxX) + 1, s.RandInclusive(s.MaxZ / 2, s.MaxZ) + 1)
            .FillTerrain(GenCity.RandomFloor(s.map, true));

            var def   = options.RandomElement();
            var thing = s.Spawn(def, GenCity.RandomStuff(def, s.map));

            if (chairDensity > 0)
            {
                var chairDef   = chairOptions.RandomElement();
                var chairStuff = GenCity.RandomStuff(chairDef, s.map);
                var sThing     = s.BoundTo(thing.OccupiedRect());
                for (var dir = 0; dir < 4; dir++)
                {
                    var sDir = sThing.Rotate(dir);
                    for (var x = sDir.MinX; x <= sDir.MaxX; x++)
                    {
                        if (s.Chance(chairDensity))
                        {
                            SpawnChair(sDir.Move(x, sDir.MinZ - 1), chairDef, chairStuff);
                        }
                    }
                }
            }
            else if (thing.def.hasInteractionCell && chairOptions.Count > 0)
            {
                var chairDef   = chairOptions.RandomElement();
                var chairStuff = GenCity.RandomStuff(chairDef, s.map);
                SpawnChair(s.MoveTo(thing.InteractionCell), chairDef, chairStuff);
            }
        }
        protected override void ScatterAt(IntVec3 pos, Map map, GenStepParams parms, int count)
        {
            var s = new Stencil(map).MoveTo(pos);

            s = s.Bound(s.MinX, 0, s.MaxX, 0);

            var spacing = spacingRange.RandomInRange;

            for (var i = s.MinX + spacingRange.RandomInRange; i <= s.MaxX; i += spacing)
            {
                var point = s.MoveRand().pos + IntVec3.North * 3;
                if (IsValidTile(map, point))
                {
                    var trap = s.MoveTo(point)
                               .Spawn(jitterRange.RandomInRange * Rand.Sign, jitterRange.RandomInRange * Rand.Sign,
                                      DefDatabase <ThingDef> .GetNamed("TrapIED_HighExplosive"));
                    trap.SetFactionDirect(map.ParentFaction);
                }
            }
        }
Ejemplo n.º 4
0
        public override void Generate(Map map, GenStepParams parms)
        {
            var roadTerrain     = roadTerrains.RandomElement();
            var divTerrain      = divTerrains.RandomElement();
            var sidewalkTerrain = sidewalkTerrains.RandomElement();

            var radius = centerRadius.RandomInRange;

            var s = new Stencil(map);

            s = s.MoveTo(s.Expand(-radius - 2).bounds.RandomCell);

            s.Bound(-radius, -radius, radius, radius)
            .ClearThingsInBounds()
            .FillTerrain(sidewalkTerrains.RandomElement());

            s.FillTerrain(-2, -2, 2, 2, roadTerrain);

            for (var dir = 0; dir < 4; dir++)
            {
                GenMainRoad(s.Rotate(dir).Move(0, 3), roadTerrain, divTerrain, sidewalkTerrain);
            }
        }
        protected override void ScatterAt(IntVec3 pos, Map map, GenStepParams parms, int count)
        {
            var tier = tierRange.RandomInRange;

            pos.z = (int)(map.Size.z * (1 - Rand.Value * mapDensity));  /////////

            var s = new Stencil(map).MoveTo(pos);

            // if (IsValidWallTile(map, s.pos)) {
            //     s.Spawn(ThingDefOf.Door, wallStuff);
            // }
            s = s.Bound(s.MinX, 0, s.MaxX, 0);

            // s.Fill(ThingDefOf.Wall, wallStuff, IsValidWallTile);

            s.Expand(0, -1, 0, -3)
            .ClearThingsInBounds();

            s.MoveWithBounds(0, -3)
            .Fill(ThingDefOf.Barricade, GenCity.RandomStuff(ThingDefOf.Barricade, map), IsValidTile);

            var sentries = sentryRange.RandomInRange;

            for (var i = 0; i < sentries; i++)
            {
                var point = s.MoveRand().pos + IntVec3.South;
                GenCity.SpawnInhabitant(point, map, new LordJob_DefendBase(map.ParentFaction, point));
            }

            if (Config_Cities.Instance.enableMortars)
            {
                var mortars = tierRange.RandomInRange * 1; /**/
                for (var i = 0; i < mortars; i++)
                {
                    var attempts = 10;
                    do
                    {
                        var point   = s.Expand(-2, 0, -2, 0).MoveRand().pos + IntVec3.North * (tier + 2);
                        var sMortar = s.MoveTo(point).ExpandRegion(IsValidEmplacementTile, 25).Center();
                        if (s.Area >= 9)
                        {
                            var mortar = sMortar.ClearThingsInBounds()
                                         .FillTerrain(TerrainDefOf.Concrete)
                                         .Back()
                                         .Spawn(ThingDefOf.Turret_Mortar, GenCity.RandomStuff(ThingDefOf.Turret_Mortar, map));
                            mortar.SetFactionDirect(map.ParentFaction);

                            var ammoPoint = point + IntVec3.North * 2;
                            var ammo      = s.MoveTo(ammoPoint).Spawn(0, 0, ThingDefOf.Shell_HighExplosive);
                            ammo.stackCount = ammoRange.RandomInRange;
                            ammo.SetOwnedByCity(true, s.map);
                            GenCity.SpawnInhabitant(ammoPoint, map, new LordJob_ManTurrets());

                            break;
                        }
                    } while (attempts-- > 0);
                }
            }

            s.Bound(s.MinX, 0, s.MaxX, 0)
            .Expand(3).FillTerrain(TerrainDefOf.Concrete, IsValidTile);

            // s.Bound(s.MinX, 0, s.MaxX, -3)
            //     .FillRoof(RoofDefOf.RoofConstructed, IsValidTile);
        }