Exemple #1
0
        public static string TargetingLabelGetter(GlobalTargetInfo target, int tile, int maxLaunchDistance, IEnumerable <IThingHolder> pods, Action <int, TransportPodsArrivalAction> launchAction, CompLaunchable launchable)
        {
            if (!target.IsValid)
            {
                return(null);
            }
            if (Find.WorldGrid.TraversalDistanceBetween(tile, target.Tile) > maxLaunchDistance)
            {
                GUI.color = ColoredText.RedReadable;
                return("TransportPodDestinationBeyondMaximumRange".Translate());
            }
            IEnumerable <FloatMenuOption> source = ((launchable != null) ? launchable.GetTransportPodsFloatMenuOptionsAt(target.Tile) : GetOptionsForTile(target.Tile, pods, launchAction));

            if (!source.Any())
            {
                return(string.Empty);
            }
            if (source.Count() == 1)
            {
                if (source.First().Disabled)
                {
                    GUI.color = ColoredText.RedReadable;
                }
                return(source.First().Label);
            }
            MapParent mapParent;

            if ((mapParent = target.WorldObject as MapParent) != null)
            {
                return("ClickToSeeAvailableOrders_WorldObject".Translate(mapParent.LabelCap));
            }
            return("ClickToSeeAvailableOrders_Empty".Translate());
        }
Exemple #2
0
        public static bool ChoseWorldTarget(GlobalTargetInfo target, int tile, IEnumerable <IThingHolder> pods, int maxLaunchDistance, Action <int, TransportPodsArrivalAction> launchAction, CompLaunchable launchable)
        {
            if (!target.IsValid)
            {
                Messages.Message("MessageTransportPodsDestinationIsInvalid".Translate(), MessageTypeDefOf.RejectInput, historical: false);
                return(false);
            }
            if (Find.WorldGrid.TraversalDistanceBetween(tile, target.Tile) > maxLaunchDistance)
            {
                Messages.Message("TransportPodDestinationBeyondMaximumRange".Translate(), MessageTypeDefOf.RejectInput, historical: false);
                return(false);
            }
            IEnumerable <FloatMenuOption> source = ((launchable != null) ? launchable.GetTransportPodsFloatMenuOptionsAt(target.Tile) : GetOptionsForTile(target.Tile, pods, launchAction));

            if (!source.Any())
            {
                if (Find.World.Impassable(target.Tile))
                {
                    Messages.Message("MessageTransportPodsDestinationIsInvalid".Translate(), MessageTypeDefOf.RejectInput, historical: false);
                    return(false);
                }
                launchAction(target.Tile, null);
                return(true);
            }
            if (source.Count() == 1)
            {
                if (!source.First().Disabled)
                {
                    source.First().action();
                    return(true);
                }
                return(false);
            }
            Find.WindowStack.Add(new FloatMenu(source.ToList()));
            return(false);
        }