public override void Arrived(int tile)
 {
     LongEventHandler.QueueLongEvent(delegate()
     {
         Map map            = GetOrGenerateMapUtility.GetOrGenerateMap(tile, null);      //MAP INDEX BUG
         TaggedString label = "LetterLabelCaravanEnteredEnemyBase".Translate();
         TaggedString text  = "LetterTransportPodsLandedInEnemyBase".Translate(parent.Label).CapitalizeFirst();
         if (parent is Settlement settlement)
         {
             SettlementUtility.AffectRelationsOnAttacked(settlement, ref text);
         }
         if (!parent.HasMap)
         {
             Find.TickManager.Notify_GeneratedPotentiallyHostileMap();
             PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(map.mapPawns.AllPawns, ref label, ref text, "LetterRelatedPawnsInMapWherePlayerLanded".Translate(Faction.OfPlayer.def.pawnsPlural), true, true);
         }
         AerialVehicleInFlight aerialVehicle = vehicle.GetAerialVehicle();
         CameraJumper.TryJump(map.Center, map);
         StrafeTargeter.Instance.BeginTargeting(vehicle, vehicle.CompVehicleLauncher.launchProtocol, delegate(IntVec3 start, IntVec3 end)
         {
             VehicleSkyfaller_FlyOver skyfaller = VehicleSkyfallerMaker.MakeSkyfallerFlyOver(vehicle.CompVehicleLauncher.Props.skyfallerStrafing, vehicle, start, end);
             skyfaller.aerialVehicle            = aerialVehicle;
             Thing thing = GenSpawn.Spawn(skyfaller, start, parent.Map, Rot8.North);                     //REDO - Other rotations?
         }, null, null, null, true);
         aerialVehicle.Destroy();
     }, "GeneratingMap", false, null, true);
 }
Example #2
0
 protected override void LeaveMap()
 {
     if (!createWorldObject)
     {
         base.LeaveMap();
         return;
     }
     if (flightPath.Any(node => node.tile < 0))
     {
         Log.Error("AerialVehicle left the map but has a flight path Tile that is invalid. Removing node from path.");
         flightPath.RemoveAll(node => node.tile < 0);
         if (flightPath.NullOrEmpty())
         {
             //REDO - Handle better here
             return;
         }
     }
     Messages.Message($"{vehicle.LabelShort} LEFT", MessageTypeDefOf.PositiveEvent);
     if (createWorldObject)
     {
         AerialVehicleInFlight flyingVehicle = (AerialVehicleInFlight)WorldObjectMaker.MakeWorldObject(WorldObjectDefOfVehicles.AerialVehicle);
         flyingVehicle.vehicle = vehicle;
         flyingVehicle.Tile    = Map.Tile;
         flyingVehicle.SetFaction(vehicle.Faction);
         flyingVehicle.OrderFlyToTiles(new List <FlightNode>(flightPath), Find.WorldGrid.GetTileCenter(Map.Tile), arrivalAction);
         if (orderRecon)
         {
             flyingVehicle.flightPath.ReconCircleAt(flightPath.LastOrDefault().tile);
         }
         flyingVehicle.Initialize();
         Find.WorldObjects.Add(flyingVehicle);
     }
     Destroy(DestroyMode.Vanish);
 }
