public override IEnumerable <Gizmo> GetGizmos() { foreach (Gizmo gizmo in base.GetGizmos()) { yield return(gizmo); } if (IsPlayerControlled) { if (vehicle.CompFueledTravel != null) { yield return(vehicle.CompFueledTravel.FuelCountGizmo); foreach (Gizmo fuelGizmo in vehicle.CompFueledTravel.DevModeGizmos()) { yield return(fuelGizmo); } } if (!vehicle.CompVehicleLauncher.inFlight && Find.WorldObjects.SettlementAt(Tile) is Settlement settlement2) { yield return(GizmoHelper.AerialVehicleTradeCommand(this, settlement2.Faction, settlement2.TraderKind)); } if (vehicle.CompVehicleLauncher.ControlInFlight || !vehicle.CompVehicleLauncher.inFlight) { Command_Action launchCommand = new Command_Action() { defaultLabel = "CommandLaunchGroup".Translate(), defaultDesc = "CommandLaunchGroupDesc".Translate(), icon = VehicleTex.LaunchCommandTex, alsoClickIfOtherInGroupClicked = false, action = delegate() { LaunchTargeter.Instance.BeginTargeting(vehicle, new Func <GlobalTargetInfo, float, bool>(ChoseTargetOnMap), this, true, VehicleTex.TargeterMouseAttachment, false, null, (GlobalTargetInfo target, List <FlightNode> path, float fuelCost) => vehicle.CompVehicleLauncher.launchProtocol.TargetingLabelGetter(target, Tile, path, fuelCost)); } }; if (vehicle.CompFueledTravel.EmptyTank) { launchCommand.Disable("VehicleLaunchOutOfFuel".Translate()); } yield return(launchCommand); } if (!vehicle.CompVehicleLauncher.inFlight) { foreach (Settlement settlement in Find.WorldObjects.ObjectsAt(flightPath.First.tile).Where(o => o is Settlement).Cast <Settlement>()) { yield return(GizmoHelper.ShuttleTradeCommand(this, settlement)); if (WorldHelper.CanOfferGiftsTo(this, settlement)) { yield return(new Command_Action { defaultLabel = "CommandOfferGifts".Translate(), defaultDesc = "CommandOfferGiftsDesc".Translate(), icon = VehicleTex.OfferGiftsCommandTex, action = delegate() { Pawn playerNegotiator = WorldHelper.FindBestNegotiator(vehicle, null, null); Find.WindowStack.Add(new Dialog_Trade(playerNegotiator, settlement, true)); } }); } } Command_Settle commandSettle = new Command_Settle { defaultLabel = "CommandSettle".Translate(), defaultDesc = "CommandSettleDesc".Translate(), icon = SettleUtility.SettleCommandTex, action = delegate() { SoundDefOf.Tick_High.PlayOneShotOnCamera(null); void settleHere() { SettlementVehicleUtility.Settle(this); }; SettlementProximityGoodwillUtility.CheckConfirmSettle(Tile, settleHere); } }; if (!TileFinder.IsValidTileForNewSettlement(Tile, tmpSettleFailReason)) { commandSettle.Disable(tmpSettleFailReason.ToString()); } else if (SettleUtility.PlayerSettlementsCountLimitReached) { if (Prefs.MaxNumberOfPlayerSettlements > 1) { commandSettle.Disable("CommandSettleFailReachedMaximumNumberOfBases".Translate()); } else { commandSettle.Disable("CommandSettleFailAlreadyHaveBase".Translate()); } } yield return(commandSettle); } if (Prefs.DevMode) { yield return(new Command_Action { defaultLabel = "Debug: Land at Nearest Player Settlement", action = delegate() { List <Settlement> playerSettlements = Find.WorldObjects.Settlements.Where(s => s.Faction == Faction.OfPlayer).ToList(); Settlement nearestSettlement = playerSettlements.MinBy(s => Ext_Math.SphericalDistance(s.DrawPos, DrawPos)); LaunchProtocol launchProtocol = vehicle.CompVehicleLauncher.launchProtocol; Rot4 vehicleRotation = launchProtocol.landingProperties.forcedRotation ?? Rot4.Random; IntVec3 cell = CellFinderExtended.RandomCenterCell(nearestSettlement.Map, (IntVec3 cell) => !MapHelper.VehicleBlockedInPosition(vehicle, Current.Game.CurrentMap, cell, vehicleRotation)); VehicleSkyfaller_Arriving skyfaller = (VehicleSkyfaller_Arriving)ThingMaker.MakeThing(vehicle.CompVehicleLauncher.Props.skyfallerIncoming); skyfaller.vehicle = vehicle; GenSpawn.Spawn(skyfaller, cell, nearestSettlement.Map, vehicleRotation); Destroy(); } }); yield return(new Command_Action { defaultLabel = "Debug: Initiate Crash Event", action = delegate() { InitiateCrashEvent(null); } }); } } }
public override void ProcessInputEvents() { HandleRotationShortcuts(); if (Event.current.type == EventType.MouseDown && Event.current.button == 0) { LocalTargetInfo localTargetInfo = CurrentTargetUnderMouse(); if (action != null) { if (targetValidator != null) { VehiclePawn vehicleAtPos = MapHelper.VehicleInPosition(vehicle, Current.Game.CurrentMap, localTargetInfo.Cell, landingRotation); if (targetValidator(localTargetInfo) && (vehicleAtPos == vehicle || !MapHelper.VehicleBlockedInPosition(vehicle, Current.Game.CurrentMap, localTargetInfo.Cell, landingRotation))) { action(localTargetInfo, landingRotation); StopTargeting(); } } else if (localTargetInfo.IsValid) { action(localTargetInfo, landingRotation); StopTargeting(); } } SoundDefOf.Tick_High.PlayOneShotOnCamera(null); Event.current.Use(); } if ((Event.current.type == EventType.MouseDown && Event.current.button == 1) || KeyBindingDefOf.Cancel.KeyDownEvent) { if (ForcedTargeting) { SoundDefOf.ClickReject.PlayOneShotOnCamera(null); Messages.Message("MustTargetLanding".Translate(), MessageTypeDefOf.RejectInput); Event.current.Use(); return; } SoundDefOf.CancelMode.PlayOneShotOnCamera(null); StopTargeting(); Event.current.Use(); } }