Пример #1
0
 private void CheckAutoRebuild(Map map)
 {
     if (autoRearm && CanSetAutoRearm && map != null && GenConstruct.CanPlaceBlueprintAt(def, base.Position, base.Rotation, map).Accepted)
     {
         GenConstruct.PlaceBlueprintForBuild(def, base.Position, map, base.Rotation, Faction.OfPlayer, base.Stuff);
     }
 }
Пример #2
0
        private static IEnumerable <Blueprint_Build> MakeSandbagLine(IntVec3 root, Map map, Rot4 growDir, int maxLength)
        {
            int i = 0;

            if (i < maxLength && SiegeBlueprintPlacer.CanPlaceBlueprintAt(root, Rot4.North, ThingDefOf.Sandbags, map))
            {
                yield return(GenConstruct.PlaceBlueprintForBuild(ThingDefOf.Sandbags, root, map, Rot4.North, SiegeBlueprintPlacer.faction, null));

                /*Error: Unable to find new state assignment for yield return*/;
            }
        }
Пример #3
0
        public override bool Spawn(IntVec3 at, Map map, Faction faction, Sketch.SpawnMode spawnMode = Sketch.SpawnMode.Normal, bool wipeIfCollides = false, List <Thing> spawnedThings = null, bool dormant = false)
        {
            if (IsSpawningBlocked(at, map, null, wipeIfCollides))
            {
                return(false);
            }
            switch (spawnMode)
            {
            case Sketch.SpawnMode.Blueprint:
                GenConstruct.PlaceBlueprintForBuild(def, at, map, rot, faction, stuff ?? GenStuff.DefaultStuffFor(def));
                break;

            case Sketch.SpawnMode.Normal:
            {
                Thing thing2 = Instantiate();
                spawnedThings?.Add(thing2);
                if (faction != null)
                {
                    thing2.SetFactionDirect(faction);
                }
                SetDormant(thing2, dormant);
                GenSpawn.Spawn(thing2, at, map, rot, WipeMode.VanishOrMoveAside);
                break;
            }

            case Sketch.SpawnMode.TransportPod:
            {
                Thing thing = Instantiate();
                thing.Position = at;
                thing.Rotation = rot;
                spawnedThings?.Add(thing);
                if (faction != null)
                {
                    thing.SetFactionDirect(faction);
                }
                SetDormant(thing, dormant);
                ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo();
                activeDropPodInfo.innerContainer.TryAdd(thing, 1);
                activeDropPodInfo.openDelay = 60;
                activeDropPodInfo.leaveSlag = false;
                activeDropPodInfo.despawnPodBeforeSpawningThing = true;
                activeDropPodInfo.spawnWipeMode = (wipeIfCollides ? new WipeMode?(WipeMode.VanishOrMoveAside) : null);
                activeDropPodInfo.moveItemsAsideBeforeSpawning = true;
                activeDropPodInfo.setRotation = rot;
                DropPodUtility.MakeDropPodAt(at, map, activeDropPodInfo);
                break;
            }

            default:
                throw new NotImplementedException("Spawn mode " + spawnMode + " not implemented!");
            }
            return(true);
        }
Пример #4
0
        private static IEnumerable <Blueprint_Build> MakeSandbagLine(IntVec3 root, Map map, Rot4 growDir, int maxLength)
        {
            IntVec3 cur = root;

            for (int i = 0; i < maxLength; i++)
            {
                if (!SiegeBlueprintPlacer.CanPlaceBlueprintAt(cur, Rot4.North, ThingDefOf.Sandbags, map))
                {
                    break;
                }
                yield return(GenConstruct.PlaceBlueprintForBuild(ThingDefOf.Sandbags, cur, map, Rot4.North, SiegeBlueprintPlacer.faction, null));

                SiegeBlueprintPlacer.placedSandbagLocs.Add(cur);
                cur += growDir.FacingCell;
            }
        }
Пример #5
0
        private static IEnumerable <Blueprint_Build> MakeCoverLine(IntVec3 root, Map map, Rot4 growDir, int maxLength, ThingDef coverThing, ThingDef coverStuff)
        {
            IntVec3 cur = root;

            for (int i = 0; i < maxLength; i++)
            {
                if (!CanPlaceBlueprintAt(cur, Rot4.North, coverThing, map, coverStuff))
                {
                    break;
                }
                yield return(GenConstruct.PlaceBlueprintForBuild(coverThing, cur, map, Rot4.North, faction, coverStuff));

                placedCoverLocs.Add(cur);
                cur += growDir.FacingCell;
            }
        }
