public static void MakeDropPodAt(IntVec3 c, Map map, ActiveDropPodInfo info)
        {
            ActiveDropPod activeDropPod = (ActiveDropPod)ThingMaker.MakeThing(ThingDefOf.ActiveDropPod, null);

            activeDropPod.Contents = info;
            SkyfallerMaker.SpawnSkyfaller(ThingDefOf.DropPodIncoming, activeDropPod, c, map);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map          map    = (Map)parms.target;
            List <Thing> things = ThingSetMakerDefOf.RefugeePod.root.Generate();
            IntVec3      intVec = DropCellFinder.RandomDropSpot(map);
            Pawn         pawn   = ThingUtility.FindPawn(things);

            pawn.guest.getRescuedThoughtOnUndownedBecauseOfPlayer = true;
            TaggedString title = "LetterLabelRefugeePodCrash".Translate();
            TaggedString text  = "RefugeePodCrash".Translate(pawn.Named("PAWN")).AdjustedFor(pawn);

            text += "\n\n";
            if (pawn.Faction == null)
            {
                text += "RefugeePodCrash_Factionless".Translate(pawn.Named("PAWN")).AdjustedFor(pawn);
            }
            else if (pawn.Faction.HostileTo(Faction.OfPlayer))
            {
                text += "RefugeePodCrash_Hostile".Translate(pawn.Named("PAWN")).AdjustedFor(pawn);
            }
            else
            {
                text += "RefugeePodCrash_NonHostile".Translate(pawn.Named("PAWN")).AdjustedFor(pawn);
            }
            PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, ref title, pawn);
            SendStandardLetter(title, text, LetterDefOf.NeutralEvent, parms, new TargetInfo(intVec, map));
            ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo();

            activeDropPodInfo.innerContainer.TryAddRangeOrTransfer(things);
            activeDropPodInfo.openDelay = 180;
            activeDropPodInfo.leaveSlag = true;
            DropPodUtility.MakeDropPodAt(intVec, map, activeDropPodInfo);
            return(true);
        }
 public static void DropThingGroupsNear(IntVec3 dropCenter, Map map, List <List <Thing> > thingsGroups, int openDelay = 110, bool instaDrop = false, bool leaveSlag = false, bool canRoofPunch = true, bool explode = false)
 {
     foreach (List <Thing> thingsGroup in thingsGroups)
     {
         IntVec3 intVec = default(IntVec3);
         if (!DropCellFinder.TryFindDropSpotNear(dropCenter, map, out intVec, true, canRoofPunch))
         {
             Log.Warning("DropThingsNear failed to find a place to drop " + thingsGroup.FirstOrDefault() + " near " + dropCenter + ". Dropping on random square instead.");
             intVec = CellFinderLoose.RandomCellWith((IntVec3 c) => c.Walkable(map), map, 1000);
         }
         for (int i = 0; i < thingsGroup.Count; i++)
         {
             thingsGroup[i].SetForbidden(true, false);
         }
         if (instaDrop)
         {
             foreach (Thing item in thingsGroup)
             {
                 GenPlace.TryPlaceThing(item, intVec, map, ThingPlaceMode.Near, null);
             }
         }
         else
         {
             ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo();
             foreach (Thing item2 in thingsGroup)
             {
                 activeDropPodInfo.innerContainer.TryAdd(item2, true);
             }
             activeDropPodInfo.openDelay = openDelay;
             activeDropPodInfo.leaveSlag = leaveSlag;
             DropPodUtility.MakeDropPodAt(intVec, map, activeDropPodInfo, explode);
         }
     }
 }
        // Token: 0x06000EB1 RID: 3761 RVA: 0x0006D5F4 File Offset: 0x0006B9F4
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map          map    = (Map)parms.target;
            List <Thing> things = ThingSetMakerDefOf.RefugeePod.root.Generate();
            IntVec3      intVec = DropCellFinder.RandomDropSpot(map);
            Pawn         pawn   = this.FindPawn(things);

            pawn.guest.getRescuedThoughtOnUndownedBecauseOfPlayer = true;
            pawn.health.AddHediff(XenomorphDefOf.RRY_HiddenXenomorphImpregnation);
            string label = "LetterLabelRefugeePodCrash".Translate();
            string text  = "RefugeePodCrash".Translate(pawn.Named("PAWN")).AdjustedFor(pawn, "PAWN");

            text += "\n\n";
            if (pawn.Faction == null)
            {
                text += "RefugeePodCrash_Factionless".Translate(pawn.Named("PAWN")).AdjustedFor(pawn, "PAWN");
            }
            else if (pawn.Faction.HostileTo(Faction.OfPlayer))
            {
                text += "RefugeePodCrash_Hostile".Translate(pawn.Named("PAWN")).AdjustedFor(pawn, "PAWN");
            }
            else
            {
                text += "RefugeePodCrash_NonHostile".Translate(pawn.Named("PAWN")).AdjustedFor(pawn, "PAWN");
            }
            PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, ref label, pawn);
            Find.LetterStack.ReceiveLetter(label, text, LetterDefOf.NeutralEvent, new TargetInfo(intVec, map, false), null, null);
            ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo();

            activeDropPodInfo.innerContainer.TryAddRangeOrTransfer(things, true, false);
            activeDropPodInfo.openDelay = 180;
            activeDropPodInfo.leaveSlag = true;
            DropPodUtility.MakeDropPodAt(intVec, map, activeDropPodInfo);
            return(true);
        }
