Example #1
0
 public virtual IEnumerable <FloatMenuOption> GetTransportPodsFloatMenuOptions(IEnumerable <IThingHolder> pods, CompLaunchable representative)
 {
 }
Example #2
0
 public static IEnumerable <FloatMenuOption> GetFloatMenuOptions(CompLaunchable representative, IEnumerable <IThingHolder> pods, Caravan caravan)
 {
     return(TransportPodsArrivalActionUtility.GetFloatMenuOptions(() => CanGiveTo(pods, caravan), () => new TransportPodsArrivalAction_GiveToCaravan(caravan), "GiveToCaravan".Translate(caravan.Label), representative, caravan.Tile));
 }
Example #3
0
 public override IEnumerable <FloatMenuOption> GetTransportPodsFloatMenuOptions(IEnumerable <IThingHolder> pods, CompLaunchable representative)
 {
     foreach (FloatMenuOption o in base.GetTransportPodsFloatMenuOptions(pods, representative))
     {
         yield return(o);
     }
     foreach (FloatMenuOption o2 in this.core.def.Worker.GetTransportPodsFloatMenuOptions(pods, representative, this))
     {
         yield return(o2);
     }
     yield break;
 }
Example #4
0
 private IEnumerable <FloatMenuOption> < GetTransportPodsFloatMenuOptions > __BaseCallProxy2(IEnumerable <IThingHolder> pods, CompLaunchable representative)
 {
     return(base.GetTransportPodsFloatMenuOptions(pods, representative));
 }
Example #5
0
 public static void Postfix(CompLaunchable __instance)
 {
     __instance.parent.BroadcastCompSignal(CompLaunchableAutoRebuild.AutoRebuildSignal);
 }
Example #6
0
        private bool ChoseWorldTarget(GlobalTargetInfo target)
        {
            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.MaxLaunchDistance(true))
                    {
                        Messages.Message("MessageFleetLaunchImpossible".Translate(), MessageSound.RejectInput);
                        return(false);
                    }
                    if (!(2 * num > ship.MaxLaunchDistance(true)))
                    {
                        canBomb = false;
                    }
                }
            }
            else
            {
                int num = Find.WorldGrid.TraversalDistanceBetween(tile, target.Tile);

                if (num > this.MaxLaunchDistance(this.LaunchAsFleet))
                {
                    Messages.Message("MessageTransportPodsDestinationIsTooFar".Translate(new object[]
                    {
                        CompLaunchable.FuelNeededToLaunchAtDist((float)num).ToString("0.#")
                    }), MessageSound.RejectInput);
                    return(false);
                }
                if (!(2 * num > this.MaxLaunchDistance(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 FactionBase && target.WorldObject.Faction != Faction.OfPlayer)
            {
                FactionBase factionBase = target.WorldObject as FactionBase;
                Find.WorldTargeter.closeWorldTabWhenFinished = false;
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                if (!target.WorldObject.Faction.HostileTo(Faction.OfPlayer))
                {
                    list.Add(new FloatMenuOption("VisitFactionBase".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);
                        JumpToTargetUtility.CloseWorldTab();
                    }, 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);
                    JumpToTargetUtility.CloseWorldTab();
                }, 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);
                    JumpToTargetUtility.CloseWorldTab();
                }, 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);
                    JumpToTargetUtility.CloseWorldTab();
                }, 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);
                        JumpToTargetUtility.CloseWorldTab();
                    }, 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);
        }
        public override void DeSpawn()
        {
            Map map = base.Map;

            base.DeSpawn();
            if (base.def.IsEdifice())
            {
                map.edificeGrid.DeRegister(this);
            }
            if (base.def.MakeFog)
            {
                map.fogGrid.Notify_FogBlockerRemoved(base.Position);
            }
            if (base.def.holdsRoof)
            {
                RoofCollapseCellsFinder.Notify_RoofHolderDespawned(this, map);
            }
            if (this.sustainerAmbient != null)
            {
                this.sustainerAmbient.End();
            }
            CellRect cellRect = this.OccupiedRect();

            for (int i = cellRect.minZ; i <= cellRect.maxZ; i++)
            {
                for (int j = cellRect.minX; j <= cellRect.maxX; j++)
                {
                    IntVec3     loc         = new IntVec3(j, 0, i);
                    MapMeshFlag mapMeshFlag = MapMeshFlag.Buildings;
                    if (base.def.coversFloor)
                    {
                        mapMeshFlag |= MapMeshFlag.Terrain;
                    }
                    if (base.def.Fillage == FillCategory.Full)
                    {
                        mapMeshFlag |= MapMeshFlag.Roofs;
                        mapMeshFlag |= MapMeshFlag.Snow;
                    }
                    map.mapDrawer.MapMeshDirty(loc, mapMeshFlag);
                    map.glowGrid.MarkGlowGridDirty(loc);
                }
            }
            map.listerBuildings.Remove(this);
            map.listerBuildingsRepairable.Notify_BuildingDeSpawned(this);
            if (base.def.leaveTerrain != null && Current.ProgramState == ProgramState.Playing)
            {
                CellRect.CellRectIterator iterator = this.OccupiedRect().GetIterator();
                while (!iterator.Done())
                {
                    map.terrainGrid.SetTerrain(iterator.Current, base.def.leaveTerrain);
                    iterator.MoveNext();
                }
            }
            map.designationManager.Notify_BuildingDespawned(this);
            if (!this.CanBeSeenOver())
            {
                map.exitMapGrid.Notify_LOSBlockerDespawned();
            }
            if (base.def.building.hasFuelingPort)
            {
                IntVec3        fuelingPortCell = FuelingPortUtility.GetFuelingPortCell(base.Position, base.Rotation);
                CompLaunchable compLaunchable  = FuelingPortUtility.LaunchableAt(fuelingPortCell, map);
                if (compLaunchable != null)
                {
                    compLaunchable.Notify_FuelingPortSourceDeSpawned();
                }
            }
            if (base.def.building.ai_combatDangerous)
            {
                AvoidGridMaker.Notify_CombatDangerousBuildingDespawned(this, map);
            }
        }