Example #3
0
        /// <summary>
        /// Trade dialog for AerialVehicle located on a Settlement
        /// </summary>
        /// <param name="vehicle"></param>
        /// <param name="settlement"></param>
        public static Command ShuttleTradeCommand(AerialVehicleInFlight vehicle, Settlement settlement)
        {
            Pawn           bestNegotiator = WorldHelper.FindBestNegotiator(vehicle.vehicle, settlement.Faction, settlement.TraderKind);
            Command_Action command_Action = new Command_Action
            {
                defaultLabel = "CommandTrade".Translate(),
                defaultDesc  = "CommandTradeDesc".Translate(),
                icon         = VehicleTex.TradeCommandTex,
                action       = delegate()
                {
                    if (settlement != null && settlement.CanTradeNow)
                    {
                        Find.WindowStack.Add(new Dialog_Trade(bestNegotiator, settlement, false));
                        PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter_Send(settlement.Goods.OfType <Pawn>(), "LetterRelatedPawnsTradingWithSettlement".Translate(Faction.OfPlayer.def.pawnsPlural), LetterDefOf.NeutralEvent, false, true);
                    }
                }
            };

            if (bestNegotiator is null)
            {
                if (settlement.TraderKind != null && settlement.TraderKind.permitRequiredForTrading != null && !vehicle.vehicle.AllPawnsAboard.Any((Pawn p) => p.royalty != null && p.royalty.HasPermit(settlement.TraderKind.permitRequiredForTrading, settlement.Faction)))
                {
                    command_Action.Disable("CommandTradeFailNeedPermit".Translate(settlement.TraderKind.permitRequiredForTrading.LabelCap));
                }
                else
                {
                    command_Action.Disable("CommandTradeFailNoNegotiator".Translate());
                }
            }
            if (bestNegotiator != null && bestNegotiator.skills.GetSkill(SkillDefOf.Social).TotallyDisabled)
            {
                command_Action.Disable("CommandTradeFailSocialDisabled".Translate());
            }
            return(command_Action);
        }
Example #4
0
        public static void Settle(AerialVehicleInFlight aerialVehicle)
        {
            Faction faction = aerialVehicle.Faction;

            if (faction != Faction.OfPlayer)
            {
                Log.Error("Cannot settle with non-player faction.");
                return;
            }
            Settlement newHome = SettleUtility.AddNewHome(aerialVehicle.Tile, faction);

            LongEventHandler.QueueLongEvent(delegate()
            {
                GetOrGenerateMapUtility.GetOrGenerateMap(aerialVehicle.Tile, Find.World.info.initialMapSize, null);
            }, "GeneratingMap", true, new Action <Exception>(GameAndMapInitExceptionHandlers.ErrorWhileGeneratingMap), true);
            LongEventHandler.QueueLongEvent(delegate()
            {
                IntVec3 landingCell = GetLandingCell(newHome.Map, aerialVehicle);
                //AerialVehicleArrivalAction_LandSpecificCell arrivalAction = new AerialVehicleArrivalAction_LandSpecificCell(aerialVehicle.vehicle, newHome, aerialVehicle.Tile,
                //	aerialVehicle.vehicle.CompVehicleLauncher.launchProtocols.FirstOrDefault(), landingCell, Rot4.North);
                //arrivalAction.Arrived(aerialVehicle.Tile);
                VehiclePawn vehicle = (VehiclePawn)GenSpawn.Spawn(aerialVehicle.vehicle, landingCell, newHome.Map);
                CameraJumper.TryJump(vehicle);
                aerialVehicle.Destroy();
            }, "SpawningColonists", true, new Action <Exception>(GameAndMapInitExceptionHandlers.ErrorWhileGeneratingMap), true);
        }
Example #5
0
 /// <summary>
 /// Strafe option for combat aerial vehicles targeting open maps
 /// </summary>
 /// <param name="vehicle"></param>
 /// <param name="parent"></param>
 public static FloatMenuOption StrafeFloatMenuOption(VehiclePawn vehicle, MapParent parent)
 {
     if (parent.EnterCooldownBlocksEntering())
     {
         return(new FloatMenuOption($"{"AerialStrafeRun".Translate(parent.Label)} ({"EnterCooldownBlocksEntering".Translate()})", null));
     }
     return(new FloatMenuOption("AerialStrafeRun".Translate(parent.Label), delegate()
     {
         if (vehicle.Spawned)
         {
             vehicle.CompVehicleLauncher.TryLaunch(parent.Tile, null, true);
         }
         else
         {
             AerialVehicleInFlight aerial = VehicleWorldObjectsHolder.Instance.AerialVehicleObject(vehicle);
             if (aerial is null)
             {
                 Log.Error($"Attempted to launch into existing map where CurrentMap is null and no AerialVehicle with {vehicle.Label} exists.");
                 return;
             }
             List <FlightNode> flightPath = new List <FlightNode>(LaunchTargeter.FlightPath);
             aerial.OrderFlyToTiles(flightPath, aerial.DrawPos);
             aerial.flightPath.ReconCircleAt(parent.Tile);
             vehicle.CompVehicleLauncher.inFlight = true;
         }
     }));
 }
