Class EquipmentActivation

java.lang.Object
megamek.common.equipment.EquipmentActivation

public final class EquipmentActivation extends Object
Stateless queries for the equipment activation/deactivation rules (equipment with an "Off" mode: active probes, ECM suites, C3 computers, heat sinks, gauss rifles, improved heavy lasers, and similar). Deactivated equipment provides none of its game effects but is otherwise undamaged; state that encodes relationships (such as C3 network membership) survives deactivation so that reactivating the equipment restores it.
  • Method Details

    • isC3SwitchedOff

      public static boolean isC3SwitchedOff(Entity entity)
      Returns whether the player has deactivated the unit's C3 network gear (C3 slave/master, C3i, Naval C3 or Nova CEWS). A switched-off unit provides and receives no network benefit, but its network membership (c3NetIdString, master link, partner UUIDs) is preserved, so reactivating the equipment automatically restores the previous network.
      Parameters:
      entity - the unit to check
      Returns:
      true if the unit mounts operable C3 network equipment and all of it is currently set to "Off"
    • isStealthOnOrActivating

      public static boolean isStealthOnOrActivating(Entity entity)
      Returns whether the unit's stealth armor system is engaged now or will be engaged next round (a pending switch to "On"). Used to validate that the ECM suite stealth armor depends on is not deactivated in the same round the stealth system is being engaged.
      Parameters:
      entity - the unit to check
      Returns:
      true if an operable stealth armor system is in the "On" mode now or as its next-round mode
    • hasEcmAvailableForStealth

      public static boolean hasEcmAvailableForStealth(Entity entity)
      Returns whether the unit will have an ECM suite operating next round, i.e. one that is operable and not deactivated or switching to "Off". Stealth armor requires such a suite, so engaging stealth is refused while this returns false.
      Parameters:
      entity - the unit to check
      Returns:
      true if an operable ECM suite will not be in the "Off" mode next round
    • ecmSuitesInUseNextRound

      public static List<MiscMounted> ecmSuitesInUseNextRound(Entity entity)
      Returns the unit's ECM suites that will be in use next round, i.e. those that are operable and whose next-round mode is anything other than "Off". A suite set to ECCM or Ghost Targets is being used just as much as one set to ECM, so every non-"Off" mode counts. The next-round mode is the one that matters because ECM suites are built with setInstantModeSwitch(false): a switch declared now takes effect in the End Phase (TO:AUE p.90).

      A unit may only use one ECM suite at a time, of any type (TM p.213, CO p.200), so a returned list holding more than one entry describes a state the rules do not allow.

      Parameters:
      entity - the unit to check
      Returns:
      a new modifiable list of the operable ECM suites that are not deactivated next round, in mount order
    • preferredEcmSuite

      @Nullable public static MiscMounted preferredEcmSuite(List<MiscMounted> ecmSuites)
      Returns the ECM suite to keep when the game has to resolve a multiple-suite conflict without asking the player, such as a unit that deploys with several suites already active. Angel ECM wins over any other type, matching the precedence ECCMComparator already applies to competing ECM fields; otherwise the first suite in mount order is kept so that the choice is stable from one game to the next.
      Parameters:
      ecmSuites - the candidate suites, normally the result of ecmSuitesInUseNextRound(Entity)
      Returns:
      the suite to leave on, or null if the list is empty
    • ecmSuiteLabel

      public static String ecmSuiteLabel(Entity entity, MiscMounted ecmSuite)
      Returns a label that identifies one ECM suite among all of the unit's ECM suites, such as "ECM Suite (Guardian) #2 (Body)". The number counts ECM suites in mount order and is only added when the unit carries more than one, because a unit can mount two suites of the same type in the same location - the Mantis Light Attack VTOL (ECCM) carries two Guardian suites in its Body - and neither the equipment name nor the location tells those apart. The client dialog, the lobby and the server chat all build the label here so that they name the same suite the same way.
      Parameters:
      entity - the unit carrying the suite
      ecmSuite - the ECM suite to label
      Returns:
      the display label for the suite
    • isGuidanceActive

      public static boolean isGuidanceActive(@Nullable Mounted<?> linker, MiscTypeFlag flag)
      Returns whether a weapon's linked fire control enhancement is both intact and switched on, so it applies its effect to a shot.

      Covers the guidance systems a player may switch off per BMM p.12: Artemis IV, Artemis V, Proto Artemis and the Apollo MRM FCS. Equipment that defines no "Off" mode reports as switched on, so passing any other flag behaves exactly as the intact-and-installed check did before this method existed.

      Example: a Mad Dog Prime fires an LRM 20 with Artemis IV and Artemis-capable ammo. Normally that is a -1 to hit and the missiles roll on a better cluster row. With the Artemis switched off, the shot resolves as a plain LRM 20 with unguided ammo instead.

      Parameters:
      linker - the equipment the weapon is linked by, which may be null when nothing is linked
      flag - the fire control flag to look for
      Returns:
      true when the linked equipment carries that flag, is undamaged, and is not switched off
    • hasActiveGuidance

      public static boolean hasActiveGuidance(Entity entity, MiscTypeFlag flag)
      Returns whether a unit mounts at least one fire control enhancement of the given kind that is intact and switched on.

      Used to decide whether to offer the player an option that needs working guidance at all, such as the MRM saturation attack an Apollo allows. Whether a particular shot gets the benefit is a per-weapon question, which isGuidanceActive(Mounted, MiscTypeFlag) answers.

      Parameters:
      entity - the unit to check
      flag - the fire control flag to look for
      Returns:
      true when at least one such system is mounted, undamaged, and not switched off