Example #5
0
 public static void DropThingGroupsNear(IntVec3 dropCenter, Map map, List <List <Thing> > thingsGroups, int openDelay = 110, bool instaDrop = false, bool leaveSlag = false, bool canRoofPunch = true)
 {
     foreach (List <Thing> thingsGroup in thingsGroups)
     {
         if (!DropCellFinder.TryFindDropSpotNear(dropCenter, map, out IntVec3 result, allowFogged: true, canRoofPunch))
         {
             Log.Warning("DropThingsNear failed to find a place to drop " + thingsGroup.FirstOrDefault() + " near " + dropCenter + ". Dropping on random square instead.");
             result = CellFinderLoose.RandomCellWith((IntVec3 c) => c.Walkable(map), map);
         }
         for (int i = 0; i < thingsGroup.Count; i++)
         {
             thingsGroup[i].SetForbidden(value: true, warnOnFail: false);
         }
         if (instaDrop)
         {
             foreach (Thing item in thingsGroup)
             {
                 GenPlace.TryPlaceThing(item, result, map, ThingPlaceMode.Near);
             }
         }
         else
         {
             ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo();
             foreach (Thing item2 in thingsGroup)
             {
                 activeDropPodInfo.innerContainer.TryAdd(item2);
             }
             activeDropPodInfo.openDelay = openDelay;
             activeDropPodInfo.leaveSlag = leaveSlag;
             MakeDropPodAt(result, map, activeDropPodInfo);
         }
     }
 }
Example #6
0
        public static void SpawnDropPod(IntVec3 dropSpot, Map map, Thing t)
        {
            ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo();

            activeDropPodInfo.SingleContainedThing = t;
            activeDropPodInfo.leaveSlag            = false;
            DropPodUtility.MakeDropPodAt(dropSpot, map, activeDropPodInfo);
        }
        public static void MakeDropPodAt(IntVec3 c, Map map, ActiveDropPodInfo info, bool explode = false)
        {
            ActiveDropPod activeDropPod = (ActiveDropPod)ThingMaker.MakeThing(ThingDefOf.ActiveDropPod, null);

            activeDropPod.Contents = info;
            ThingDef skyfaller = (!explode) ? ThingDefOf.DropPodIncoming : ThingDefOf.ExplosiveDropPodIncoming;

            SkyfallerMaker.SpawnSkyfaller(skyfaller, activeDropPod, c, map);
        }