Example #6
0
        public static IEnumerable <AirDefense> CheckNearbyObjects(AerialVehicleInFlight aerialVehicle, float speedPctPerTick)
        {
            float   halfTicksPerTileTraveled = Ext_Math.RoundTo(speedPctPerTick * 100, 0.001f);
            Vector3 start = aerialVehicle.DrawPos;

            for (int i = 0; i < aerialVehicle.flightPath.Path.Count; i++)
            {
                int     destination    = aerialVehicle.flightPath[i].tile;
                Vector3 destinationPos = Find.WorldGrid.GetTileCenter(destination);
                Vector3 position       = start;
                for (float transition = 0; transition < 1; transition += halfTicksPerTileTraveled)
                {
                    Vector3 partition = Vector3.Slerp(position, destinationPos, transition);
                    foreach (KeyValuePair <WorldObject, AirDefense> defenseCache in airDefenseCache)
                    {
                        float distance = Ext_Math.SphericalDistance(partition, defenseCache.Key.DrawPos);
                        if (distance < defenseCache.Value.MaxDistance)
                        {
                            yield return(defenseCache.Value);
                        }
                    }
                }
                start = destinationPos;
            }
        }
Example #7
0
        public static void DrawAltitudeMeter(AerialVehicleInFlight aerialVehicle)
        {
            try
            {
                Rect rect       = new Rect(AltitudeScreenPos, MeterSize);
                Rect windowRect = new Rect(rect)
                {
                    width  = rect.width * 3 + 10,
                    height = WindowHeight + InfoWindoHeight
                };
                float elevation = (MeterSize.y - (aerialVehicle.Elevation / MaximumAltitude * MeterSize.y)).Clamp(MaxAltitudeScreenHeight, MeterSize.y - MinAltitudeScreenHeight);
                Find.WindowStack.ImmediateWindow(aerialVehicle.GetHashCode(), windowRect, WindowLayer.GameUI, delegate()
                {
                    var anchor = Text.Anchor;
                    var font   = Text.Font;
                    var color  = GUI.color;

                    Rect viewRect     = rect.AtZero();
                    windowRect.x      = rect.width + 5;
                    windowRect.y      = 5;
                    windowRect.height = WindowHeight;

                    GUI.BeginScrollView(windowRect, new Vector2(windowRect.x, elevation - WindowHeight / 2), viewRect, GUIStyle.none, GUIStyle.none);

                    GUI.DrawTexture(viewRect, VehicleTex.AltitudeMeter);

                    if (elevation <= MaximumAltitude)
                    {
                        Rect lineRect = new Rect(0, windowRect.y + elevation, viewRect.width, 1f);
                        GUI.DrawTexture(lineRect, elevation >= MeterSize.y / 2 ? BaseContent.BlackTex : BaseContent.WhiteTex);
                    }

                    GUI.color = WindowBGBorderColor;
                    Widgets.DrawLineHorizontal(0, windowRect.y + elevation + MeterSize.y / 2, viewRect.width);
                    Widgets.DrawLineVertical(viewRect.width, windowRect.y, MeterSize.y);
                    GUI.color = color;

                    Text.Font        = GameFont.Small;
                    float textHeight = Text.CalcHeight(aerialVehicle.Elevation.ToString(), viewRect.width);
                    Rect labelRect   = new Rect(viewRect.width + 5, windowRect.y + elevation - textHeight / 2, viewRect.width - 5, textHeight);
                    Widgets.DrawMenuSection(labelRect);

                    Text.Font            = GameFont.Tiny;
                    Text.Anchor          = TextAnchor.MiddleCenter;
                    int elevationRounded = Mathf.RoundToInt(aerialVehicle.Elevation);
                    GUI.Label(labelRect, elevationRounded.ToString(), Text.CurFontStyle);

                    GUI.EndScrollView(false);

                    Text.Anchor = anchor;
                    Text.Font   = font;
                    GUI.color   = color;
                }, true, false, 0);
            }
            catch (Exception ex)
            {
                SmashLog.Error($"Exception thrown while trying to draw <type>AltitudeMeter</type> for {aerialVehicle?.Label ?? "NULL"}. Exception=\"{ex.Message}\"");
            }
        }
        public override void VehicleArrived(AerialVehicleInFlight aerialVehicle, LaunchProtocol launchProtocol, Map map)
        {
            Rot4    vehicleRotation             = launchProtocol.landingProperties.forcedRotation ?? Rot4.Random;
            IntVec3 cell                        = CellFinderExtended.RandomCenterCell(map, (IntVec3 cell) => !MapHelper.VehicleBlockedInPosition(aerialVehicle.vehicle, Current.Game.CurrentMap, cell, vehicleRotation));
            VehicleSkyfaller_Arriving skyfaller = (VehicleSkyfaller_Arriving)ThingMaker.MakeThing(aerialVehicle.vehicle.CompVehicleLauncher.Props.skyfallerIncoming);

            skyfaller.vehicle = aerialVehicle.vehicle;
            GenSpawn.Spawn(skyfaller, cell, map, vehicleRotation);
        }
