Class BridgeLayerLogic

java.lang.Object
megamek.common.equipment.BridgeLayerLogic

public final class BridgeLayerLogic extends Object
Stateless rules helper for Bridge-Layer (AVLB) equipment, TM p.242 / TW. Holds the carried-bridge query, deploy eligibility, hit-redirection and weapon-fire-block logic that operates on an Entity and its bridgelayer MiscMounteds. Extracted from Entity so the bridgelayer rules do not add to that already very large class; this mirrors the codebase's other Entity-operating utilities (BridgeConstruction, megamek.common.compute.Compute).
  • Method Details

    • getDeployableBridgeLayers

      public static List<MiscMounted> getDeployableBridgeLayers(Entity entity)
      Parameters:
      entity - the unit to inspect
      Returns:
      all carried, still-deployable Bridge-Layer (AVLB) mounts on the unit, in equipment order - each a bridgelayer whose folding bridge is not yet deployed, whose deploy mechanism is intact, that still has Construction Factor, and that is not itself destroyed. A unit may carry more than one (e.g. the Prometheus has a Right and a Left bridge), and the player chooses which to deploy. TM p.242 / TW.
    • getDeployableBridgeLayer

      @Nullable public static MiscMounted getDeployableBridgeLayer(Entity entity)
      Parameters:
      entity - the unit to inspect
      Returns:
      the first carried, still-deployable Bridge-Layer (AVLB) mount on the unit, or null if none. Used for eligibility checks; see getDeployableBridgeLayers(Entity) for the full list the player chooses from.
    • getPendingDeployBridgeLayer

      @Nullable public static MiscMounted getPendingDeployBridgeLayer(Entity entity)
      Parameters:
      entity - the unit to inspect
      Returns:
      the Bridge-Layer mount on the unit that has a deploy declared and awaiting placement, or null if none.
    • getBridgeLayerForHit

      @Nullable public static MiscMounted getBridgeLayerForHit(Entity entity, HitData hit)
      Parameters:
      entity - the unit taking the hit
      hit - the incoming hit
      Returns:
      the carried (not-yet-deployed) bridgelayer mount whose folding bridge should absorb a hit to this location, or null if none applies. A hit to the location where a bridgelayer is mounted is absorbed by the carried bridge (e.g. the Right/Left side bridges on the Prometheus absorb RS/LS hits). On a Support Vehicle a hit to the turret is also absorbed (TM p.242 / TW; this covers turret-mounted SV bridgelayers, while the mounted-location rule still protects side/body-mounted ones). Returns null once the carried bridge has no Construction Factor left - it is destroyed and the location then takes damage normally.
    • isWeaponLocationBlockedByCarriedBridge

      public static boolean isWeaponLocationBlockedByCarriedBridge(Entity entity, int location)
      Parameters:
      entity - the firing unit
      location - a weapon's location index
      Returns:
      whether a carried, not-yet-deployed bridgelayer occupies this location and so blocks weapons mounted there from firing (TM p.242 / TW: "If the bridge has not yet been deployed, the unit cannot make attacks from any weapons mounted in its location."). A destroyed or already-deployed bridge no longer blocks fire.
    • isBridgeLayerMotiveReady

      public static boolean isBridgeLayerMotiveReady(Entity entity)
      Parameters:
      entity - the unit to inspect
      Returns:
      whether the unit's motive system currently permits deploying a bridgelayer (TM p.242 / TW): ground units always qualify; Hover and WiGE units only when landed (they spent no MP the previous round and sit at ground level, not airborne); Naval, Hydrofoil and Submersible units only when surfaced (at Depth 0). The stationary-this-turn requirement is enforced separately, since the deploy declaration must be the unit's only action.
    • getBridgeLayerTargetCoords

      @Nullable public static Coords getBridgeLayerTargetCoords(Entity entity)
      Parameters:
      entity - the unit to inspect
      Returns:
      the hex directly in front of the unit (in its current facing), where its bridgelayer would deploy its folding bridge, or null if the unit has no board position.
    • getBridgeLayerExits

      public static int getBridgeLayerExits(Entity entity)
      Parameters:
      entity - the unit to inspect
      Returns:
      the exits bitmask for a bridge deployed straight ahead of the unit, connecting the front hexside and its opposite so the single-hex span runs along the unit's facing (TM p.242 / TW: the bridge cannot extend at an angle).
    • canDeclareBridgeDeploy

      public static boolean canDeclareBridgeDeploy(Entity entity, Game game)
      Determines whether the unit may declare a bridgelayer deployment now (during the movement phase). Each failing condition is logged at DEBUG with its reason and relevant values so a playtest can diagnose a disabled "Deploy Bridge" button from megamek.log. TM p.242 / TW.
      Parameters:
      entity - the unit declaring the deployment
      game - the current game (for the board and the target hex validation)
      Returns:
      true if a deployment may be declared