Example #8
0
        public override void SpawnJoiner(Map map, Pawn pawn)
        {
            IntVec3           c = DropCellFinder.RandomDropSpot(map);
            ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo();

            activeDropPodInfo.innerContainer.TryAddOrTransfer(pawn);
            activeDropPodInfo.openDelay = 180;
            activeDropPodInfo.leaveSlag = true;
            DropPodUtility.MakeDropPodAt(c, map, activeDropPodInfo);
        }
Example #9
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);
        }
        // Token: 0x06002762 RID: 10082 RVA: 0x0012C458 File Offset: 0x0012A858
        public static void MakeTunnelAt(IntVec3 c, Map map, ActiveDropPodInfo info)
        {
            ThingDef TunnelDef = DefDatabase <ThingDef> .GetNamed("RRY_Tunneler");

            //    Log.Message(string.Format("making tunnelSpawner: {0}, @: {1}, {2}, {3}", TunnelDef, c, map, info.innerContainer.ContentsString));
            TunnelSpawner tunnelSpawner = (TunnelSpawner)ThingMaker.MakeThing(TunnelDef, null);

            foreach (Thing item in info.innerContainer)
            {
                tunnelSpawner.GetDirectlyHeldThings().TryAddOrTransfer(item, false);
            }
            GenSpawn.Spawn(tunnelSpawner, c, map);
            //--    SkyfallerMaker.SpawnSkyfaller(ThingDefOf.DropPodIncoming, tunnelSpawner, c, map);
        }
Example #11
0
        public static void MakeDropPodAt(IntVec3 c, Map map, ActiveDropPodInfo info)
        {
            ActiveDropPod activeDropPod = (ActiveDropPod)ThingMaker.MakeThing(ThingDefOf.ActiveDropPod);

            activeDropPod.Contents = info;
            SkyfallerMaker.SpawnSkyfaller(ThingDefOf.DropPodIncoming, activeDropPod, c, map);
            foreach (Thing item in (IEnumerable <Thing>)activeDropPod.Contents.innerContainer)
            {
                Pawn pawn;
                if ((pawn = (item as Pawn)) != null && pawn.IsWorldPawn())
                {
                    Find.WorldPawns.RemovePawn(pawn);
                    pawn.psychicEntropy?.SetInitialPsyfocusLevel();
                }
            }
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map          map    = (Map)parms.target;
            List <Thing> things = ItemCollectionGeneratorDefOf.RefugeePod.Worker.Generate(default(ItemCollectionGeneratorParams));
            IntVec3      intVec = DropCellFinder.RandomDropSpot(map);
            Pawn         pawn   = this.FindPawn(things);
            string       label  = "LetterLabelRefugeePodCrash".Translate();
            string       text   = "RefugeePodCrash".Translate();

            PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, ref label, pawn);
            Find.LetterStack.ReceiveLetter(label, text, LetterDefOf.NeutralEvent, new TargetInfo(intVec, map, false), null);
            ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo();

            activeDropPodInfo.innerContainer.TryAddRangeOrTransfer(things, true, false);
            activeDropPodInfo.openDelay = 180;
            activeDropPodInfo.leaveSlag = true;
            DropPodUtility.MakeDropPodAt(intVec, map, activeDropPodInfo, true);
            return(true);
        }
        // Token: 0x06002764 RID: 10084 RVA: 0x0012C518 File Offset: 0x0012A918
        public static void DropThingGroupsNear(IntVec3 dropCenter, Map map, List <List <Thing> > thingsGroups, int openDelay = 110, bool instaDrop = false, bool leaveSlag = false, bool canRoofPunch = true)
        {
            foreach (List <Thing> list in thingsGroups)
            {
                IntVec3 intVec;
                if (!DropThoughRoofCellFinder.TryFindDropSpotNear(dropCenter, map, out intVec, true, canRoofPunch))
                {
                    Log.Warning(string.Concat(new object[]
                    {
                        "DropThingsNear failed to find a place to drop ",
                        list.FirstOrDefault <Thing>(),
                        " near ",
                        dropCenter,
                        ". Dropping on random square instead."
                    }), false);
                    intVec = CellFinderLoose.RandomCellWith((IntVec3 c) => c.Walkable(map) && (c.Roofed(map) && c.GetRoof(map) != RoofDefOf.RoofRockThick), map, 1000);
                }
                for (int i = 0; i < list.Count; i++)
                {
                    list[i].SetForbidden(true, false);
                }
                if (instaDrop)
                {
                    foreach (Thing thing in list)
                    {
                        GenPlace.TryPlaceThing(thing, intVec, map, ThingPlaceMode.Near, null, null);
                    }
                }
                else
                {
                    ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo();
                    foreach (Thing item in list)
                    {
                        activeDropPodInfo.innerContainer.TryAddOrTransfer(item, true);
                    }
                    activeDropPodInfo.openDelay = openDelay;
                    activeDropPodInfo.leaveSlag = leaveSlag;

                    DropThroughRoofUtility.MakeTunnelAt(intVec, map, activeDropPodInfo);
                }
            }
        }