Example #9
0
 public override void VehicleArrived(AerialVehicleInFlight aerialVehicle, LaunchProtocol launchProtocol, Map map)
 {
     CameraJumper.TryJump(map.Center, map);
     LandingTargeter.Instance.BeginTargeting(aerialVehicle.vehicle, aerialVehicle.vehicle.CompVehicleLauncher.launchProtocol, map, delegate(LocalTargetInfo target, Rot4 rot)
     {
         VehicleSkyfaller_Arriving skyfaller = (VehicleSkyfaller_Arriving)ThingMaker.MakeThing(aerialVehicle.vehicle.CompVehicleLauncher.Props.skyfallerIncoming);
         skyfaller.vehicle = aerialVehicle.vehicle;
         GenSpawn.Spawn(skyfaller, target.Cell, map, rot);
     }, null, null, null, aerialVehicle.vehicle.VehicleDef.rotatable && aerialVehicle.vehicle.CompVehicleLauncher.launchProtocol.landingProperties.forcedRotation is null, true);
 }
Example #10
0
        protected virtual void ExitMap()
        {
            AerialVehicleInFlight flyingVehicle = (AerialVehicleInFlight)WorldObjectMaker.MakeWorldObject(WorldObjectDefOfVehicles.AerialVehicle);

            flyingVehicle.vehicle = vehicle;
            flyingVehicle.Tile    = Map.Tile;
            flyingVehicle.SetFaction(vehicle.Faction);
            flyingVehicle.OrderFlyToTiles(aerialVehicle.flightPath.Path, Find.WorldGrid.GetTileCenter(Map.Tile), aerialVehicle.arrivalAction);
            //Recon edge case?
            flyingVehicle.Initialize();
            Find.WorldObjects.Add(flyingVehicle);
            Destroy();
        }
