예제 #1
0
        public static string TargetingLabelGetter(GlobalTargetInfo target, int tile, int maxLaunchDistance, IEnumerable <IThingHolder> pods, Action <int, TransportPodsArrivalAction> launchAction, CompLaunchablePawn launchable)
        {
            if (!target.IsValid)
            {
                return(null);
            }
            int num = Find.WorldGrid.TraversalDistanceBetween(tile, target.Tile, true, int.MaxValue);

            if (maxLaunchDistance > 0 && num > maxLaunchDistance)
            {
                GUI.color = ColorLibrary.RedReadable;
                return("TransportPodDestinationBeyondMaximumRange".Translate());
            }
            IEnumerable <FloatMenuOption> source = (launchable != null) ? launchable.GetTransportPodsFloatMenuOptionsAt(target.Tile) : CompLaunchable.GetOptionsForTile(target.Tile, pods, launchAction);

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

            if ((mapParent = (target.WorldObject as MapParent)) != null)
            {
                return("ClickToSeeAvailableOrders_WorldObject".Translate(mapParent.LabelCap));
            }
            return("ClickToSeeAvailableOrders_Empty".Translate());
        }
예제 #2
0
        public static bool ChoseWorldTarget(GlobalTargetInfo target, int tile, IEnumerable <IThingHolder> pods, int maxLaunchDistance, Action <int, TransportPodsArrivalAction> launchAction, CompLaunchablePawn launchable)
        {
            if (!target.IsValid)
            {
                Messages.Message("MessageTransportPodsDestinationIsInvalid".Translate(), MessageTypeDefOf.RejectInput, false);
                return(false);
            }
            int num = Find.WorldGrid.TraversalDistanceBetween(tile, target.Tile, true, int.MaxValue);

            if (maxLaunchDistance > 0 && num > maxLaunchDistance)
            {
                Messages.Message("TransportPodDestinationBeyondMaximumRange".Translate(), MessageTypeDefOf.RejectInput, false);
                return(false);
            }
            IEnumerable <FloatMenuOption> source = (launchable != null) ? launchable.GetTransportPodsFloatMenuOptionsAt(target.Tile) : CompLaunchable.GetOptionsForTile(target.Tile, pods, launchAction);

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