Пример #1
0
 public override IEnumerable <FloatMenuOption> GetShuttleFloatMenuOptions(IEnumerable <IThingHolder> pods, Action <int, TransportPodsArrivalAction> launchAction)
 {
     if (!TransportPodsArrivalAction_LandInSpecificCell.CanLandInSpecificCell(pods, this))
     {
         yield break;
     }
     yield return(new FloatMenuOption("LandInExistingMap".Translate(Label), delegate
     {
         Map map = Map;
         Current.Game.CurrentMap = map;
         CameraJumper.TryHideWorld();
         Find.Targeter.BeginTargeting(TargetingParameters.ForDropPodsDestination(), delegate(LocalTargetInfo x)
         {
             launchAction(base.Tile, new TransportPodsArrivalAction_LandInSpecificCell(this, x.Cell, landInShuttle: true));
         }, delegate(LocalTargetInfo x)
         {
             RoyalTitlePermitWorker_CallShuttle.DrawShuttleGhost(x, Map);
         }, delegate(LocalTargetInfo x)
         {
             AcceptanceReport acceptanceReport = RoyalTitlePermitWorker_CallShuttle.ShuttleCanLandHere(x, Map);
             if (!acceptanceReport.Accepted)
             {
                 Messages.Message(acceptanceReport.Reason, new LookTargets(this), MessageTypeDefOf.RejectInput, historical: false);
             }
             return acceptanceReport.Accepted;
         }, null, null, CompLaunchable.TargeterMouseAttachment);
     }));
 }
        public IEnumerable <FloatMenuOption> GetTransportPodsFloatMenuOptionsAt(int tile, GlobalTargetInfo target)
        {
            MapParent mapParent = target.WorldObject as MapParent;

            if (mapParent != null && mapParent.HasMap)
            {
                yield return(new FloatMenuOption("TM_SelectTargetOnMap".Translate(mapParent.LabelCap), delegate
                {
                    Map map = mapParent.Map;
                    Current.Game.CurrentMap = map;
                    CameraJumper.TryHideWorld();
                    Find.Targeter.BeginTargeting(TargetingParameters.ForDropPodsDestination(), delegate(LocalTargetInfo x)
                    {
                        destCell = x.Cell;
                        destTile = map.Tile;
                        LaunchLightPod(destTile, destCell, null);
                    }, null);
                }));
            }

            if (!Find.World.Impassable(tile))
            {
                yield return(new FloatMenuOption("FormCaravanHere".Translate(), delegate
                {
                    LaunchLightPod(target.Tile, default(IntVec3), new TransportPodsArrivalAction_FormCaravan());
                }));
            }
        }
Пример #3
0
 public override IEnumerable <FloatMenuOption> GetTransportPodsFloatMenuOptions(IEnumerable <IThingHolder> pods, CompLaunchable representative)
 {
     foreach (FloatMenuOption o in base.GetTransportPodsFloatMenuOptions(pods, representative))
     {
         yield return(o);
     }
     if (TransportPodsArrivalAction_LandInSpecificCell.CanLandInSpecificCell(pods, this))
     {
         yield return(new FloatMenuOption("LandInExistingMap".Translate(new object[]
         {
             this.Label
         }), delegate()
         {
             Map myMap = representative.parent.Map;
             Map map = this.Map;
             Current.Game.CurrentMap = map;
             CameraJumper.TryHideWorld();
             Find.Targeter.BeginTargeting(TargetingParameters.ForDropPodsDestination(), delegate(LocalTargetInfo x)
             {
                 representative.TryLaunch(this.Tile, new TransportPodsArrivalAction_LandInSpecificCell(this.$this, x.Cell));
             }, null, delegate()
             {
                 if (Find.Maps.Contains(myMap))
                 {
                     Current.Game.CurrentMap = myMap;
                 }
             }, CompLaunchable.TargeterMouseAttachment);
         }, MenuOptionPriority.Default, null, null, 0f, null, null));
     }
     yield break;
 }