Example #11
0
        public override void Initialize(WorldObject firedFrom, AerialVehicleInFlight target, Vector3 source)
        {
            this.target = target;
            Vector3 misfire = new Vector3(Rand.Range(-Spread, Spread), Rand.Range(-Spread, Spread), Rand.Range(-Spread, Spread));

            destination     = this.target.DrawPosAhead(50) - misfire;
            this.source     = source;
            this.firedFrom  = firedFrom;
            speedPctPerTick = Mathf.Max((AerialVehicleInFlight.PctPerTick / Ext_Math.SphericalDistance(this.source, destination)) * Rand.Range(40, 70), MinSpeed);
            InitializeFacing();

            explosionFrame = -1;
        }
 public Dialog_TradeAerialVehicle(AerialVehicleInFlight aerialVehicle, Pawn playerNegotiator, ITrader trader, bool giftsOnly = false)
 {
     this.aerialVehicle = aerialVehicle;
     this.giftsOnly     = giftsOnly;
     TradeSession.SetupWith(trader, playerNegotiator, giftsOnly);
     SetupPlayerCaravanVariables();
     forcePause = true;
     absorbInputAroundWindow = true;
     soundAppear             = SoundDefOf.CommsWindow_Open;
     soundClose = SoundDefOf.CommsWindow_Close;
     if (trader is PassingShip)
     {
         soundAmbient = SoundDefOf.RadioComms_Ambience;
     }
     sorter1 = TransferableSorterDefOf.Category;
     sorter2 = TransferableSorterDefOf.MarketValue;
 }
        public static Settlement SettlementVisitedNow(AerialVehicleInFlight aerial)
        {
            if (!aerial.Spawned || aerial.vehicle.CompVehicleLauncher.inFlight)
            {
                return(null);
            }
            List <Settlement> settlementBases = Find.WorldObjects.SettlementBases;

            for (int i = 0; i < settlementBases.Count; i++)
            {
                Settlement settlement = settlementBases[i];
                if (settlement.Tile == aerial.flightPath.First.tile && settlement.Faction != aerial.Faction && settlement.Visitable)
                {
                    return(settlement);
                }
            }
            return(null);
        }
Example #14
0
        private static IntVec3 GetLandingCell(Map map, AerialVehicleInFlight aerialVehicle)
        {
            bool validator(IntVec3 c)
            {
                bool flag = aerialVehicle.vehicle.PawnOccupiedCells(c, Rot4.East).All(c2 => c2.Standable(map) && !c.Roofed(map) && !c.Fogged(map) && c.InBounds(map));

                return(flag);
            }

            IntVec3 RandomCentercell()
            {
                RCellFinder.TryFindRandomCellNearTheCenterOfTheMapWith(validator, map, out IntVec3 result);
                return(result);
            }

            IntVec3 cell = RandomCentercell();

            return(cell);
        }
Example #15
0
 public override void Arrived(int tile)
 {
     LongEventHandler.QueueLongEvent(delegate()
     {
         Map map            = GetOrGenerateMapUtility.GetOrGenerateMap(tile, null);
         TaggedString label = "LetterLabelCaravanEnteredEnemyBase".Translate();
         TaggedString text  = "LetterTransportPodsLandedInEnemyBase".Translate(settlement.Label).CapitalizeFirst();
         SettlementUtility.AffectRelationsOnAttacked(settlement, ref text);
         if (!settlement.HasMap)
         {
             Find.TickManager.Notify_GeneratedPotentiallyHostileMap();
             PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(map.mapPawns.AllPawns, ref label, ref text, "LetterRelatedPawnsInMapWherePlayerLanded".Translate(Faction.OfPlayer.def.pawnsPlural), true, true);
         }
         Find.LetterStack.ReceiveLetter(label, text, LetterDefOf.NeutralEvent, vehicle, settlement.Faction, null, null, null);
         AerialVehicleInFlight aerialVehicle = vehicle.GetAerialVehicle();
         arrivalModeDef.Worker.VehicleArrived(aerialVehicle, launchProtocol, settlement.Map);
         aerialVehicle.Destroy();
     }, "GeneratingMap", false, null, true);
 }
