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));
                    }
                }
            }
        }
            public virtual void Generate(Stencil s)
            {
                var spacingX = this.spacingX > 0 ? this.spacingX : spacing;
                var spacingZ = this.spacingZ > 0 ? this.spacingZ : spacing;

                s.ClearThingsInBounds();
                if (!naturalFloor)
                {
                    s.FillTerrain(GenCity.RandomFloor(s.map));
                }
                if (roofed)
                {
                    var wallStuff = GenCity.RandomWallStuff(s.map);
                    s.Spawn(s.MinX, s.MinZ, ThingDefOf.Wall, wallStuff);
                    s.Spawn(s.MaxX, s.MinZ, ThingDefOf.Wall, wallStuff);
                    s.Spawn(s.MinX, s.MaxZ, ThingDefOf.Wall, wallStuff);
                    s.Spawn(s.MaxX, s.MaxZ, ThingDefOf.Wall, wallStuff);
                    s.FillRoof(RoofDefOf.RoofConstructed);
                }

                var stuff = thingStuff ?? GenCity.RandomStuff(thingDef, s.map);

                var paddingX = spacingX / 2 + 1;
                var paddingZ = spacingZ / 2 + 1;

                for (var x = s.MinX + paddingX; x <= s.MaxX - paddingX; x += spacingX)
                {
                    for (var z = s.MinZ + paddingZ; z <= s.MaxZ - paddingZ; z += spacingZ)
                    {
                        s.Spawn(x, z, thingDef, stuff);
                    }
                }
            }
        public override void Decorate(Stencil s)
        {
            var floorStuff  = GenCity.RandomFloor(s.map);
            var columnStuff = GenCity.RandomStuff(ThingDefOf.Column, s.map);
            var distance    = distanceRange.RandomInRange;

            for (var dir = 0; dir < 4; dir++)
            {
                var sDir = s.Rotate(dir);
                sDir = sDir.Bound(sDir.MinX, sDir.MaxZ + 1, sDir.MaxX, sDir.MaxZ + distance);
                if (dir % 2 == 0)
                {
                    sDir = sDir.Expand(distance, 0, distance, 0);
                }

                var spacing = columnSpacingRange.RandomInRange;
                for (var x = sDir.MinX + Rand.Range(0, spacing); x <= sDir.MaxX; x += spacing)
                {
                    var sCol = sDir.Move(x, sDir.MaxZ);
                    if (sCol.IsInMap() && IsValidTile(s.map, sCol.pos))
                    {
                        sCol.Spawn(ThingDefOf.Column, columnStuff);
                    }
                }

                sDir.FillRoof(RoofDefOf.RoofConstructed)
                .FillTerrain(floorStuff, IsValidTile);
            }
        }
示例#4
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());
                }
            }
示例#5
0
        public override void GenerateRect(Stencil s)
        {
            if (!Config_Cities.Instance.enableTurrets)
            {
                return;
            }
            var stuff = GenCity.RandomStuff(ThingDefOf.Sandbags, s.map);

            for (var dir = 0; dir < 4; dir++)
            {
                var sDir = s.Rotate(dir);
                for (var x = sDir.MinX; x <= sDir.MaxX; x++)
                {
                    if (x <= sDir.MinX / 2 || x >= sDir.MaxX / 2)
                    {
                        sDir.Spawn(x, sDir.MaxZ, ThingDefOf.Sandbags, stuff);
                    }
                }
            }

            var emplacementOption = options
                                    .Where(opt => {
                if (opt.selfDestructive)
                {
                    return(Config_Cities.Instance.enableMortars && (s.map.ParentFaction.def.permanentEnemy || s.map.Parent is Citadel));
                }
                return(Config_Cities.Instance.enableTurrets);
            })
                                    .RandomElementByWeight(opt => opt.weight);

            emplacementOption?.Generate(s);
        }
示例#6
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));
            }
        }
示例#7
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);
            }
        }
        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);
                }
            }
        }
示例#9
0
 private void SpawnChair(Stencil s, ThingDef thing, ThingDef stuff)
 {
     s.Spawn(thing, stuff);
     if (s.Chance(chairPawnChance))
     {
         GenCity.SpawnInhabitant(s.pos, s.map);
     }
 }