Пример #4
0
 public override IEnumerable <FloatMenuOption> GetTransportPodsFloatMenuOptions(IEnumerable <IThingHolder> pods, CompLaunchable representative)
 {
     foreach (FloatMenuOption transportPodsFloatMenuOption in base.GetTransportPodsFloatMenuOptions(pods, representative))
     {
         yield return(transportPodsFloatMenuOption);
     }
     if (!TransportPodsArrivalAction_LandInSpecificCell.CanLandInSpecificCell(pods, this))
     {
         yield break;
     }
     yield return(new FloatMenuOption("LandInExistingMap".Translate(Label), delegate
     {
         Map myMap = representative.parent.Map;
         Map map = Map;
         Current.Game.CurrentMap = map;
         CameraJumper.TryHideWorld();
         Find.Targeter.BeginTargeting(TargetingParameters.ForDropPodsDestination(), delegate(LocalTargetInfo x)
         {
             representative.TryLaunch(base.Tile, new TransportPodsArrivalAction_LandInSpecificCell(this, x.Cell, representative.parent.TryGetComp <CompShuttle>() != null));
         }, null, delegate
         {
             if (Find.Maps.Contains(myMap))
             {
                 Current.Game.CurrentMap = myMap;
             }
         }, CompLaunchable.TargeterMouseAttachment);
     }));
 }
Пример #5
0
        public static IEnumerable <FloatMenuOption> GetMapParent(MapParent mapparent, IEnumerable <IThingHolder> pods, CompLaunchableHelicopter representative, Caravan car)
        {
            /*
             * foreach (FloatMenuOption o in mapparent.GetFloatMenuOptions())
             * {
             *  yield return o;
             * }
             */

            if (TransportPodsArrivalAction_LandInSpecificCell.CanLandInSpecificCell(pods, mapparent))
            {
                yield return(new FloatMenuOption("LandInExistingMap".Translate(new object[]
                {
                    mapparent.Label
                }), delegate
                {
                    Map myMap;
                    if (car == null)
                    {
                        myMap = representative.parent.Map;
                    }
                    else
                    {
                        myMap = null;
                    }

                    Map map = mapparent.Map;
                    Current.Game.CurrentMap = map;
                    CameraJumper.TryHideWorld();
                    Find.Targeter.BeginTargeting(TargetingParameters.ForDropPodsDestination(), delegate(LocalTargetInfo x)
                    {
                        representative.TryLaunch(mapparent.Tile, new TransportPodsArrivalAction_LandInSpecificCell(mapparent, x.Cell), car);
                    }, null, delegate
                    {
                        if (myMap != null && Find.Maps.Contains(myMap))
                        {
                            Current.Game.CurrentMap = myMap;
                        }
                    }, CompLaunchable.TargeterMouseAttachment);
                }, MenuOptionPriority.Default, null, null, 0f, null, null));
            }
            yield break;
        }
Пример #6
0
        public override IEnumerable <FloatMenuOption> GetTransportPodsFloatMenuOptions(IEnumerable <IThingHolder> pods, CompLaunchable representative)
        {
            _003CGetTransportPodsFloatMenuOptions_003Ec__Iterator4 _003CGetTransportPodsFloatMenuOptions_003Ec__Iterator = (_003CGetTransportPodsFloatMenuOptions_003Ec__Iterator4) /*Error near IL_0038: stateMachine*/;

            using (IEnumerator <FloatMenuOption> enumerator = base.GetTransportPodsFloatMenuOptions(pods, representative).GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    FloatMenuOption o = enumerator.Current;
                    yield return(o);

                    /*Error: Unable to find new state assignment for yield return*/;
                }
            }
            if (TransportPodsArrivalAction_LandInSpecificCell.CanLandInSpecificCell(pods, this))
            {
                yield return(new FloatMenuOption("LandInExistingMap".Translate(Label), delegate
                {
                    _003CGetTransportPodsFloatMenuOptions_003Ec__Iterator4 _003CGetTransportPodsFloatMenuOptions_003Ec__Iterator2 = _003CGetTransportPodsFloatMenuOptions_003Ec__Iterator;
                    Map myMap = representative.parent.Map;
                    Map map = _003CGetTransportPodsFloatMenuOptions_003Ec__Iterator._0024this.Map;
                    Current.Game.CurrentMap = map;
                    CameraJumper.TryHideWorld();
                    Find.Targeter.BeginTargeting(TargetingParameters.ForDropPodsDestination(), delegate(LocalTargetInfo x)
                    {
                        representative.TryLaunch(_003CGetTransportPodsFloatMenuOptions_003Ec__Iterator2._0024this.Tile, new TransportPodsArrivalAction_LandInSpecificCell(_003CGetTransportPodsFloatMenuOptions_003Ec__Iterator2._0024this, x.Cell));
                    }, null, delegate
                    {
                        if (Find.Maps.Contains(myMap))
                        {
                            Current.Game.CurrentMap = myMap;
                        }
                    }, CompLaunchable.TargeterMouseAttachment);
                }));

                /*Error: Unable to find new state assignment for yield return*/;
            }
            yield break;
