public static void MakeDropoffShuttle(Map map, List <Thing> contents, Faction faction = null) { if (!DropCellFinder.TryFindShipLandingArea(map, out IntVec3 result, out Thing firstBlockingThing)) { if (firstBlockingThing != null) { Messages.Message("ShuttleBlocked".Translate("BlockedBy".Translate(firstBlockingThing).CapitalizeFirst()), firstBlockingThing, MessageTypeDefOf.NeutralEvent); } result = DropCellFinder.TryFindSafeLandingSpotCloseToColony(map, ThingDefOf.Shuttle.Size); } Thing thing = ThingMaker.MakeThing(ThingDefOf.Shuttle); thing.TryGetComp <CompShuttle>().dropEverythingOnArrival = true; for (int i = 0; i < contents.Count; i++) { Pawn p; if ((p = (contents[i] as Pawn)) != null) { Find.WorldPawns.RemovePawn(p); } } thing.SetFaction(faction); thing.TryGetComp <CompTransporter>().innerContainer.TryAddRangeOrTransfer(contents); GenPlace.TryPlaceThing(SkyfallerMaker.MakeSkyfaller(ThingDefOf.ShuttleIncoming, Gen.YieldSingle(thing)), result, map, ThingPlaceMode.Near); }
public override void Notify_QuestSignalReceived(Signal signal) { base.Notify_QuestSignalReceived(signal); if (!(signal.tag == inSignal) || !MapParent.HasMap) { return; } IntVec3 result = IntVec3.Invalid; if (cell.IsValid) { result = cell; } else { if (tryLandInShipLandingZone && !DropCellFinder.TryFindShipLandingArea(MapParent.Map, out result, out var firstBlockingThing)) { if (firstBlockingThing != null) { Messages.Message("ShuttleBlocked".Translate("BlockedBy".Translate(firstBlockingThing).CapitalizeFirst()), firstBlockingThing, MessageTypeDefOf.NeutralEvent); } result = DropCellFinder.TryFindSafeLandingSpotCloseToColony(MapParent.Map, thing.def.Size, factionForFindingSpot); } if (!result.IsValid && tryLandNearThing != null) { DropCellFinder.FindSafeLandingSpotNearAvoidingHostiles(tryLandNearThing, MapParent.Map, out result, 35, 15, 25, thing.def.size); } if (!result.IsValid && (!lookForSafeSpot || !DropCellFinder.FindSafeLandingSpot(out result, factionForFindingSpot, MapParent.Map, 35, 15, 25, thing.def.size))) { IntVec3 intVec = DropCellFinder.RandomDropSpot(MapParent.Map); if (!DropCellFinder.TryFindDropSpotNear(intVec, MapParent.Map, out result, allowFogged: false, canRoofPunch: false, allowIndoors: false, thing.def.size)) { result = intVec; } } } GenPlace.TryPlaceThing(thing, result, MapParent.Map, ThingPlaceMode.Near); spawned = true; Skyfaller skyfaller = thing as Skyfaller; if (skyfaller != null && skyfaller.innerContainer.Count == 1) { innerSkyfallerThing = skyfaller.innerContainer.First(); } else { innerSkyfallerThing = null; } }