Пример #1
0
        public static void SetTerrain(List <MapObject> mapObjects, Map map)
        {
            foreach (var thing in mapObjects)
            {
                ThingData data = thing.key;

                if (data.Terrain != null)
                {
                    foreach (var pos in thing.value)
                    {
                        map.terrainGrid.SetTerrain(pos, data.Terrain);
                    }
                }
            }
        }
Пример #2
0
        public static void PlaceBuildingsAndItems(List <MapObject> mapObjects, Map map, Faction forceFaction, bool refuel)
        {
            foreach (var thing in mapObjects)
            {
                ThingData data = thing.key;

                if (data.Thing != null)
                {
                    foreach (var pos in thing.value)
                    {
                        Thing newThing = ThingMaker.MakeThing(data.Thing, data.Stuff);
                        var   comp     = newThing.TryGetComp <CompQuality>();
                        if (comp != null)
                        {
                            comp.SetQuality(data.Quality, ArtGenerationContext.Colony);
                        }
                        if (newThing.def.stackLimit != 1)
                        {
                            newThing.stackCount = data.Count;
                        }
                        newThing = GenSpawn.Spawn(newThing, pos, map, data.Rotate);

                        CompGatherSpot compGathering = newThing.TryGetComp <CompGatherSpot>();
                        if (compGathering != null)
                        {
                            compGathering.Active = false;
                        }

                        if (newThing.def.CanHaveFaction && forceFaction != null)
                        {
                            newThing.SetFaction(forceFaction);
                        }

                        CompRefuelable compRefuelable = newThing.TryGetComp <CompRefuelable>();
                        if (compRefuelable != null && refuel)
                        {
                            compRefuelable.Refuel(compRefuelable.Props.fuelCapacity);
                        }
                    }
                }
            }
        }
Пример #3
0
        public static void SpawnPawns(List <MapObject> mapObjects, Map map, Faction forceFaction, List <Pawn> spawnedPawns, Lord forceLord)
        {
            foreach (var thing in mapObjects)
            {
                ThingData data = thing.key;

                if (data.Kind != null)
                {
                    Faction faction = forceFaction;
                    if (faction == null)
                    {
                        faction = Find.FactionManager.FirstFactionOfDef(data.Faction);
                    }

                    if (faction != null)
                    {
                        foreach (var pos in thing.value)
                        {
                            Pawn pawn = PawnGenerator.GeneratePawn(data.Kind, faction);

                            if (pawn.RaceProps.Animal && data.Faction == null)
                            {
                                pawn.SetFaction(null);
                            }

                            if (pawn.RaceProps.FleshType == FleshTypeDefOf.Insectoid && pawn.Faction != Faction.OfInsects)
                            {
                                pawn.SetFaction(Faction.OfInsects);
                            }

                            if (pawn.RaceProps.IsMechanoid && pawn.Faction != Faction.OfMechanoids)
                            {
                                pawn.SetFaction(Faction.OfMechanoids);
                            }

                            pawn = GenSpawn.Spawn(pawn, pos, map) as Pawn;
                            spawnedPawns.Add(pawn);

                            if (forceLord == null)
                            {
                                LordJob_DefendPoint lordJob = new LordJob_DefendPoint(pawn.Position);
                                Lord lord = LordMaker.MakeNewLord(faction, lordJob, map);
                                lord.numPawnsLostViolently = int.MaxValue;

                                lord.AddPawn(pawn);
                            }
                            else
                            {
                                forceLord.AddPawn(pawn);
                            }
                        }
                    }
                    else
                    {
                        foreach (var pos in thing.value)
                        {
                            Pawn pawn = PawnGenerator.GeneratePawn(data.Kind, faction);
                            pawn = GenSpawn.Spawn(pawn, pos, map) as Pawn;
                        }
                    }
                }
            }
        }