Example #14
0
 public static void DropThingGroupsNear(IntVec3 dropCenter, Map map, List <List <Thing> > thingsGroups, int openDelay = 110, bool instaDrop = false, bool leaveSlag = false, bool canRoofPunch = true)
 {
     foreach (List <Thing> current in thingsGroups)
     {
         IntVec3 intVec;
         if (!DropCellFinder.TryFindDropSpotNear(dropCenter, map, out intVec, true, canRoofPunch))
         {
             Log.Warning(string.Concat(new object[]
             {
                 "DropThingsNear failed to find a place to drop ",
                 current.FirstOrDefault <Thing>(),
                 " near ",
                 dropCenter,
                 ". Dropping on random square instead."
             }), false);
             intVec = CellFinderLoose.RandomCellWith((IntVec3 c) => c.Walkable(map), map, 1000);
         }
         for (int i = 0; i < current.Count; i++)
         {
             current[i].SetForbidden(true, false);
         }
         if (instaDrop)
         {
             foreach (Thing current2 in current)
             {
                 GenPlace.TryPlaceThing(current2, intVec, map, ThingPlaceMode.Near, null, null);
             }
         }
         else
         {
             ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo();
             foreach (Thing current3 in current)
             {
                 activeDropPodInfo.innerContainer.TryAdd(current3, true);
             }
             activeDropPodInfo.openDelay = openDelay;
             activeDropPodInfo.leaveSlag = leaveSlag;
             DropPodUtility.MakeDropPodAt(intVec, map, activeDropPodInfo);
         }
     }
 }
        private void CallShuttleToCaravan(Pawn caller, Faction faction, bool free)
        {
            Caravan caravan           = caller.GetCaravan();
            int     maxLaunchDistance = ThingDefOf.Shuttle.GetCompProperties <CompProperties_Launchable>().fixedLaunchDistanceMax;

            CameraJumper.TryJump(CameraJumper.GetWorldTarget(caravan));
            Find.WorldSelector.ClearSelection();
            int caravanTile = caravan.Tile;

            Find.WorldTargeter.BeginTargeting_NewTemp(ChoseWorldTarget, canTargetTiles: true, CompLaunchable.TargeterMouseAttachment, closeWorldTabWhenFinished: false, delegate
            {
                GenDraw.DrawWorldRadiusRing(caravanTile, maxLaunchDistance);
            }, (GlobalTargetInfo target) => CompLaunchable.TargetingLabelGetter(target, caravanTile, maxLaunchDistance, Gen.YieldSingle(caravan), Launch, null));
            bool ChoseWorldTarget(GlobalTargetInfo target)
            {
                return(CompLaunchable.ChoseWorldTarget(target, caravan.Tile, Gen.YieldSingle(caravan), maxLaunchDistance, Launch, null));
            }

            void Launch(int tile, TransportPodsArrivalAction arrivalAction)
            {
                ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo();

                activeDropPodInfo.innerContainer.TryAddRangeOrTransfer(CaravanInventoryUtility.AllInventoryItems(caravan));
                activeDropPodInfo.innerContainer.TryAddRangeOrTransfer(caravan.GetDirectlyHeldThings());
                caravan.Destroy();
                TravelingTransportPods travelingTransportPods = (TravelingTransportPods)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.TravelingShuttle);

                travelingTransportPods.Tile = caravan.Tile;
                travelingTransportPods.SetFaction(Faction.OfPlayer);
                travelingTransportPods.destinationTile = tile;
                travelingTransportPods.arrivalAction   = arrivalAction;
                travelingTransportPods.AddPod(activeDropPodInfo, justLeftTheMap: true);
                Find.WorldObjects.Add(travelingTransportPods);
                Find.WorldTargeter.StopTargeting();
                caller.royalty.GetPermit(def, faction).Notify_Used();
                if (!free)
                {
                    caller.royalty.TryRemoveFavor(faction, def.royalAid.favorCost);
                }
            }
        }
