コード例 #1
0
        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;
            }
        }
コード例 #2
0
        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();
                }
            });
        }