public static List <GenericUpgrade> GetBombsToDrop(GenericShip ship, UpgradeSubType subType = UpgradeSubType.None, Type type = null) { return(ship.UpgradeBar.GetUpgradesOnlyFaceup() .Where(n => n.GetType().BaseType == typeof(GenericTimedBomb) || n.GetType().BaseType == typeof(GenericTimedBombSE) || n.GetType().BaseType == typeof(GenericContactMineSE) || n.UpgradeInfo.SubType == UpgradeSubType.Remote) .Where(n => n.State.UsesCharges == false || (n.State.UsesCharges == true && n.State.Charges > 0)) .Where(n => subType == UpgradeSubType.None || n.UpgradeInfo.SubType == subType) .Where(n => type == null || n.GetType() == type) .ToList()); }
public static void CreateAskBombDropSubPhase(GenericShip ship, UpgradeSubType subType = UpgradeSubType.None, Type type = null, bool onlyDrop = false) { Selection.ChangeActiveShip("ShipId:" + ship.ShipId); BombDecisionSubPhase selectBombToDrop = (BombDecisionSubPhase)Phases.StartTemporarySubPhaseNew( "Select a device to drop", typeof(BombDecisionSubPhase), delegate { DropSelectedDevice(onlyDrop); } ); selectBombToDrop.DefaultDecisionName = "None"; foreach (GenericUpgrade deviceInstalled in GetBombsToDrop(Selection.ThisShip, subType, type)) { selectBombToDrop.AddDecision( deviceInstalled.UpgradeInfo.Name, delegate { SelectBomb(deviceInstalled); } ); if (type != null && deviceInstalled.GetType() == type) { selectBombToDrop.DefaultDecisionName = deviceInstalled.UpgradeInfo.Name; } } selectBombToDrop.IsForced = selectBombToDrop.DefaultDecisionName != "None"; if (CheckBombDropCanBeSkipped()) { selectBombToDrop.AddDecision( "None", delegate { SelectBomb(null); } ); } selectBombToDrop.DescriptionShort = "Select a device to drop"; selectBombToDrop.RequiredPlayer = Selection.ThisShip.Owner.PlayerNo; selectBombToDrop.Start(); }
public static bool HasBombsToDrop(GenericShip ship, UpgradeSubType subType = UpgradeSubType.None, Type type = null) { return(GetBombsToDrop(ship, subType, type).Any()); }
public static void RegisterBombDropTriggerIfAvailable(GenericShip ship, TriggerTypes triggerType, UpgradeSubType subType = UpgradeSubType.None, Type type = null, bool onlyDrop = false, bool isRealDrop = true) { if ((!isRealDrop || !ship.IsBombAlreadyDropped) && HasBombsToDrop(ship, subType, type)) { Triggers.RegisterTrigger(new Trigger() { Name = "Ask which bomb to drop", TriggerType = TriggerTypes.OnMovementActivationStart, TriggerOwner = ship.Owner.PlayerNo, EventHandler = (object sender, EventArgs e) => CreateAskBombDropSubPhase((sender as GenericShip), subType, type, onlyDrop), Sender = ship }); } }
public UpgradeCardInfo( string name, UpgradeType type = UpgradeType.None, List <UpgradeType> types = null, int cost = 0, bool isLimited = false, bool isSolitary = false, int limited = 0, Type abilityType = null, UpgradeCardRestriction restriction = null, UpgradeCardRestrictions restrictions = null, int charges = 0, bool regensCharges = false, bool cannotBeRecharged = false, int seImageNumber = 0, SpecialWeaponInfo weaponInfo = null, ShipArcInfo addArc = null, ActionInfo addAction = null, List <ActionInfo> addActions = null, LinkedActionInfo addActionLink = null, UpgradeSlot addSlot = null, List <UpgradeSlot> addSlots = null, bool feIsLimitedPerShip = false, UpgradeType forbidSlot = UpgradeType.None, List <UpgradeType> forbidSlots = null, Dictionary <UpgradeType, int> costReductionByType = null, int addShields = 0, int addHull = 0, int addForce = 0, UpgradeSubType subType = UpgradeSubType.None, Type remoteType = null ) { Name = name; Cost = cost; Charges = charges; RegensCharges = regensCharges; CannotBeRecharged = cannotBeRecharged; SEImageNumber = seImageNumber; WeaponInfo = weaponInfo; AddActionLink = addActionLink; IsSolitary = isSolitary; AbilityTypes = new List <Type>(); if (abilityType != null) { AbilityTypes.Add(abilityType); } Limited = (isLimited) ? 1 : 0; if (limited != 0) { Limited = limited; } FeIsLimitedPerShip = feIsLimitedPerShip; UpgradeTypes = new List <UpgradeType>(); if (type != UpgradeType.None) { UpgradeTypes.Add(type); } if (types != null) { UpgradeTypes.AddRange(types); } Restrictions = new UpgradeCardRestrictions(); if (restriction != null) { Restrictions = new UpgradeCardRestrictions(restriction); } if (restrictions != null) { Restrictions = restrictions; } AddedSlots = new List <UpgradeSlot>(); if (addSlot != null) { AddedSlots.Add(addSlot); } if (addSlots != null) { AddedSlots.AddRange(addSlots); } AddedActions = new List <ActionInfo>(); if (addAction != null) { AddedActions.Add(addAction); } if (addActions != null) { AddedActions.AddRange(addActions); } ForbiddenSlots = new List <UpgradeType>(); if (forbidSlot != UpgradeType.None) { ForbiddenSlots.Add(forbidSlot); } if (forbidSlots != null) { ForbiddenSlots.AddRange(forbidSlots); } CostReductionByType = new Dictionary <UpgradeType, int>(); if (costReductionByType != null) { CostReductionByType = costReductionByType; } AddHull = addHull; AddShields = addShields; AddForce = addForce; AddArc = addArc; SubType = subType; RemoteType = remoteType; }