public virtual void InitializeLaunchProtocols(bool respawningAfterLoad) { if (!respawningAfterLoad) { launchProtocol = (LaunchProtocol)Activator.CreateInstance(Props.launchProtocol.GetType(), new object[] { Props.launchProtocol, Vehicle }); } launchProtocol.ResolveProperties(Props.launchProtocol); }
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); }
public override void ResolveProperties(LaunchProtocol reference) { base.ResolveProperties(reference); VTOLTakeoff vtolReference = reference as VTOLTakeoff; verticalLaunchCurve = vtolReference.verticalLaunchCurve; verticalLandingCurve = vtolReference.verticalLandingCurve; ticksVertical = vtolReference.ticksVertical; }
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); }
public void BeginTargeting(VehiclePawn vehicle, LaunchProtocol launchProtocol, Action <LocalTargetInfo, Rot4> action, Func <LocalTargetInfo, bool> targetValidator = null, Action actionWhenFinished = null, Texture2D mouseAttachment = null, bool allowRotating = false, bool forcedTargeting = false) { this.vehicle = vehicle; this.launchProtocol = launchProtocol; this.action = action; this.actionWhenFinished = actionWhenFinished; this.mouseAttachment = mouseAttachment; this.targetValidator = targetValidator; this.allowRotating = allowRotating; landingRotation = launchProtocol.landingProperties?.forcedRotation ?? Rot4.North; ForcedTargeting = forcedTargeting; }
public void BeginTargeting(VehiclePawn vehicle, LaunchProtocol launchProtocol, Action <IntVec3, IntVec3> action, Func <LocalTargetInfo, bool> targetValidator = null, Action actionWhenFinished = null, Texture2D mouseAttachment = null, bool forcedTargeting = false) { this.vehicle = vehicle; this.launchProtocol = launchProtocol; this.action = action; this.actionWhenFinished = actionWhenFinished; this.mouseAttachment = mouseAttachment; this.targetValidator = targetValidator; ForcedTargeting = forcedTargeting; start = IntVec3.Invalid; end = IntVec3.Invalid; }
public void BeginTargeting(VehiclePawn vehicle, LaunchProtocol launchProtocol, Map map, Action <IntVec3, IntVec3> action, Func <LocalTargetInfo, bool> targetValidator = null, Action actionWhenFinished = null, Texture2D mouseAttachment = null, bool forcedTargeting = false) { Current.Game.CurrentMap = map; BeginTargeting(vehicle, launchProtocol, action, targetValidator, actionWhenFinished, mouseAttachment); ForcedTargeting = forcedTargeting; }
public AerialVehicleArrivalAction_CrashSpecificCell(VehiclePawn vehicle, MapParent mapParent, int tile, LaunchProtocol launchProtocol, IntVec3 landingCell, Rot4 landingRot) : base(vehicle, mapParent, tile, launchProtocol, landingCell, landingRot) { }
public virtual void ResolveProperties(LaunchProtocol reference) { launchProperties = reference.launchProperties; landingProperties = reference.landingProperties; }
/// <summary> /// Copy over from XML values for instances /// </summary> /// <param name="reference"></param> /// <param name="vehicle"></param> public LaunchProtocol(LaunchProtocol reference, VehiclePawn vehicle) { this.vehicle = vehicle; landingProperties = reference.landingProperties; launchProperties = reference.launchProperties; }
public abstract void VehicleArrived(AerialVehicleInFlight aerialVehicle, LaunchProtocol protocol, Map map);
public AerialVehicleArrivalAction_LandSpecificCell(VehiclePawn vehicle, MapParent mapParent, int tile, LaunchProtocol launchProtocol, IntVec3 landingCell, Rot4 landingRot) : base(vehicle, mapParent, tile, launchProtocol) { this.tile = tile; this.mapParent = mapParent; this.launchProtocol = launchProtocol; this.landingCell = landingCell; this.landingRot = landingRot; }
public AerialVehicleArrivalAction_LandInMap(VehiclePawn vehicle, MapParent mapParent, int tile, LaunchProtocol launchProtocol) : base(vehicle) { this.tile = tile; this.mapParent = mapParent; this.launchProtocol = launchProtocol; }
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 static IEnumerable <FloatMenuOption> GetFloatMenuOptions(VehiclePawn vehicle, LaunchProtocol launchProtocol, Settlement settlement) { if (vehicle.CompVehicleLauncher.ControlInFlight) { foreach (FloatMenuOption floatMenuOption2 in VehicleArrivalActionUtility.GetFloatMenuOptions(() => CanAttack(vehicle, settlement), () => new AerialVehicleArrivalAction_AttackSettlement(vehicle, launchProtocol, settlement, AerialVehicleArrivalModeDefOf.TargetedLanding), "AttackAndTargetLanding".Translate(settlement.Label), vehicle, settlement.Tile, null)) { yield return(floatMenuOption2); } } foreach (FloatMenuOption floatMenuOption2 in VehicleArrivalActionUtility.GetFloatMenuOptions(() => CanAttack(vehicle, settlement), () => new AerialVehicleArrivalAction_AttackSettlement(vehicle, launchProtocol, settlement, AerialVehicleArrivalModeDefOf.EdgeDrop), "AttackAndDropAtEdge".Translate(settlement.Label), vehicle, settlement.Tile, null)) { yield return(floatMenuOption2); } foreach (FloatMenuOption floatMenuOption2 in VehicleArrivalActionUtility.GetFloatMenuOptions(() => CanAttack(vehicle, settlement), () => new AerialVehicleArrivalAction_AttackSettlement(vehicle, launchProtocol, settlement, AerialVehicleArrivalModeDefOf.CenterDrop), "AttackAndDropInCenter".Translate(settlement.Label), vehicle, settlement.Tile, null)) { yield return(floatMenuOption2); } }
public AerialVehicleArrivalAction_AttackSettlement(VehiclePawn vehicle, LaunchProtocol launchProtocol, Settlement settlement, AerialVehicleArrivalModeDef arrivalModeDef) : base(vehicle) { this.launchProtocol = launchProtocol; this.settlement = settlement; this.arrivalModeDef = arrivalModeDef; }