Example #16
0
 public override void WorldComponentTick()
 {
     foreach (var defense in searchingDefenses)
     {
         AerialVehicleInFlight aerialVehicleSearchingFor = defense.Key;
         for (int j = defense.Value.Count - 1; j >= 0; j--)
         {
             AirDefense airDefense        = defense.Value.ElementAt(j);
             float      distance          = Ext_Math.SphericalDistance(airDefense.parent.DrawPos, aerialVehicleSearchingFor.DrawPos);
             bool       withinMaxDistance = distance <= airDefense.MaxDistance;
             if (airDefense.CurrentTarget != aerialVehicleSearchingFor)
             {
                 airDefense.angle = (airDefense.angle + RotationRate * airDefense.searchDirection).ClampAndWrap(0, 360);
                 float angleToTarget = airDefense.parent.DrawPos.AngleToPoint(aerialVehicleSearchingFor.DrawPos);
                 if (withinMaxDistance && Mathf.Abs(angleToTarget - airDefense.angle) <= (airDefense.Arc / 2))
                 {
                     airDefense.activeTargets.Add(aerialVehicleSearchingFor);
                 }
             }
             else
             {
                 float headingToTarget   = WorldHelper.TryFindHeading(airDefense.parent.DrawPos, airDefense.CurrentTarget.DrawPos);
                 int   dirSignMultiplier = headingToTarget < airDefense.angle ? -2 : 2;
                 if (Mathf.Abs(headingToTarget - airDefense.angle) < 1 || Mathf.Abs(headingToTarget - airDefense.angle) > 359)
                 {
                     airDefense.angle = headingToTarget;
                     airDefense.Attack();
                 }
                 else
                 {
                     airDefense.angle = (airDefense.angle + RotationRate * dirSignMultiplier).ClampAndWrap(0, 360);
                 }
                 if (!withinMaxDistance)
                 {
                     airDefense.activeTargets.Remove(aerialVehicleSearchingFor);
                 }
             }
         }
     }
 }
Example #17
0
        private static void SpawnCrashingShuttle()
        {
            List <DebugMenuOption> list = new List <DebugMenuOption>();

            foreach (VehicleDef vehicleDef in DefDatabase <VehicleDef> .AllDefs.OrderBy(d => d.defName))
            {
                list.Add(new DebugMenuOption(vehicleDef.defName, DebugMenuOptionMode.Tool, delegate()
                {
                    Faction faction     = Faction.OfPlayer;
                    VehiclePawn vehicle = VehicleSpawner.GenerateVehicle(vehicleDef, faction);
                    vehicle.CompVehicleLauncher?.InitializeLaunchProtocols(false);
                    AerialVehicleInFlight flyingVehicle = (AerialVehicleInFlight)WorldObjectMaker.MakeWorldObject(WorldObjectDefOfVehicles.AerialVehicle);
                    flyingVehicle.vehicle = vehicle;
                    flyingVehicle.vehicle.CompVehicleLauncher.inFlight = true;
                    flyingVehicle.Tile = Find.CurrentMap.Tile;
                    flyingVehicle.SetFaction(vehicle.Faction);
                    flyingVehicle.Initialize();
                    (VehicleIncidentDefOf.BlackHawkDown.Worker as IncidentWorker_ShuttleDowned).TryExecuteEvent(flyingVehicle, null, Verse.UI.MouseCell());
                }));
            }
            Find.WindowStack.Add(new Dialog_DebugOptionListLister(list));
        }
Example #18
0
        public static void RegisterAerialVehicle(AerialVehicleInFlight aerialVehicle, HashSet <AirDefense> newDefenses)
        {
            HashSet <AirDefense> oldDefenses = new HashSet <AirDefense>();

            if (searchingDefenses.TryGetValue(aerialVehicle, out var defenses))
            {
                oldDefenses.AddRange(defenses);
                defenses.Clear();
                defenses.AddRange(newDefenses);
            }
            else
            {
                searchingDefenses.Add(aerialVehicle, newDefenses);
            }
            defensesToDraw.RemoveWhere(d => oldDefenses.Contains(d));
            foreach (AirDefense airDefense in newDefenses)
            {
                if (defensesToDraw.Add(airDefense))
                {
                    airDefense.angle = Rand.RangeInclusive(0, 360);
                }
            }
        }
Example #19
0
 public static void DeregisterAerialVehicle(AerialVehicleInFlight aerialVehicle)
 {
     searchingDefenses.Remove(aerialVehicle);
     RecacheAirDefenseDrawers();
 }
