Пример #1
0
            public virtual void Generate(Stencil s)
            {
                var weapon = s.Spawn(weaponDef, weaponDef.MadeFromStuff ? ThingDefOf.Steel : null);

                weapon.SetFactionDirect(s.map.ParentFaction);
                if (ammoDef != null)
                {
                    var ammo = s.RotateRand().Spawn(s.RandInclusive(-1, 1), s.RandInclusive(2, 3), ammoDef);
                    ammo.stackCount = ammoCount.RandomInRange;
                    ammo.SetOwnedByCity(true, s.map);
                }

                if (roofed)
                {
                    var stuff = GenCity.RandomWallStuff(s.map);
                    s.Spawn(s.MinX, s.MinZ, ThingDefOf.Wall, stuff);
                    s.Spawn(s.MaxX, s.MinZ, ThingDefOf.Wall, stuff);
                    s.Spawn(s.MinX, s.MaxZ, ThingDefOf.Wall, stuff);
                    s.Spawn(s.MaxX, s.MaxZ, ThingDefOf.Wall, stuff);
                    s.FillRoof(RoofDefOf.RoofConstructed);
                }

                if (manned)
                {
                    GenCity.SpawnInhabitant(s.pos, s.map, new LordJob_ManTurrets());
                }
            }
        public override void Decorate(Stencil s)
        {
            var sBed  = s.Expand(-1);
            var thing = bedOptions.RandomElement();
            var stuff = GenCity.RandomStuff(thing, s.map);
            var bed   = (Building_Bed)sBed.Spawn(sBed.RandX, sBed.RandZ, thing, stuff);

            bed.SetFactionDirect(s.map.ParentFaction);
            bed.ForPrisoners = true;
            if (s.Chance(prisonerChance))
            {
                var pawn = GenCity.SpawnInhabitant(s.pos, s.map, kind: PawnKindDefOf.Slave);
                if (pawn.guest == null)
                {
                    pawn.guest = new Pawn_GuestTracker(pawn);
                }
                if (pawn.skills == null)
                {
                    pawn.skills = new Pawn_SkillTracker(pawn);
                }
                if (pawn.Faction.HostileTo(s.map.ParentFaction))
                {
                    pawn.equipment.DestroyAllEquipment();
                    pawn.guest.SetGuestStatus(s.map.ParentFaction, GuestStatus.Prisoner);
                }
            }
        }
Пример #3
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));
            }
        }
Пример #4
0
 private void SpawnChair(Stencil s, ThingDef thing, ThingDef stuff)
 {
     s.Spawn(thing, stuff);
     if (s.Chance(chairPawnChance))
     {
         GenCity.SpawnInhabitant(s.pos, s.map);
     }
 }
 void SpawnChair(Stencil s, ThingDef thing, ThingDef stuff)
 {
     if (s.Check(IsValidChairTile))
     {
         s.Spawn(thing, stuff);
     }
     if (s.Chance(chairPawnChance) && s.IsInMap())
     {
         GenCity.SpawnInhabitant(s.pos, s.map);
     }
 }