IL_0160:
            /*Error near IL_0161: Unexpected return in MoveNext()*/;
        }
 public static IEnumerable <FloatMenuOption> GetMapParent(
     MapParent mapparent,
     IEnumerable <IThingHolder> pods,
     CompLaunchableHelicopter representative,
     Caravan car)
 {
     if (TransportPodsArrivalAction_LandInSpecificCell.CanLandInSpecificCell(pods, mapparent))
     {
         yield return(new FloatMenuOption("LandInExistingMap".Translate((object)mapparent.Label), (Action)(() =>
         {
             Map myMap = car != null ? (Map)null : representative.parent.Map;
             Current.Game.CurrentMap = mapparent.Map;
             CameraJumper.TryHideWorld();
             Find.Targeter.BeginTargeting(TargetingParameters.ForDropPodsDestination(), (Action <LocalTargetInfo>)(x => representative.TryLaunch(mapparent.Tile, (TransportPodsArrivalAction) new TransportPodsArrivalAction_LandInSpecificCell(mapparent, x.Cell), car)), (Pawn)null, (Action)(() =>
             {
                 if (myMap == null || !Find.Maps.Contains(myMap))
                 {
                     return;
                 }
                 Current.Game.CurrentMap = myMap;
             }), CompLaunchable.TargeterMouseAttachment);
         }), MenuOptionPriority.Default, (Action)null, (Thing)null, 0.0f, (Func <Rect, bool>)null, (WorldObject)null));
     }
 }
