public override string CompInspectStringExtra() { CompShuttle compShuttle = parent.TryGetComp <CompShuttle>(); if (LoadingInProgressOrReadyToLaunch && CanTryLaunch) { if (!AllInGroupConnectedToFuelingPort) { return("NotReadyForLaunch".Translate() + ": " + "NotAllInGroupConnectedToFuelingPort".Translate().CapitalizeFirst() + "."); } if (!AllFuelingPortSourcesInGroupHaveAnyFuel) { return("NotReadyForLaunch".Translate() + ": " + "NotAllFuelingPortSourcesInGroupHaveAnyFuel".Translate().CapitalizeFirst() + "."); } if (AnyInGroupHasAnythingLeftToLoad) { return("NotReadyForLaunch".Translate() + ": " + "TransportPodInGroupHasSomethingLeftToLoad".Translate().CapitalizeFirst() + "."); } if (compShuttle == null || !compShuttle.IsMissionShuttle || compShuttle.AllRequiredThingsLoaded) { return("ReadyForLaunch".Translate()); } } return(null); }
public static IEnumerable <Thing> AllSendableItems_NewTmp(List <CompTransporter> transporters, Map map, bool autoLoot) { List <Thing> items = CaravanFormingUtility.AllReachableColonyItems(map, canMinify: autoLoot, allowEvenIfOutsideHomeArea: autoLoot, allowEvenIfReserved: transporters[0].Props.canChangeAssignedThingsAfterStarting && transporters[0].LoadingInProgressOrReadyToLaunch); CompShuttle shuttle = transporters[0].parent.TryGetComp <CompShuttle>(); for (int i = 0; i < items.Count; i++) { if (shuttle == null || shuttle.IsRequired(items[i]) || shuttle.IsAllowed(items[i])) { yield return(items[i]); } } }
public static IEnumerable <Pawn> AllSendablePawns(List <CompTransporter> transporters, Map map) { CompShuttle shuttle = transporters[0].parent.TryGetComp <CompShuttle>(); int allowLoadAndEnterTransportersLordForGroupID = (transporters[0].Props.canChangeAssignedThingsAfterStarting && transporters[0].LoadingInProgressOrReadyToLaunch) ? transporters[0].groupID : (-1); List <Pawn> pawns = CaravanFormingUtility.AllSendablePawns(map, allowEvenIfDowned: true, allowEvenIfInMentalState: false, allowEvenIfPrisonerNotSecure: false, allowCapturableDownedPawns: false, shuttle != null, allowLoadAndEnterTransportersLordForGroupID); for (int i = 0; i < pawns.Count; i++) { if (shuttle == null || shuttle.IsRequired(pawns[i]) || shuttle.IsAllowed(pawns[i])) { yield return(pawns[i]); } } }
public void TryLaunch(int destinationTile, TransportPodsArrivalAction arrivalAction) { if (!parent.Spawned) { Log.Error(string.Concat("Tried to launch ", parent, ", but it's unspawned.")); return; } List <CompTransporter> transportersInGroup = TransportersInGroup; if (transportersInGroup == null) { Log.Error(string.Concat("Tried to launch ", parent, ", but it's not in any group.")); } else { if (!LoadingInProgressOrReadyToLaunch || !AllInGroupConnectedToFuelingPort || !AllFuelingPortSourcesInGroupHaveAnyFuel) { return; } Map map = parent.Map; int num = Find.WorldGrid.TraversalDistanceBetween(map.Tile, destinationTile); CompShuttle compShuttle = parent.TryGetComp <CompShuttle>(); if (num <= MaxLaunchDistance || (compShuttle != null && compShuttle.IsMissionShuttle)) { Transporter.TryRemoveLord(map); int groupID = Transporter.groupID; float amount = Mathf.Max(FuelNeededToLaunchAtDist(num), 1f); compShuttle?.SendLaunchedSignals(transportersInGroup); for (int i = 0; i < transportersInGroup.Count; i++) { CompTransporter compTransporter = transportersInGroup[i]; compTransporter.Launchable.FuelingPortSource?.TryGetComp <CompRefuelable>().ConsumeFuel(amount); ThingOwner directlyHeldThings = compTransporter.GetDirectlyHeldThings(); ActiveDropPod activeDropPod = (ActiveDropPod)ThingMaker.MakeThing(ThingDefOf.ActiveDropPod); activeDropPod.Contents = new ActiveDropPodInfo(); activeDropPod.Contents.innerContainer.TryAddRangeOrTransfer(directlyHeldThings, canMergeWithExistingStacks: true, destroyLeftover: true); DropPodLeaving obj = (DropPodLeaving)SkyfallerMaker.MakeSkyfaller(Props.skyfallerLeaving ?? ThingDefOf.DropPodLeaving, activeDropPod); obj.groupID = groupID; obj.destinationTile = destinationTile; obj.arrivalAction = arrivalAction; obj.worldObjectDef = ((compShuttle != null) ? WorldObjectDefOf.TravelingShuttle : WorldObjectDefOf.TravelingTransportPods); compTransporter.CleanUpLoadingVars(map); compTransporter.parent.Destroy(); GenSpawn.Spawn(obj, compTransporter.parent.Position, map); } CameraJumper.TryHideWorld(); } } }
public static IEnumerable <Pawn> AllSendablePawns_NewTmp(List <CompTransporter> transporters, Map map, bool autoLoot) { CompShuttle shuttle = transporters[0].parent.TryGetComp <CompShuttle>(); int allowLoadAndEnterTransportersLordForGroupID = ((transporters[0].Props.canChangeAssignedThingsAfterStarting && transporters[0].LoadingInProgressOrReadyToLaunch) ? transporters[0].groupID : (-1)); bool allowLodgers = shuttle != null; List <Pawn> pawns = CaravanFormingUtility.AllSendablePawns(map, allowEvenIfDowned: true, autoLoot, autoLoot, autoLoot, allowLodgers, allowLoadAndEnterTransportersLordForGroupID); for (int i = 0; i < pawns.Count; i++) { if (shuttle == null || shuttle.IsRequired(pawns[i]) || shuttle.IsAllowed(pawns[i])) { yield return(pawns[i]); } } }
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; } } }
public int SubtractFromToLoadList(Thing t, int count, bool sendMessageOnFinished = true) { if (leftToLoad == null) { return(0); } TransferableOneWay transferableOneWay = TransferableUtility.TransferableMatchingDesperate(t, leftToLoad, TransferAsOneMode.PodsOrCaravanPacking); if (transferableOneWay == null) { return(0); } if (transferableOneWay.CountToTransfer <= 0) { return(0); } int num = Mathf.Min(count, transferableOneWay.CountToTransfer); transferableOneWay.AdjustBy(-num); if (transferableOneWay.CountToTransfer <= 0) { leftToLoad.Remove(transferableOneWay); } if (sendMessageOnFinished && !AnyInGroupHasAnythingLeftToLoad) { CompShuttle comp = parent.GetComp <CompShuttle>(); if (comp == null || comp.AllRequiredThingsLoaded) { if (Props.max1PerGroup) { Messages.Message("MessageFinishedLoadingTransporterSingle".Translate(), parent, MessageTypeDefOf.TaskCompletion); } else { Messages.Message("MessageFinishedLoadingTransporters".Translate(), parent, MessageTypeDefOf.TaskCompletion); } } } return(num); }
public static void SendAway(Thing shuttle, bool dropEverything) { CompShuttle compShuttle = shuttle.TryGetComp <CompShuttle>(); CompTransporter compTransporter = shuttle.TryGetComp <CompTransporter>(); if (shuttle.Spawned) { if (dropEverything && compTransporter.LoadingInProgressOrReadyToLaunch) { compTransporter.CancelLoad(); } if (!compTransporter.LoadingInProgressOrReadyToLaunch) { TransporterUtility.InitiateLoading(Gen.YieldSingle(compTransporter)); } compShuttle.Send(); } else if (shuttle.ParentHolder is Thing && ((Thing)shuttle.ParentHolder).def == ThingDefOf.ShuttleIncoming) { compShuttle.leaveASAP = true; } }
public override IEnumerable <Gizmo> CompGetGizmosExtra() { foreach (Gizmo item in base.CompGetGizmosExtra()) { yield return(item); } CompShuttle shuttleComp = parent.TryGetComp <CompShuttle>(); if (LoadingInProgressOrReadyToLaunch && CanTryLaunch) { Command_Action command_Action = new Command_Action(); command_Action.defaultLabel = "CommandLaunchGroup".Translate(); command_Action.defaultDesc = "CommandLaunchGroupDesc".Translate(); command_Action.icon = LaunchCommandTex; command_Action.alsoClickIfOtherInGroupClicked = false; if (shuttleComp != null && shuttleComp.IsMissionShuttle && !shuttleComp.AllRequiredThingsLoaded) { command_Action.Disable("ShuttleRequiredItemsNotSatisfied".Translate()); } command_Action.action = delegate { if (AnyInGroupHasAnythingLeftToLoad) { Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmSendNotCompletelyLoadedPods".Translate(FirstThingLeftToLoadInGroup.LabelCapNoCount, FirstThingLeftToLoadInGroup), StartChoosingDestination)); } else if (shuttleComp != null && shuttleComp.IsMissionShuttle) { TransportPodsArrivalAction_Shuttle arrivalAction = new TransportPodsArrivalAction_Shuttle((MapParent)shuttleComp.missionShuttleTarget) { missionShuttleHome = shuttleComp.missionShuttleHome, missionShuttleTarget = shuttleComp.missionShuttleTarget, sendAwayIfQuestFinished = shuttleComp.sendAwayIfQuestFinished, questTags = parent.questTags }; TryLaunch((parent.Tile == shuttleComp.missionShuttleTarget.Tile) ? shuttleComp.missionShuttleHome.Tile : shuttleComp.missionShuttleTarget.Tile, arrivalAction); } else { StartChoosingDestination(); } }; if (!AllInGroupConnectedToFuelingPort) { command_Action.Disable("CommandLaunchGroupFailNotConnectedToFuelingPort".Translate()); } else if (!AllFuelingPortSourcesInGroupHaveAnyFuel) { command_Action.Disable("CommandLaunchGroupFailNoFuel".Translate()); } else if (AnyInGroupIsUnderRoof) { command_Action.Disable("CommandLaunchGroupFailUnderRoof".Translate()); } yield return(command_Action); } if (shuttleComp == null || !shuttleComp.permitShuttle) { yield break; } yield return(new Command_Action { defaultLabel = "CommandShuttleDismiss".Translate(), defaultDesc = "CommandShuttleDismissDesc".Translate(), icon = DismissTex, alsoClickIfOtherInGroupClicked = false, action = delegate { Transporter.innerContainer.TryDropAll(parent.Position, parent.Map, ThingPlaceMode.Near); if (!LoadingInProgressOrReadyToLaunch) { TransporterUtility.InitiateLoading(Gen.YieldSingle(Transporter)); } shuttleComp.Send(); } }); }
private bool CheckForErrors(List <Pawn> pawns) { if (!CanChangeAssignedThingsAfterStarting && !transferables.Any((TransferableOneWay x) => x.CountToTransfer != 0)) { if (transporters[0].Props.max1PerGroup) { Messages.Message("CantSendEmptyTransporterSingle".Translate(), MessageTypeDefOf.RejectInput, historical: false); } else { Messages.Message("CantSendEmptyTransportPods".Translate(), MessageTypeDefOf.RejectInput, historical: false); } return(false); } if (transporters[0].Props.max1PerGroup) { CompShuttle shuttle = transporters[0].Shuttle; if (shuttle != null && shuttle.requiredColonistCount > 0 && pawns.Count > shuttle.requiredColonistCount) { Messages.Message("TransporterSingleTooManyColonists".Translate(shuttle.requiredColonistCount), MessageTypeDefOf.RejectInput, historical: false); return(false); } } if (MassUsage > MassCapacity) { FlashMass(); if (transporters[0].Props.max1PerGroup) { Messages.Message("TooBigTransporterSingleMassUsage".Translate(), MessageTypeDefOf.RejectInput, historical: false); } else { Messages.Message("TooBigTransportersMassUsage".Translate(), MessageTypeDefOf.RejectInput, historical: false); } return(false); } Pawn pawn = pawns.Find((Pawn x) => !x.MapHeld.reachability.CanReach(x.PositionHeld, transporters[0].parent, PathEndMode.Touch, TraverseParms.For(TraverseMode.PassDoors)) && !transporters.Any((CompTransporter y) => y.innerContainer.Contains(x))); if (pawn != null) { if (transporters[0].Props.max1PerGroup) { Messages.Message("PawnCantReachTransporterSingle".Translate(pawn.LabelShort, pawn).CapitalizeFirst(), MessageTypeDefOf.RejectInput, historical: false); } else { Messages.Message("PawnCantReachTransporters".Translate(pawn.LabelShort, pawn).CapitalizeFirst(), MessageTypeDefOf.RejectInput, historical: false); } return(false); } Map map = transporters[0].parent.Map; for (int i = 0; i < transferables.Count; i++) { if (transferables[i].ThingDef.category != ThingCategory.Item) { continue; } int countToTransfer = transferables[i].CountToTransfer; int num = 0; if (countToTransfer <= 0) { continue; } for (int j = 0; j < transferables[i].things.Count; j++) { Thing t = transferables[i].things[j]; Pawn_CarryTracker pawn_CarryTracker = t.ParentHolder as Pawn_CarryTracker; if (map.reachability.CanReach(t.Position, transporters[0].parent, PathEndMode.Touch, TraverseParms.For(TraverseMode.PassDoors)) || transporters.Any((CompTransporter x) => x.innerContainer.Contains(t)) || (pawn_CarryTracker != null && pawn_CarryTracker.pawn.MapHeld.reachability.CanReach(pawn_CarryTracker.pawn.PositionHeld, transporters[0].parent, PathEndMode.Touch, TraverseParms.For(TraverseMode.PassDoors)))) { num += t.stackCount; if (num >= countToTransfer) { break; } } } if (num >= countToTransfer) { continue; } if (countToTransfer == 1) { if (transporters[0].Props.max1PerGroup) { Messages.Message("TransporterSingleItemIsUnreachableSingle".Translate(transferables[i].ThingDef.label), MessageTypeDefOf.RejectInput, historical: false); } else { Messages.Message("TransporterItemIsUnreachableSingle".Translate(transferables[i].ThingDef.label), MessageTypeDefOf.RejectInput, historical: false); } } else if (transporters[0].Props.max1PerGroup) { Messages.Message("TransporterSingleItemIsUnreachableMulti".Translate(countToTransfer, transferables[i].ThingDef.label), MessageTypeDefOf.RejectInput, historical: false); } else { Messages.Message("TransporterItemIsUnreachableMulti".Translate(countToTransfer, transferables[i].ThingDef.label), MessageTypeDefOf.RejectInput, historical: false); } return(false); } return(true); }