示例#1
0
        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)
                .ClearThingsInBounds();

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

            var sandbagStuff = GenCity.RandomStuff(ThingDefOf.Sandbags, map);

            s.MoveWithBounds(0, -2)
            .Border(ThingDefOf.Sandbags, sandbagStuff, mask: IsValidTile);
            s.MoveWithBounds(0, 2)
            .Border(ThingDefOf.Sandbags, sandbagStuff, mask: IsValidTile);

            var sentries = sentryRange.RandomInRange;

            for (var i = 0; i < sentries; i++)
            {
                var point = s.MoveRand().pos + IntVec3.North * 3;
                GenCity.SpawnInhabitant(point, map, new LordJob_DefendBase(map.ParentFaction, point));
            }
        }
        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);
        }