Пример #8
0
        private bool ChoseWorldTarget(GlobalTargetInfo target)
        {
            if (this.parentLandedShip != null)
            {
                this.parentLandedShip.isTargeting = true;
            }
            this.isTargeting = true;
            int tile;

            if (this.parentLandedShip != null)
            {
                tile = this.parentLandedShip.Tile;
            }
            else
            {
                tile = this.Map.Tile;
            }
            bool canBomb = true;

            if (!target.IsValid)
            {
                Messages.Message("MessageTransportPodsDestinationIsInvalid".Translate(), MessageSound.RejectInput);
                return(false);
            }
            if (this.LaunchAsFleet)
            {
                List <int> distances = new List <int>();
                for (int i = 0; i < DropShipUtility.currentShipTracker.ShipsInFleet(this.fleetID).Count; i++)
                {
                    ShipBase ship = DropShipUtility.currentShipTracker.ShipsInFleet(this.fleetID)[i];
                    if (ship.compShip.cargoLoadingActive)
                    {
                        Messages.Message("MessageFleetLaunchImpossible".Translate(), MessageSound.RejectInput);
                        return(false);
                    }
                    int num = (Find.WorldGrid.TraversalDistanceBetween(tile, target.Tile));
                    if (num > ship.MaxLaunchDistanceEverPossible(true))
                    {
                        Messages.Message("MessageFleetLaunchImpossible".Translate(), MessageSound.RejectInput);
                        return(false);
                    }
                    if (!(2 * num > ship.MaxLaunchDistanceEverPossible(true)))
                    {
                        canBomb = false;
                    }
                }
            }
            else
            {
                int num = Find.WorldGrid.TraversalDistanceBetween(tile, target.Tile);

                if (num > this.MaxLaunchDistanceEverPossible(this.LaunchAsFleet))
                {
                    Messages.Message("MessageTransportPodsDestinationIsTooFar".Translate(new object[]
                    {
                        CompLaunchable.FuelNeededToLaunchAtDist((float)num).ToString("0.#")
                    }), MessageSound.RejectInput);
                    return(false);
                }
                if (!(2 * num > this.MaxLaunchDistanceEverPossible(true)))
                {
                    canBomb = false;
                }
            }

            MapParent mapParent = target.WorldObject as MapParent;

            if (mapParent != null && mapParent.HasMap)
            {
                Map myMap = this.Map;
                Map map   = mapParent.Map;
                Current.Game.VisibleMap = map;
                Targeter targeter           = Find.Targeter;
                Action   actionWhenFinished = delegate
                {
                    if (Find.Maps.Contains(myMap))
                    {
                        Current.Game.VisibleMap = myMap;
                    }
                };
                targeter.BeginTargeting(TargetingParameters.ForDropPodsDestination(), delegate(LocalTargetInfo x)
                {
                    if (!this.ReadyForTakeoff || this.LaunchAsFleet && DropShipUtility.currentShipTracker.ShipsInFleet(this.fleetID).Any(s => !s.ReadyForTakeoff))
                    {
                        return;
                    }
                    this.TryLaunch(x.ToGlobalTargetInfo(map), PawnsArriveMode.Undecided, TravelingShipArrivalAction.EnterMapFriendly);
                }, null, actionWhenFinished, DropShipUtility.TargeterShipAttachment);
                return(true);
            }

            if (target.WorldObject is Settlement || target.WorldObject is Site)
            {
                Find.WorldTargeter.closeWorldTabWhenFinished = false;
                MapParent localMapParent    = target.WorldObject as MapParent;
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                if (!target.WorldObject.Faction.HostileTo(Faction.OfPlayer))
                {
                    list.Add(new FloatMenuOption("VisitSettlement".Translate(new object[]
                    {
                        target.WorldObject.Label
                    }), delegate
                    {
                        if (!this.ReadyForTakeoff || this.LaunchAsFleet && DropShipUtility.currentShipTracker.ShipsInFleet(this.fleetID).Any(s => !s.ReadyForTakeoff))
                        {
                            return;
                        }
                        this.TryLaunch(target, PawnsArriveMode.Undecided, TravelingShipArrivalAction.StayOnWorldMap);
                        CameraJumper.TryHideWorld();
                    }, MenuOptionPriority.Default, null, null, 0f, null, null));
                }
                list.Add(new FloatMenuOption("DropAtEdge".Translate(), delegate
                {
                    if (!this.ReadyForTakeoff || this.LaunchAsFleet && DropShipUtility.currentShipTracker.ShipsInFleet(this.fleetID).Any(s => !s.ReadyForTakeoff))
                    {
                        return;
                    }
                    this.TryLaunch(target, PawnsArriveMode.EdgeDrop, TravelingShipArrivalAction.EnterMapFriendly);
                    CameraJumper.TryHideWorld();
                }, MenuOptionPriority.Default, null, null, 0f, null, null));
                //list.Add(new FloatMenuOption("DropInCenter".Translate(), delegate
                //{
                //    if (!this.ReadyForTakeoff || this.LaunchAsFleet && DropShipUtility.currentShipTracker.ShipsInFleet(this.fleetID).Any(s => !s.ReadyForTakeoff))
                //    {
                //        return;
                //    }
                //    this.TryLaunch(target, PawnsArriveMode.CenterDrop, TravelingShipArrivalAction.EnterMapFriendly);
                //    CameraJumper.TryHideWorld();
                //}, MenuOptionPriority.Default, null, null, 0f, null, null));

                list.Add(new FloatMenuOption("AttackFactionBaseAerial".Translate(), delegate
                {
                    if (!this.ReadyForTakeoff || this.LaunchAsFleet && DropShipUtility.currentShipTracker.ShipsInFleet(this.fleetID).Any(s => !s.ReadyForTakeoff))
                    {
                        return;
                    }
                    this.TryLaunch(target, PawnsArriveMode.CenterDrop, TravelingShipArrivalAction.EnterMapAssault);
                    CameraJumper.TryHideWorld();
                }, MenuOptionPriority.Default, null, null, 0f, null, null));


                if (canBomb && (DropShipUtility.currentShipTracker.ShipsInFleet(this.fleetID).Any(x => x.installedTurrets.Any(y => y.Key.slotType == WeaponSystemType.Bombing && y.Value != null))) || this.loadedBombs.Any())
                {
                    list.Add(new FloatMenuOption("BombFactionBase".Translate(), delegate
                    {
                        if (!this.ReadyForTakeoff || this.LaunchAsFleet && DropShipUtility.currentShipTracker.ShipsInFleet(this.fleetID).Any(s => !s.ReadyForTakeoff))
                        {
                            return;
                        }
                        this.performBombingRun = true;
                        this.TryLaunch(target, PawnsArriveMode.CenterDrop, TravelingShipArrivalAction.BombingRun);
                        CameraJumper.TryHideWorld();
                    }, MenuOptionPriority.Default, null, null, 0f, null, null));
                }


                Find.WindowStack.Add(new FloatMenu(list));
                return(true);
            }
            if (Find.World.Impassable(target.Tile))
            {
                Messages.Message("MessageTransportPodsDestinationIsInvalid".Translate(), MessageSound.RejectInput);
                return(false);
            }

            this.TryLaunch(target, PawnsArriveMode.Undecided, TravelingShipArrivalAction.StayOnWorldMap);
            return(true);
        }
