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); }
public bool SpawnNear(IntVec3 near, Map map, float radius, Faction faction, Sketch.SpawnMode spawnMode = Sketch.SpawnMode.Normal, bool wipeIfCollides = false, List <Thing> spawnedThings = null, bool dormant = false) { int num = GenRadial.NumCellsInRadius(radius); for (int i = 0; i < num; i++) { IntVec3 intVec = near + GenRadial.RadialPattern[i]; if (intVec.InBounds(map) && Spawn(intVec, map, faction, spawnMode, wipeIfCollides, spawnedThings, dormant)) { return(true); } } return(false); }
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 (this.IsSpawningBlocked(at, map, (Thing)null, wipeIfCollides)) { return(false); } if (spawnMode == Sketch.SpawnMode.Normal) { map.roofGrid.SetRoof(at, roof); } else { throw new NotImplementedException("Spawn mode " + (object)spawnMode + " not implemented!"); } return(true); }
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); }
public static List <Thing> SpawnCluster(IntVec3 center, Map map, MechClusterSketch sketch, bool dropInPods = true, bool canAssaultColony = false, string questTag = null) { List <Thing> spawnedThings = new List <Thing>(); Sketch.SpawnMode spawnMode = (!dropInPods) ? Sketch.SpawnMode.Normal : Sketch.SpawnMode.TransportPod; sketch.buildingsSketch.Spawn(map, center, Faction.OfMechanoids, Sketch.SpawnPosType.Unchanged, spawnMode, wipeIfCollides : false, clearEdificeWhereFloor : false, spawnedThings, sketch.startDormant, buildRoofsInstantly : false, null, delegate(IntVec3 spot, SketchEntity entity) { SketchThing sketchThing; if ((sketchThing = (entity as SketchThing)) != null && sketchThing.def != ThingDefOf.Wall && sketchThing.def != ThingDefOf.Barricade) { entity.SpawnNear(spot, map, 12f, Faction.OfMechanoids, spawnMode, wipeIfCollides: false, spawnedThings, sketch.startDormant); } }); float defendRadius = Mathf.Sqrt(sketch.buildingsSketch.OccupiedSize.x * sketch.buildingsSketch.OccupiedSize.x + sketch.buildingsSketch.OccupiedSize.z * sketch.buildingsSketch.OccupiedSize.z) / 2f + 6f; LordJob_MechanoidDefendBase lordJob_MechanoidDefendBase = null; lordJob_MechanoidDefendBase = ((!sketch.startDormant) ? ((LordJob_MechanoidDefendBase) new LordJob_MechanoidsDefend(spawnedThings, Faction.OfMechanoids, defendRadius, center, canAssaultColony, isMechCluster: true)) : ((LordJob_MechanoidDefendBase) new LordJob_SleepThenMechanoidsDefend(spawnedThings, Faction.OfMechanoids, defendRadius, center, canAssaultColony, isMechCluster: true))); Lord lord = LordMaker.MakeNewLord(Faction.OfMechanoids, lordJob_MechanoidDefendBase, map); QuestUtility.AddQuestTag(lord, questTag); bool flag = Rand.Chance(0.6f); float randomInRange = InitiationDelay.RandomInRange; int num = (int)(MechAssemblerInitialDelayDays.RandomInRange * 60000f); for (int i = 0; i < spawnedThings.Count; i++) { Thing thing = spawnedThings[i]; thing.TryGetComp <CompSpawnerPawn>()?.CalculateNextPawnSpawnTick(num); if (thing.TryGetComp <CompProjectileInterceptor>() != null) { lordJob_MechanoidDefendBase.AddThingToNotifyOnDefeat(thing); } if (flag) { CompInitiatable compInitiatable = thing.TryGetComp <CompInitiatable>(); if (compInitiatable != null) { compInitiatable.initiationDelayTicksOverride = (int)(60000f * randomInRange); } } Building b; if ((b = (thing as Building)) != null && IsBuildingThreat(b)) { lord.AddBuilding(b); } thing.SetFaction(Faction.OfMechanoids); } if (!sketch.pawns.NullOrEmpty()) { foreach (MechClusterSketch.Mech pawn2 in sketch.pawns) { IntVec3 result = pawn2.position + center; if (result.Standable(map) || CellFinder.TryFindRandomCellNear(result, map, 12, (IntVec3 x) => x.Standable(map), out result)) { Pawn pawn = PawnGenerator.GeneratePawn(pawn2.kindDef, Faction.OfMechanoids); CompCanBeDormant compCanBeDormant = pawn.TryGetComp <CompCanBeDormant>(); if (compCanBeDormant != null) { if (sketch.startDormant) { compCanBeDormant.ToSleep(); } else { compCanBeDormant.WakeUp(); } } lord.AddPawn(pawn); spawnedThings.Add(pawn); if (dropInPods) { ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo(); activeDropPodInfo.innerContainer.TryAdd(pawn, 1); activeDropPodInfo.openDelay = 60; activeDropPodInfo.leaveSlag = false; activeDropPodInfo.despawnPodBeforeSpawningThing = true; activeDropPodInfo.spawnWipeMode = WipeMode.Vanish; DropPodUtility.MakeDropPodAt(result, map, activeDropPodInfo); } else { GenSpawn.Spawn(pawn, result, map); } } } } foreach (Thing item in spawnedThings) { if (!sketch.startDormant) { item.TryGetComp <CompWakeUpDormant>()?.Activate(sendSignal: true, silent: true); } } return(spawnedThings); }
public abstract bool Spawn(IntVec3 at, Map map, Faction faction, Sketch.SpawnMode spawnMode = Sketch.SpawnMode.Normal, bool wipeIfCollides = false, List <Thing> spawnedThings = null, bool dormant = false);
public bool SpawnNear(IntVec3 near, Map map, float radius, Faction faction, Sketch.SpawnMode spawnMode = Sketch.SpawnMode.Normal, bool wipeIfCollides = false, List <Thing> spawnedThings = null, bool dormant = false) { return(SpawnNear_NewTmp(near, map, radius, faction, spawnMode, wipeIfCollides, spawnedThings, dormant)); }