コード例 #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());
                }
            }
コード例 #2
0
            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);
                    }
                }
            }
コード例 #3
0
        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;
        }
コード例 #4
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);
            }
        }
コード例 #5
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);
                    //     }
                    // }
                }
            }
        }
コード例 #6
0
 ThingDef RandomWallStuff(Map map)
 {
     return(wallStuffOptions.RandomElementWithFallback()
            ?? GenCity.RandomWallStuff(map, expensive));
 }