示例#10
0
        public override void Generate(Map map, GenStepParams parms)
        {
            var s = new Stencil(map);

            s = s.Bound(s.MinX, s.MaxZ - Mathf.RoundToInt(map.Size.x * HeightRatio), s.MaxX, s.MaxZ)
                .Center();

            // Clear area
            s.Expand(0, 3, 0, 0).ClearThingsInBounds();

            // Courtyard floor
            s.FillTerrain(BaseGenUtility.RandomHightechFloorDef());

            // Outer floor
            s.Bound(0, s.MinZ - 1, 0, s.MinZ - 8).SetTerrain(GenCity.RandomFloor(map));

            // Outer barricade
            s.Fill(s.MinX, s.MinZ - 7, s.MaxX, s.MinZ - 7, ThingDefOf.Barricade, GenCity.RandomStuff(ThingDefOf.Barricade, map), IsValidBarricadeTile);

            // Outer wall
            var wallStuff = BaseGenUtility.RandomHightechWallStuff();
            var doorX     = s.MinX + map.Size.x / 2;

            s.Fill(s.MinX, s.MinZ - 3, doorX - 1, s.MinZ, ThingDefOf.Wall, wallStuff);
            s.Fill(doorX + 1, s.MinZ - 3, s.MaxX, s.MinZ, ThingDefOf.Wall, wallStuff);
            s.Bound(doorX, s.MinZ - 3, doorX, s.MinZ)
            .Fill(ThingDefOf.Door, wallStuff);

            // Inner keep
            s = s.Expand(-marginRange.RandomInRange, -marginRange.RandomInRange, -marginRange.RandomInRange, -marginRange.RandomInRange);

            var genStep = (GenStep_Buildings)buildingGenStepDef.genStep;

            genStep.GenerateRect(s);

            // Mechanoids
            var mechs = PawnGroupMakerUtility.GeneratePawns(new PawnGroupMakerParms {
                groupKind = PawnGroupKindDefOf.Combat,
                tile      = map.Tile,
                faction   = Faction.OfMechanoids,
                points    = 5000,
            }).ToList();

            foreach (var mech in mechs)
            {
                var pos = s.Expand(-10).MoveRand().pos;
                GenSpawn.Spawn(mech, GenCity.FindPawnSpot(pos, map), map);
                mech.SetFactionDirect(map.ParentFaction);
                mech.Name = new NameSingle(mechanoidNames[Rand.Range(0, mechanoidNames.Count)] + " #" + Rand.RangeInclusive(10, 40));
                var lord = LordMaker.MakeNewLord(map.ParentFaction, new LordJob_LiveInCitadel(pos), map);
                lord.AddPawn(mech);
            }

            //TODO throne room
        }
 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);
     }
 }
        public override void Decorate(Stencil s)
        {
            base.Decorate(s);

            var sVent = s.RotateRand().Move(0, s.MaxZ - 1).Bound(-1, -1, 1, 1);

            sVent.Border(ThingDefOf.Wall, GenCity.RandomWallStuff(s.map));
            sVent.Bound(0, 0, 0, 0).ClearRoof();
            var tempControl = sVent.Spawn(0, -1, ThingDefOf.Cooler).TryGetComp <CompTempControl>();

            tempControl.targetTemperature = -1;
        }
示例#13
0
        protected override void ScatterAt(IntVec3 pos, Map map, GenStepParams parms, int count)
        {
            var s = new Stencil(map);

            s = s.BoundTo(CellRect.FromLimits(pos, s.bounds.RandomCell));
            var stuff = GenCity.RandomWallStuff(map);

            for (var dir = 0; dir < 4; dir++)
            {
                var sDir = s.Rotate(dir);
                sDir.Fill(sDir.MinX, sDir.MaxZ, sDir.MaxX, sDir.MaxZ, ThingDefOf.Wall, stuff, IsValidTile);
            }
        }
示例#14
0
        public override void Decorate(Stencil s)
        {
            var sBed       = s.Expand(-1);
            var thing      = ThingDefOf.Bed;
            var stuff      = GenCity.RandomStuff(thing, s.map);
            var monitorDef = DefDatabase <ThingDef> .GetNamed("VitalsMonitor");

            var monitor = sBed.Spawn(sBed.RandX, sBed.MaxZ, monitorDef);
            var bed     = (Building_Bed)sBed.Spawn(sBed.RandX, sBed.RandZ, thing, stuff);

            bed.SetFactionDirect(s.map.ParentFaction);
            bed.Medical = true;
        }
