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);
                }
            }
        }
Example #2
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);
        }
        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);
                    }
                }
            }
Example #5
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 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);
            }
        }
Example #7
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));
            }
        }
Example #8
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
        }
Example #9
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;
        }
Example #10
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);
            }
        }
Example #11
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);
        }
Example #12
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)
        {
            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);
        }
        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);
        }