Example #16
0
        public override void TravelingTransportPodsArrived(List <ActiveDropPodInfo> dropPods, Map map)
        {
            if (dropPods.Count > 1)
            {
                TransportPodsArrivalActionUtility.DropShuttle_NewTemp(dropPods, map, IntVec3.Invalid);
                return;
            }
            ActiveDropPodInfo activeDropPodInfo = dropPods[0];
            List <Pawn>       requiredPawns     = activeDropPodInfo.innerContainer.Where((Thing t) => t is Pawn).Cast <Pawn>().ToList();
            Thing             thing             = TransportPodsArrivalActionUtility.DropShuttle_NewTemp(dropPods, map, IntVec3.Invalid);

            thing.questTags = activeDropPodInfo.questTags;
            CompShuttle compShuttle = thing.TryGetComp <CompShuttle>();

            if (compShuttle == null)
            {
                return;
            }
            compShuttle.sendAwayIfQuestFinished = activeDropPodInfo.sendAwayIfQuestFinished;
            if (activeDropPodInfo.missionShuttleHome == null && activeDropPodInfo.missionShuttleTarget == null)
            {
                return;
            }
            compShuttle.missionShuttleTarget = activeDropPodInfo.missionShuttleHome;
            compShuttle.missionShuttleHome   = null;
            compShuttle.stayAfterDroppedEverythingOnArrival = true;
            compShuttle.requiredPawns = requiredPawns;
            compShuttle.hideControls  = false;
            if (compShuttle.missionShuttleTarget != null)
            {
                return;
            }
            foreach (Thing item in (IEnumerable <Thing>)compShuttle.Transporter.innerContainer)
            {
                Pawn pawn;
                if ((pawn = item as Pawn) != null && pawn.IsColonist)
                {
                    pawn.inventory.UnloadEverything = true;
                }
            }
        }
        private void CallResources(IntVec3 cell)
        {
            List <Thing> list = new List <Thing>();

            for (int i = 0; i < def.royalAid.itemsToDrop.Count; i++)
            {
                Thing thing = ThingMaker.MakeThing(def.royalAid.itemsToDrop[i].thingDef);
                thing.stackCount = def.royalAid.itemsToDrop[i].count;
                list.Add(thing);
            }
            if (list.Any())
            {
                ActiveDropPodInfo activeDropPodInfo = new ActiveDropPodInfo();
                activeDropPodInfo.innerContainer.TryAddRangeOrTransfer(list);
                DropPodUtility.MakeDropPodAt(cell, map, activeDropPodInfo);
                Messages.Message("MessagePermitTransportDrop".Translate(faction.Named("FACTION")), new LookTargets(cell, map), MessageTypeDefOf.NeutralEvent);
                caller.royalty.GetPermit(def, faction).Notify_Used();
                if (!free)
                {
                    caller.royalty.TryRemoveFavor(faction, def.royalAid.favorCost);
                }
            }
        }
Example #18
0
        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);
        }