Пример #6
0
        public override void GenerateRect(Stencil s)
        {
            s.FillTerrain(GenCity.RandomFloor(s.map));
            var pawn = (Pawn)null;

            if (!s.map.ParentFaction.HostileTo(Faction.OfPlayer))
            {
                pawn = GenCity.SpawnInhabitant(s.Coords(s.RandX / 2, s.RandZ / 2), s.map);
                var traderKind = DefDatabase <TraderKindDef> .AllDefs.RandomElement();

                pawn.mindState.wantsToTradeWithColony = true;
                PawnComponentsUtility.AddAndRemoveDynamicComponents(pawn, true);
                pawn.trader.traderKind = traderKind;
                pawn.inventory.DestroyAll();
                var parms = new ThingSetMakerParams {
                    traderDef     = traderKind,
                    tile          = s.map.Tile,
                    makingFaction = s.map.ParentFaction,
                };
                foreach (var item in ThingSetMakerDefOf.TraderStock.root.Generate(parms))
                {
                    if (!(item is Pawn) && !pawn.inventory.innerContainer.TryAdd(item))
                    {
                        item.Destroy();
                    }
                }

                PawnInventoryGenerator.GiveRandomFood(pawn);
            }

            for (var dir = 0; dir < 4; dir++)
            {
                if (s.Chance(standChance))
                {
                    var sStand = s.Rotate(dir).Move(Mathf.RoundToInt(s.RandX / 2F), s.MaxZ - s.RandInclusive(0, 2)).Bound(-1, 0, 1, 0);
                    sStand.FillTerrain(GenCity.RandomFloor(s.map, true));
                    var wallStuff = GenCity.RandomWallStuff(s.map);
                    sStand.Spawn(sStand.MinX - 1, 0, ThingDefOf.Wall, wallStuff);
                    sStand.Spawn(sStand.MaxX + 1, 0, ThingDefOf.Wall, wallStuff);
                    sStand.Expand(1).FillRoof(RoofDefOf.RoofConstructed);
                    // if (pawn != null) {
                    //     var itemPos = sStand.Coords(sStand.RandX, sStand.RandZ);
                    //     var item = pawn.inventory.innerContainer.FirstOrDefault();
                    //     if (item != null) {
                    //         pawn.inventory.innerContainer.TryDrop(item, itemPos, s.map, ThingPlaceMode.Direct, out var result);
                    //         item.SetOwnedByCity(true, s.map);
                    //     }
                    // }
                }
            }
        }
        public override void Generate(Map map, GenStepParams parms)
        {
            base.Generate(map, parms);

            var faction = GenCity.RandomCityFaction(f => f.PlayerGoodwill > -50);

            for (var i = 0; i < innocentPawns; i++)
            {
                var pawn = GenCity.SpawnInhabitant(CellRect.WholeMap(map).RandomCell, map, new LordJob_ExitMapBest());
                pawn.SetFactionDirect(faction);
            }

            // map.weatherManager.curWeather = DefDatabase<WeatherDef>.GetNamed("Fog");
        }
Пример #8
0
        public override void Decorate(Stencil s)
        {
            var stuff    = GenCity.RandomStuff(ThingDefOf.Bed, s.map);
            var sDresser = s.Rotate(s.RandInclusive(0, 1) * 2);

            sDresser.Spawn(s.RandInclusive(sDresser.MinX + 1, sDresser.MaxX - 1), sDresser.MinZ + 1, DefDatabase <ThingDef> .GetNamed("Dresser"), stuff);
            var bedX = s.RandX;

            s.Spawn(bedX, s.MinZ, DefDatabase <ThingDef> .GetNamed("EndTable"), stuff);
            var bed = (Building_Bed)s.Spawn(bedX, s.MinZ + 1, ThingDefOf.Bed, stuff);

            bed.SetFactionDirect(s.map.ParentFaction);
            var pawn = GenCity.SpawnInhabitant(s.Chance(pawnInBedroomChance) ? s.pos : s.MapBounds.RandomCell, s.map, null, randomWorkSpot: true);

            bed.CompAssignableToPawn.TryAssignPawn(pawn);
        }
Пример #9
0
        public override void Decorate(Stencil s)
        {
            var sBed  = s.Expand(-1);
            var thing = bedOptions.RandomElement();
            var stuff = GenCity.RandomStuff(thing, s.map);
            var bed   = (Building_Bed)sBed.Spawn(sBed.RandX, sBed.RandZ, thing, stuff);

            bed.SetFactionDirect(s.map.ParentFaction);
            bed.ForPrisoners = true;
            if (s.Chance(prisonerChance))
            {
                var pawn = GenCity.SpawnInhabitant(s.pos, s.map);
                pawn.guest.SetGuestStatus(s.map.ParentFaction, true);
                bed.TryAssignPawn(pawn);
            }
        }
        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);
        }