Example #20
0
 public override IEnumerable <FloatMenuOption> GetFloatMenuOptionsAt(int tile)
 {
     if (AerialVehicleArrivalAction_FormVehicleCaravan.CanFormCaravanAt(vehicle, tile) && !Find.WorldObjects.AnySettlementBaseAt(tile) && !Find.WorldObjects.AnySiteAt(tile))
     {
         yield return(new FloatMenuOption("FormCaravanHere".Translate(), delegate()
         {
             if (vehicle.Spawned)
             {
                 vehicle.CompVehicleLauncher.TryLaunch(tile, new AerialVehicleArrivalAction_FormVehicleCaravan(vehicle));
             }
             else
             {
                 AerialVehicleInFlight aerial = VehicleWorldObjectsHolder.Instance.AerialVehicleObject(vehicle);
                 aerial.OrderFlyToTiles(LaunchTargeter.FlightPath, aerial.DrawPos, new AerialVehicleArrivalAction_FormVehicleCaravan(vehicle));
             }
         }, MenuOptionPriority.Default, null, null, 0f, null, null));
     }
     else if (Find.WorldObjects.MapParentAt(tile) is MapParent parent)
     {
         if (CanLandInSpecificCell(parent))
         {
             yield return(new FloatMenuOption("LandInExistingMap".Translate(vehicle.Label), delegate()
             {
                 Current.Game.CurrentMap = parent.Map;
                 CameraJumper.TryHideWorld();
                 LandingTargeter.Instance.BeginTargeting(vehicle, this, delegate(LocalTargetInfo target, Rot4 rot)
                 {
                     if (vehicle.Spawned)
                     {
                         vehicle.CompVehicleLauncher.TryLaunch(tile, new AerialVehicleArrivalAction_LandSpecificCell(vehicle, parent, tile, this, target.Cell, rot));
                     }
                     else
                     {
                         AerialVehicleInFlight aerial = VehicleWorldObjectsHolder.Instance.AerialVehicleObject(vehicle);
                         if (aerial is null)
                         {
                             Log.Error($"Attempted to launch into existing map where CurrentMap is null and no AerialVehicle with {vehicle.Label} exists.");
                             return;
                         }
                         aerial.arrivalAction = new AerialVehicleArrivalAction_LandSpecificCell(vehicle, parent, tile, this, target.Cell, rot);
                         aerial.OrderFlyToTiles(LaunchTargeter.FlightPath, aerial.DrawPos, new AerialVehicleArrivalAction_LandSpecificCell(vehicle, parent, tile, this, target.Cell, rot));
                         vehicle.CompVehicleLauncher.inFlight = true;
                         CameraJumper.TryShowWorld();
                     }
                 }, null, null, null, vehicle.VehicleDef.rotatable && landingProperties.forcedRotation is null);
             }, MenuOptionPriority.Default, null, null, 0f, null, null));
         }
         if (vehicle.CompVehicleLauncher.ControlInFlight)
         {
             yield return(MapHelper.ReconFloatMenuOption(vehicle, parent));
         }
         if (vehicle.CompVehicleLauncher.ControlInFlight && vehicle.CompCannons != null)                 //REDO - strafe specific properties
         {
             yield return(new FloatMenuOption("VehicleStrafeRun".Translate(), delegate()
             {
                 if (vehicle.Spawned)
                 {
                     LaunchTargeter.Instance.ContinueTargeting(vehicle, new Func <GlobalTargetInfo, float, bool>(ChoseWorldTarget), vehicle.Map.Tile, true, VehicleTex.TargeterMouseAttachment, true, null,
                                                               (GlobalTargetInfo target, List <FlightNode> path, float fuelCost) => TargetingLabelGetter(target, tile, path, fuelCost));
                 }
                 else
                 {
                     AerialVehicleInFlight aerialVehicle = vehicle.GetAerialVehicle();
                     if (aerialVehicle is null)
                     {
                         Log.Error($"Unable to launch strafe run. AerialVehicle is null and {vehicle.LabelCap} is not spawned.");
                         return;
                     }
                     LaunchTargeter.Instance.ContinueTargeting(vehicle, new Func <GlobalTargetInfo, float, bool>(aerialVehicle.ChoseTargetOnMap), aerialVehicle, true, VehicleTex.TargeterMouseAttachment, false, null,
                                                               (GlobalTargetInfo target, List <FlightNode> path, float fuelCost) => vehicle.CompVehicleLauncher.launchProtocol.TargetingLabelGetter(target, aerialVehicle.Tile, path, fuelCost));
                 }
                 CameraJumper.TryShowWorld();
                 LaunchTargeter.Instance.RegisterActionOnTile(tile, new AerialVehicleArrivalAction_StrafeMap(vehicle, parent));
             }, MenuOptionPriority.Default, null, null, 0f, null, null));
         }
     }
     if (Find.WorldObjects.SettlementAt(tile) is Settlement settlement)
     {
         if (settlement.Faction.def.techLevel <= TechLevel.Industrial)
         {
             yield return(new FloatMenuOption("LandVehicleHere".Translate(), delegate()
             {
                 if (vehicle.Spawned)
                 {
                     vehicle.CompVehicleLauncher.TryLaunch(tile, new AerialVehicleArrivalAction_FormVehicleCaravan(vehicle));
                 }
                 else
                 {
                     AerialVehicleInFlight aerial = VehicleWorldObjectsHolder.Instance.AerialVehicleObject(vehicle);
                     aerial.OrderFlyToTiles(LaunchTargeter.FlightPath, aerial.DrawPos, new AerialVehicleArrivalAction_VisitSettlement(vehicle, settlement));
                 }
             }, MenuOptionPriority.Default, null, null, 0f, null, null));
         }
         foreach (FloatMenuOption option in AerialVehicleArrivalAction_AttackSettlement.GetFloatMenuOptions(vehicle, this, settlement))
         {
             yield return(option);
         }
     }
 }