Пример #9
0
        public override IEnumerable <Gizmo> GetGizmos()
        {
            foreach (Gizmo baseGizmo in base.GetGizmos())
            {
                yield return(baseGizmo);
            }
            yield return(new Command_Toggle()
            {
                defaultLabel = "RimSpawners_Pause".Translate(),
                defaultDesc = "RimSpawners_PauseDesc".Translate(),
                icon = ContentFinder <Texture2D> .Get("UI/Commands/Halt"),
                isActive = () => cusp.Paused,
                toggleAction = () =>
                {
                    cusp.Paused = !cusp.Paused;
                }
            });

            yield return(new Command_Toggle()
            {
                defaultLabel = "RimSpawners_DropPodToggle".Translate(),
                defaultDesc = "RimSpawners_DropPodToggleDesc".Translate(),
                icon = ContentFinder <Texture2D> .Get("UI/Commands/SelectAllTransporters"),
                isActive = () => cusp.SpawnInDropPods,
                toggleAction = () =>
                {
                    cusp.SpawnInDropPods = !cusp.SpawnInDropPods;
                    if (!cusp.SpawnInDropPods)
                    {
                        cusp.dropSpot = IntVec3.Invalid;
                    }
                }
            });

            yield return(new Command_Action()
            {
                defaultLabel = "RimSpawners_DropSpotSelect".Translate(),
                defaultDesc = "RimSpawners_DropSpotSelectDesc".Translate(),
                icon = ContentFinder <Texture2D> .Get("Things/Special/DropPod"),
                action = () =>
                {
                    TargetingParameters targetParams = TargetingParameters.ForDropPodsDestination();
                    Find.Targeter.BeginTargeting(targetParams, delegate(LocalTargetInfo target)
                    {
                        List <VanometricFabricator> spawners = Find.Selector.SelectedObjects.OfType <VanometricFabricator>().ToList();
                        foreach (VanometricFabricator spawner in spawners)
                        {
                            spawner.cusp.dropSpot = target.Cell;
                        }
                    });
                }
            });

            yield return(new Command_Toggle()
            {
                defaultLabel = "RimSpawners_SpawnAllAtOnce".Translate(),
                defaultDesc = "RimSpawners_SpawnAllAtOnceDesc".Translate(),
                icon = ContentFinder <Texture2D> .Get("UI/Commands/Attack"),
                isActive = () => cusp.SpawnAllAtOnce,
                toggleAction = () =>
                {
                    cusp.SpawnAllAtOnce = !cusp.SpawnAllAtOnce;
                }
            });

            yield return(new Command_Action()
            {
                defaultLabel = "RimSpawners_KillSwitch".Translate(),
                defaultDesc = "RimSpawners_KillSwitchDesc".Translate(),
                icon = ContentFinder <Texture2D> .Get("UI/Commands/Detonate"),
                action = RemoveAllSpawnedPawns
            });

            yield return(new Command_Action()
            {
                defaultLabel = "RimSpawners_Reset".Translate(),
                defaultDesc = "RimSpawners_ResetDesc".Translate(),
                icon = ContentFinder <Texture2D> .Get("UI/Commands/TryReconnect"),
                action = () =>
                {
                    SetChosenKind(null);
                }
            });
        }
        private bool ChoseWorldTarget(GlobalTargetInfo target)
        {
            Cthulhu.Utility.DebugReport("ChooseWorldTarget Called");
            if (!this.LoadingInProgressOrReadyToLaunch)
            {
                return(true);
            }
            if (!target.IsValid)
            {
                Messages.Message("MessageTransportPodsDestinationIsInvalid".Translate(), MessageTypeDefOf.RejectInput);
                return(false);
            }
            int num = Find.WorldGrid.TraversalDistanceBetween(this.parent.Map.Tile, target.Tile);

            if (num > this.MaxLaunchDistance)
            {
                //Messages.Message("MessageTransportPodsDestinationIsTooFar".Translate(new object[]
                //{
                //    CompLaunchable.FuelNeededToLaunchAtDist((float)num).ToString("0.#")
                //}), MessageTypeDefOf.RejectInput);
                return(false);
            }
            MapParent mapParent = target.WorldObject as MapParent;

            if (mapParent != null && mapParent.HasMap)
            {
                Map myMap = this.parent.Map;
                Map map   = mapParent.Map;
                Current.Game.CurrentMap = map;
                Targeter arg_139_0 = Find.Targeter;

                void ActionWhenFinished()
                {
                    if (Find.Maps.Contains(myMap))
                    {
                        Current.Game.CurrentMap = myMap;
                    }
                }

                arg_139_0.BeginTargeting(TargetingParameters.ForDropPodsDestination(), delegate(LocalTargetInfo x)
                {
                    if (!this.LoadingInProgressOrReadyToLaunch)
                    {
                        Cthulhu.Utility.DebugReport("ChooseTarget Exited - LoadingInProgressOrReadyToLaunch");
                        return;
                    }
                    this.TryLaunch(x.ToGlobalTargetInfo(map), PawnsArrivalModeDefOf.EdgeDrop, false);
                }, null, ActionWhenFinished, CompLaunchablePawn.TargeterMouseAttachment);
                return(true);
            }
            if (target.WorldObject is Settlement && target.WorldObject.Faction != Faction.OfPlayer)
            {
                Find.WorldTargeter.closeWorldTabWhenFinished = false;
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                if (!target.WorldObject.Faction.HostileTo(Faction.OfPlayer))
                {
                    list.Add(new FloatMenuOption("VisitFactionBase".Translate(
                                                     target.WorldObject.Label
                                                     ), delegate
                    {
                        if (!this.LoadingInProgressOrReadyToLaunch)
                        {
                            return;
                        }
                        this.TryLaunch(target, PawnsArrivalModeDefOf.EdgeDrop, false);
                        CameraJumper.TryHideWorld();
                    }, MenuOptionPriority.Default, null, null, 0f, null, null));
                }
                list.Add(new FloatMenuOption("DropAtEdge".Translate(), delegate
                {
                    if (!this.LoadingInProgressOrReadyToLaunch)
                    {
                        return;
                    }
                    this.TryLaunch(target, PawnsArrivalModeDefOf.EdgeDrop, true);
                    CameraJumper.TryHideWorld();
                }, MenuOptionPriority.Default, null, null, 0f, null, null));
                list.Add(new FloatMenuOption("DropInCenter".Translate(), delegate
                {
                    if (!this.LoadingInProgressOrReadyToLaunch)
                    {
                        return;
                    }
                    this.TryLaunch(target, PawnsArrivalModeDefOf.CenterDrop, true);
                    CameraJumper.TryHideWorld();
                }, MenuOptionPriority.Default, null, null, 0f, null, null));
                Find.WindowStack.Add(new FloatMenu(list));
                return(true);
            }
            else // if (Find.World.Impassable(target.Tile))
            {
                Messages.Message("MessageTransportPodsDestinationIsInvalid".Translate(), MessageTypeDefOf.RejectInput);
                return(false);
            }
            //this.TryLaunch(target, PawnsArrivalModeDefOf.Undecided, false);
            //return true;
        }