Пример #6
0
        public override void DesignateSingleCell(IntVec3 c)
        {
            if (TutorSystem.TutorialMode && !TutorSystem.AllowAction(new EventPack(base.TutorTagDesignate, c)))
            {
                return;
            }
            if (DebugSettings.godMode || entDef.GetStatValueAbstract(StatDefOf.WorkToBuild, stuffDef) == 0f)
            {
                if (entDef is TerrainDef)
                {
                    base.Map.terrainGrid.SetTerrain(c, (TerrainDef)entDef);
                }
                else
                {
                    Thing thing = ThingMaker.MakeThing((ThingDef)entDef, stuffDef);
                    thing.SetFactionDirect(Faction.OfPlayer);
                    GenSpawn.Spawn(thing, c, base.Map, placingRot);
                }
            }
            else
            {
                GenSpawn.WipeExistingThings(c, placingRot, entDef.blueprintDef, base.Map, DestroyMode.Deconstruct);
                GenConstruct.PlaceBlueprintForBuild(entDef, c, base.Map, placingRot, Faction.OfPlayer, stuffDef);
            }
            MoteMaker.ThrowMetaPuffs(GenAdj.OccupiedRect(c, placingRot, entDef.Size), base.Map);
            ThingDef thingDef = entDef as ThingDef;

            if (thingDef != null && thingDef.IsOrbitalTradeBeacon)
            {
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.BuildOrbitalTradeBeacon, KnowledgeAmount.Total);
            }
            if (TutorSystem.TutorialMode)
            {
                TutorSystem.Notify_Event(new EventPack(base.TutorTagDesignate, c));
            }
            if (entDef.PlaceWorkers != null)
            {
                for (int i = 0; i < entDef.PlaceWorkers.Count; i++)
                {
                    entDef.PlaceWorkers[i].PostPlace(base.Map, entDef, c, placingRot);
                }
            }
        }
Пример #7
0
        public override bool Spawn(IntVec3 at, Map map, Faction faction, Sketch.SpawnMode spawnMode = Sketch.SpawnMode.Normal, bool wipeIfCollides = false, List <Thing> spawnedThings = null, bool dormant = false)
        {
            if (IsSpawningBlocked(at, map, null, wipeIfCollides))
            {
                return(false);
            }
            switch (spawnMode)
            {
            case Sketch.SpawnMode.Blueprint:
                GenConstruct.PlaceBlueprintForBuild(GetDefFromStuff(), at, map, Rot4.North, faction, null);
                break;

            case Sketch.SpawnMode.Normal:
                map.terrainGrid.SetTerrain(at, GetDefFromStuff());
                break;

            default:
                throw new NotImplementedException(string.Concat("Spawn mode ", spawnMode, " not implemented!"));
            }
            return(true);
        }
Пример #8
0
        private static IEnumerable <Blueprint_Build> PlaceArtilleryBlueprints(float points, Map map)
        {
            IEnumerable <ThingDef> artyDefs = DefDatabase <ThingDef> .AllDefs.Where((ThingDef def) => def.building != null && def.building.buildingTags.Contains("Artillery_BaseDestroyer"));

            int numArtillery = Mathf.RoundToInt(points / 60f);

            numArtillery = Mathf.Clamp(numArtillery, 1, 2);
            for (int i = 0; i < numArtillery; i++)
            {
                Rot4     random   = Rot4.Random;
                ThingDef thingDef = artyDefs.RandomElement();
                IntVec3  intVec   = FindArtySpot(thingDef, random, map);
                if (!intVec.IsValid)
                {
                    break;
                }
                yield return(GenConstruct.PlaceBlueprintForBuild(thingDef, intVec, map, random, faction, ThingDefOf.Steel));

                points -= 60f;
            }
        }
Пример #9
0
        private static IEnumerable <Blueprint_Build> PlaceArtilleryBlueprints(float points, Map map)
        {
            IEnumerable <ThingDef> artyDefs = from def in DefDatabase <ThingDef> .AllDefs
                                              where def.building != null && def.building.buildingTags.Contains("Artillery_BaseDestroyer")
                                              select def;
            int numArtillery = Mathf.RoundToInt(points / 60f);

            numArtillery = Mathf.Clamp(numArtillery, 1, 2);
            for (int i = 0; i < numArtillery; i++)
            {
                Rot4     rot      = Rot4.Random;
                ThingDef artyDef  = artyDefs.RandomElement <ThingDef>();
                IntVec3  artySpot = SiegeBlueprintPlacer.FindArtySpot(artyDef, rot, map);
                if (!artySpot.IsValid)
                {
                    break;
                }
                yield return(GenConstruct.PlaceBlueprintForBuild(artyDef, artySpot, map, rot, SiegeBlueprintPlacer.faction, ThingDefOf.Steel));

                points -= 60f;
            }
        }
Пример #10
0
        private static IEnumerable <Blueprint_Build> PlaceArtilleryBlueprints(float points, Map map)
        {
            IEnumerable <ThingDef> artyDefs = from def in DefDatabase <ThingDef> .AllDefs
                                              where def.building != null && def.building.buildingTags.Contains("Artillery_BaseDestroyer")
                                              select def;
            int numArtillery2 = Mathf.RoundToInt((float)(points / 60.0));

            numArtillery2 = Mathf.Clamp(numArtillery2, 1, 2);
            int i = 0;

            if (i < numArtillery2)
            {
                Rot4     rot      = Rot4.Random;
                ThingDef artyDef  = artyDefs.RandomElement();
                IntVec3  artySpot = SiegeBlueprintPlacer.FindArtySpot(artyDef, rot, map);
                if (artySpot.IsValid)
                {
                    yield return(GenConstruct.PlaceBlueprintForBuild(artyDef, artySpot, map, rot, SiegeBlueprintPlacer.faction, ThingDefOf.Steel));

                    /*Error: Unable to find new state assignment for yield return*/;
                }
            }
        }