Example #21
0
 /// <summary>
 /// AerialVehicle <paramref name="vehicle"/> can offer gifts to <paramref name="settlement"/>
 /// </summary>
 /// <param name="vehicle"></param>
 /// <param name="settlement"></param>
 public static FloatMenuAcceptanceReport CanOfferGiftsTo(AerialVehicleInFlight vehicle, Settlement settlement)
 {
     return(settlement != null && settlement.Spawned && !settlement.HasMap && settlement.Faction != null && settlement.Faction != Faction.OfPlayer &&
            !settlement.Faction.def.permanentEnemy && settlement.Faction.HostileTo(Faction.OfPlayer) && settlement.CanTradeNow && vehicle.vehicle.HasNegotiator);
 }
Example #22
0
 public VehicleSkyfaller_FlyOver(AerialVehicleInFlight aerialVehicle)
 {
     this.aerialVehicle = aerialVehicle;
 }
Example #23
0
 public abstract void VehicleArrived(AerialVehicleInFlight aerialVehicle, LaunchProtocol protocol, Map map);
Example #24
0
 public void ContinueTargeting(VehiclePawn vehicle, Func <GlobalTargetInfo, float, bool> action, AerialVehicleInFlight aerialVehicle, bool canTargetTiles, Texture2D mouseAttachment = null, bool closeWorldTabWhenFinished = false, Action onUpdate = null,
                               Func <GlobalTargetInfo, List <FlightNode>, float, string> extraLabelGetter = null)
 {
     this.vehicle                   = vehicle;
     this.action                    = action;
     this.aerialVehicle             = aerialVehicle;
     this.canTargetTiles            = canTargetTiles;
     this.mouseAttachment           = mouseAttachment;
     this.closeWorldTabWhenFinished = closeWorldTabWhenFinished;
     this.onUpdate                  = onUpdate;
     this.extraLabelGetter          = extraLabelGetter;
 }
Example #25
0
 public FlightPath(AerialVehicleInFlight aerialVehicle)
 {
     this.aerialVehicle = aerialVehicle;
 }
Example #26
0
 public abstract void Initialize(WorldObject firedFrom, AerialVehicleInFlight target, Vector3 source);