示例#15
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 PreMapGenerate()
        {
            var defaultSettlement = Find.WorldObjects.MapParentAt(Find.GameInitData.startingTile);

            Find.WorldObjects.Remove(defaultSettlement);

            var citadel = (Citadel)WorldObjectMaker.MakeWorldObject(DefDatabase <WorldObjectDef> .GetNamed("City_Citadel"));

            citadel.SetFaction(Find.GameInitData.playerFaction);
            citadel.inhabitantFaction = GenCity.RandomCityFaction(f => !f.def.CanEverBeNonHostile);
            citadel.Tile = Find.GameInitData.startingTile;
            citadel.Name = citadel.ChooseName();
            Find.WorldObjects.Add(citadel);
        }
        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");
        }
示例#18
0
        public override void Decorate(Stencil s)
        {
            var thing = Rand.Chance(barricadeChance) ? ThingDefOf.Barricade : ThingDefOf.Sandbags;
            var stuff = GenCity.RandomStuff(thing, s.map);

            for (var dir = 0; dir < 4; dir++)
            {
                var sDir = s.Rotate(dir);
                sDir.Bound(sDir.MinX - distance, sDir.MaxZ + distance, sDir.MinX / 2, sDir.MaxZ + distance)
                .Fill(thing, stuff, mask: IsValidTile);
                sDir.Bound(sDir.MaxX / 2, sDir.MaxZ + distance, sDir.MaxX + distance, sDir.MaxZ + distance)
                .Fill(thing, stuff, mask: IsValidTile);
            }
        }
示例#19
0
        public override void PreMapGenerate()
        {
            var defaultSettlement = Find.WorldObjects.MapParentAt(Find.GameInitData.startingTile);

            Find.WorldObjects.Remove(defaultSettlement);

            var city = (City)WorldObjectMaker.MakeWorldObject(DefDatabase <WorldObjectDef> .GetNamed(GetObjectDefName()));

            city.SetFaction(Find.GameInitData.playerFaction);
            city.inhabitantFaction = GenCity.RandomCityFaction(IsValidFaction);
            city.Tile = Find.GameInitData.startingTile;
            city.Name = SettlementNameGenerator.GenerateSettlementName(city, city.inhabitantFaction?.def.factionNameMaker);
            Find.WorldObjects.Add(city);
        }
示例#20
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);
        }
示例#21
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);
            }
        }
        public override void GenerateRect(Stencil s)
        {
            GenRooms(s, true);

            var wallStuff = RandomWallStuff(s.map);
            var doorStuff = RandomWallStuff(s.map);
            var hasDoor   = false;

            for (var dir = 0; dir < 4; dir++)
            {
                var sDir = s.Rotate(dir);

                var doorHere = !hasDoor || s.Chance(doorChance);
                if (doorHere)
                {
                    hasDoor = true;
                    var offset = sDir.RandInclusive(0, 2) + 2;
                    var doorZ  = sDir.Chance(.5F) ? sDir.MinZ + offset : sDir.MaxZ - offset;
                    for (var z = sDir.MinZ; z < sDir.MaxZ; z++)
                    {
                        if (z != doorZ)
                        {
                            sDir.Spawn(sDir.MaxX, z, ThingDefOf.Wall, doorStuff);
                        }
                        else
                        {
                            sDir.Move(sDir.MaxX + 1, z).ClearBuildingsAtPos();
                            sDir.Spawn(sDir.MaxX, z, ThingDefOf.Door, wallStuff);
                        }
                    }
                }
                else
                {
                    sDir.Fill(sDir.MaxX, sDir.MinZ, sDir.MaxX, sDir.MaxZ - 1, ThingDefOf.Wall, wallStuff);
                }
            }

            if (buildingDecorators.Count > 0)
            {
                buildingDecorators.RandomElement().Decorate(s);
            }

            // s.FillFog();
            s.Expand(1).BorderTerrain(GenCity.RandomFloor(s.map), IsValidTile);
        }
        public override void GenerateRect(Stencil s)
        {
            var stuff = GenCity.RandomStuff(ThingDefOf.Sandbags, s.map);

            for (var dir = 0; dir < 4; dir++)
            {
                var sDir = s.Rotate(dir);
                for (var x = sDir.MinX; x <= sDir.MaxX; x++)
                {
                    if (x <= sDir.MinX / 2 || x >= sDir.MaxX / 2)
                    {
                        sDir.Spawn(x, sDir.MaxZ, ThingDefOf.Sandbags, stuff);
                    }
                }
            }

            options.Where(opt => !opt.selfDestructive || s.map.ParentFaction.def.permanentEnemy || s.map.Parent is Citadel)
            .RandomElementByWeight(opt => opt.weight).Generate(s);
        }
        void GenerateCity(WorldObjectDef def, bool abandoned, System.Predicate <Faction> factionFilter = null)
        {
            var city = (City)WorldObjectMaker.MakeWorldObject(def);

            city.SetFaction(GenCity.RandomCityFaction(factionFilter));
            if (!abandoned)
            {
                city.inhabitantFaction = city.Faction;
            }

            city.Tile = TileFinder.RandomSettlementTileFor(city.Faction);
            city.Name = city.ChooseName();
            if (!TileFinder.IsValidTileForNewSettlement(city.Tile))
            {
                // (Faction Control) ensure valid tile for existing saves
                city.Tile = TileFinder.RandomStartingTile();
            }

            Find.WorldObjects.Add(city);
        }
