public static void UnloadThingsNear(Faction faction, IntVec3 dropCenter, IEnumerable <Thing> things, int openDelay = 110, bool canInstaDropDuringInit = false, bool leaveSlag = false, bool canRoofPunch = true) { Log.Message("Starting Spawn"); foreach (Thing current in things) { List <Thing> list = new List <Thing>(); list.Add(current); Deepstriker_Utilities.tempList.Add(list); } Deepstriker_Utilities.UnloadThingGroupsNear(faction, dropCenter, Deepstriker_Utilities.tempList, openDelay, canInstaDropDuringInit, leaveSlag, canRoofPunch); Deepstriker_Utilities.tempList.Clear(); }
public static void UnloadThingGroupsNear(Faction faction, IntVec3 dropCenter, 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, 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." })); intVec = CellFinderLoose.RandomCellWith((IntVec3 c) => c.Walkable(), 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, ThingPlaceMode.Near, null); } } else { DropPodInfo dropPodInfo = new DropPodInfo(); foreach (Thing current3 in current) { dropPodInfo.containedThings.Add(current3); } dropPodInfo.openDelay = openDelay; dropPodInfo.leaveSlag = leaveSlag; Deepstriker_Utilities.MakeDeepStrikerAt(intVec, dropPodInfo, faction); } } }
public override bool TryExecute(IncidentParms parms) { { this.ResolveRaidPoints(parms); if (!this.TryResolveRaidFaction(parms)) { return(false); } this.ResolveRaidStrategy(parms); this.ResolveRaidArriveMode(parms); this.ResolveRaidSpawnCenter(parms); PawnGroupMakerUtility.AdjustPointsForGroupArrivalParams(parms); List <Pawn> list = PawnGroupMakerUtility.GenerateArrivingPawns(parms, true).ToList <Pawn>(); if (list.Count == 0) { Log.Error("Got no pawns spawning raid from parms " + parms); return(false); } TargetInfo letterLookTarget = TargetInfo.Invalid; Deepstriker_Utilities.UnloadThingsNear(parms.faction, parms.spawnCenter, list.Cast <Thing>(), parms.raidPodOpenDelay, false, true, true); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("Points = " + parms.points.ToString("F0")); foreach (Pawn current2 in list) { string str = (current2.equipment == null || current2.equipment.Primary == null) ? "unarmed" : current2.equipment.Primary.LabelCap; stringBuilder.AppendLine(current2.KindLabel + " - " + str); } Find.LetterStack.ReceiveLetter(this.GetLetterLabel(parms), this.GetLetterText(parms, list), this.GetLetterType(), letterLookTarget, stringBuilder.ToString()); if (this.GetLetterType() == LetterType.BadUrgent) { TaleRecorder.RecordTale(TaleDefOf.RaidArrived, new object[0]); } PawnRelationUtility.Notify_PawnsSeenByPlayer(list, this.GetRelatedPawnsInfoLetterText(parms), true); Lord lord = LordMaker.MakeNewLord(parms.faction, parms.raidStrategy.Worker.MakeLordJob(ref parms), list); AvoidGridMaker.RegenerateAvoidGridsFor(parms.faction); LessonAutoActivator.TeachOpportunity(ConceptDefOf.EquippingWeapons, OpportunityType.Critical); if (!PlayerKnowledgeDatabase.IsComplete(ConceptDefOf.PersonalShields)) { for (int i = 0; i < list.Count; i++) { Pawn pawn = list[i]; if (pawn.apparel.WornApparel.Any((Apparel ap) => ap is PersonalShield)) { LessonAutoActivator.TeachOpportunity(ConceptDefOf.PersonalShields, OpportunityType.Critical); break; } } } if (DebugViewSettings.drawStealDebug && parms.faction.HostileTo(Faction.OfPlayer)) { Log.Message(string.Concat(new object[] { "Market value threshold to start stealing: ", StealAIUtility.StartStealingMarketValueThreshold(lord), " (colony wealth = ", Find.StoryWatcher.watcherWealth.WealthTotal, ")" })); } return(true); } }