Example #8
0
        public static IEnumerable <FloatMenuOption> GetFloatMenuOptions <T>(Func <FloatMenuAcceptanceReport> acceptanceReportGetter, Func <T> arrivalActionGetter, string label, CompLaunchable representative, int destinationTile) where T : TransportPodsArrivalAction
        {
            FloatMenuAcceptanceReport rep = acceptanceReportGetter();

            if (rep.Accepted || !rep.FailReason.NullOrEmpty() || !rep.FailMessage.NullOrEmpty())
            {
                if (!rep.FailReason.NullOrEmpty())
                {
                    yield return(new FloatMenuOption(label + " (" + rep.FailReason + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null));
                }
                else
                {
                    yield return(new FloatMenuOption(label, delegate()
                    {
                        FloatMenuAcceptanceReport floatMenuAcceptanceReport = acceptanceReportGetter();
                        if (floatMenuAcceptanceReport.Accepted)
                        {
                            representative.TryLaunch(destinationTile, arrivalActionGetter());
                        }
                        else if (!floatMenuAcceptanceReport.FailMessage.NullOrEmpty())
                        {
                            Messages.Message(floatMenuAcceptanceReport.FailMessage, new GlobalTargetInfo(destinationTile), MessageTypeDefOf.RejectInput, false);
                        }
                    }, MenuOptionPriority.Default, null, null, 0f, null, null));
                }
            }
            yield break;
        }
Example #9
0
        public override IEnumerable <FloatMenuOption> GetTransportPodsFloatMenuOptions(IEnumerable <IThingHolder> pods, CompLaunchable representative)
        {
            //not now...
            yield break;

            foreach (var opt in base.GetTransportPodsFloatMenuOptions(pods, representative))
            {
                yield return(opt);
            }

            foreach (var opt in quest.GetTransportPodsFloatMenuOptions(pods, representative))
            {
                yield return(opt);
            }
        }
Example #10
0
        public override void ProcessInput(Event ev)
        {
            base.ProcessInput(ev);
            if (refuelables == null)
            {
                refuelables = new List <CompRefuelableMulti>();
            }
            if (!refuelables.Contains(refuelable))
            {
                refuelables.Add(refuelable);
            }
            int num = int.MaxValue;

            for (int i = 0; i < refuelables.Count; i++)
            {
                if ((int)refuelables[i].Props.fuelCapacity < num)
                {
                    num = (int)refuelables[i].Props.fuelCapacity;
                }
            }
            int startingValue = num / 2;

            for (int j = 0; j < refuelables.Count; j++)
            {
                if ((int)refuelables[j].TargetFuelLevel <= num)
                {
                    startingValue = (int)refuelables[j].TargetFuelLevel;
                    break;
                }
            }
            Func <int, string> textGetter = (!refuelable.parent.def.building.hasFuelingPort) ? ((Func <int, string>)((int x) => "SetTargetFuelLevel".Translate(x))) : ((Func <int, string>)((int x) => "SetPodLauncherTargetFuelLevel".Translate(x, CompLaunchable.MaxLaunchDistanceAtFuelLevel(x))));
            Dialog_Slider      window     = new Dialog_Slider(textGetter, 0, num, delegate(int value)
            {
                for (int k = 0; k < refuelables.Count; k++)
                {
                    refuelables[k].TargetFuelLevel = value;
                }
            }, startingValue);

            Find.WindowStack.Add(window);
        }
 public virtual IEnumerable <FloatMenuOption> GetTransportPodsFloatMenuOptions(IEnumerable <IThingHolder> pods, CompLaunchable representative)
 {
     for (int i = 0; i < this.comps.Count; i++)
     {
         foreach (FloatMenuOption f in this.comps[i].GetTransportPodsFloatMenuOptions(pods, representative))
         {
             yield return(f);
         }
     }
     yield break;
 }