示例#25
0
        public override void Tick()
        {
            var map = Find.CurrentMap;

            if (map != null && Find.TickManager.TicksGame == 20)
            {
                var faction = GenCity.RandomCityFaction(f => f.GoodwillWith(Faction.OfPlayer) >= 0 && !f.def.HasRoyalTitles);
                faction.TryAffectGoodwillWith(Faction.OfPlayer, 100, false, false);

                var storyComp = Find.Storyteller.storytellerComps.First(x => x is StorytellerComp_OnOffCycle || x is StorytellerComp_RandomMain);
                var parms     = storyComp.GenerateParms(IncidentCategoryDefOf.ThreatBig, map);
                parms.faction         = faction;
                parms.raidStrategy    = RaidStrategyDefOf.ImmediateAttackFriendly;
                parms.raidArrivalMode = PawnsArrivalModeDefOf.EdgeWalkIn;
                parms.raidArrivalModeForQuickMilitaryAid = true;
                parms.points = 2500;
                parms.biocodeWeaponsChance            = 0;
                parms.raidNeverFleeIndividual         = true;
                parms.dontUseSingleUseRocketLaunchers = true;
                IncidentDefOf.RaidFriendly.Worker.TryExecute(parms);
            }
        }
示例#26
0
        void GenerateCities(int per100kTiles, bool abandoned)
        {
            int cityCount = GenMath.RoundRandom(Find.WorldGrid.TilesCount / 100000F * per100kTiles);

            for (int i = 0; i < cityCount; i++)
            {
                var city = (City)WorldObjectMaker.MakeWorldObject(DefDatabase <WorldObjectDef> .GetNamed(abandoned ? "City_Abandoned" : "City_Faction"));
                city.SetFaction(GenCity.RandomCityFaction());
                if (!abandoned)
                {
                    city.inhabitantFaction = city.Faction;
                }
                city.Tile = TileFinder.RandomSettlementTileFor(city.Faction);
                city.Name = SettlementNameGenerator.GenerateSettlementName(city);
                if (!TileFinder.IsValidTileForNewSettlement(city.Tile))
                {
                    // (Faction Control) ensure valid tile for existing saves
                    city.Tile = TileFinder.RandomStartingTile();
                }
                Find.WorldObjects.Add(city);
            }
        }
示例#27
0
        private void GeneratePawns()
        {
            var faction = city.Faction;

            hostages = new List <Pawn>();
            for (var i = 0; i < hostageCount; i++)
            {
                var pawn = PawnGenerator.GeneratePawn(new PawnGenerationRequest(PawnKindDefOf.Slave, faction, PawnGenerationContext.NonPlayer, city.Tile));
                pawn.equipment?.DestroyAllEquipment();
                hostages.Add(pawn);
            }

            var captorFaction = GenCity.RandomCityFaction(f => !faction.def.CanEverBeNonHostile)
                                ?? GenCity.RandomCityFaction(f => f.HostileTo(Faction.OfPlayer));

            captors = new List <Pawn>();
            for (var i = 0; i < captorCount; i++)
            {
                var pawn = PawnGenerator.GeneratePawn(new PawnGenerationRequest(faction.RandomPawnKind(), captorFaction, PawnGenerationContext.NonPlayer, city.Tile));
                captors.Add(pawn);
            }
        }
示例#28
0
 public virtual void PreMapGenerate(Map map)
 {
     SetFaction(inhabitantFaction ?? GenCity.RandomCityFaction(f => f.HostileTo(Faction.OfPlayer)));
 }
 ThingDef RandomWallStuff(Map map)
 {
     return(wallStuffOptions.RandomElementWithFallback()
            ?? GenCity.RandomWallStuff(map, expensive));
 }
        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);
        }