Class BridgeLayerState

java.lang.Object
megamek.common.equipment.BridgeLayerState
All Implemented Interfaces:
Serializable

public class BridgeLayerState extends Object implements Serializable
Mutable per-mount state for a Bridge-Layer (AVLB) MiscMounted, holding the carried folding bridge's current Construction Factor and the deploy lifecycle. Kept in its own holder (referenced by a single field on MiscMounted) so the large MiscMounted/Entity classes are not bloated with bridgelayer fields.

Lifecycle: a bridgelayer starts carried (the folding bridge occupies the unit, absorbs attacks to its location, and blocks weapon fire there). The controlling player may declare a deploy; the unit must then remain stationary and the bridge is placed on the board in the following End Phase, after which the mount is deployed (spent). Construction Factors per TechManual Bridge-Layer table.

See Also:
  • Field Details

    • DIAGNOSTIC_LOGGER_NAME

      public static final String DIAGNOSTIC_LOGGER_NAME
      Dedicated log4j2 logger name for all Bridge-Layer (AVLB) diagnostics. AVLB code logs gate/eligibility reasons and state transitions through this name (tagged [AVLB]) so the whole feature flow can be enabled and grepped from megamek.log without turning on debug for the large host classes (Entity, MoveStep). Enable it in mmconf/log4j2.xml.
      See Also:
    • LIGHT_BRIDGE_LAYER_CF

      public static final int LIGHT_BRIDGE_LAYER_CF
      Carried bridge Construction Factor for the Light Bridge-Layer (TechManual Bridge-Layer table).
      See Also:
    • MEDIUM_BRIDGE_LAYER_CF

      public static final int MEDIUM_BRIDGE_LAYER_CF
      Carried bridge Construction Factor for the Medium Bridge-Layer (TechManual Bridge-Layer table).
      See Also:
    • HEAVY_BRIDGE_LAYER_CF

      public static final int HEAVY_BRIDGE_LAYER_CF
      Carried bridge Construction Factor for the Heavy Bridge-Layer (TechManual Bridge-Layer table).
      See Also:
  • Constructor Details

    • BridgeLayerState

      public BridgeLayerState(MiscType type)
      Creates the carried-bridge state for a bridgelayer mount, initializing the current CF from the equipment variant.
      Parameters:
      type - the bridgelayer MiscType (must be a bridgelayer; see isBridgeLayer(MiscType))
  • Method Details

    • isBridgeLayer

      public static boolean isBridgeLayer(@Nullable MiscType type)
      Parameters:
      type - an equipment type, possibly null
      Returns:
      true if the type is any of the Light/Medium/Heavy Bridge-Layer variants
    • initialCF

      public static int initialCF(MiscType type)
      Parameters:
      type - a bridgelayer equipment type
      Returns:
      the starting carried-bridge Construction Factor for the variant, or 0 if not a bridgelayer
    • terrainBridgeType

      public static int terrainBridgeType(MiscType type)
      Parameters:
      type - a bridgelayer equipment type
      Returns:
      the board bridge terrain type level placed when this variant deploys (Light = 1, Medium = 2, Heavy = 3). The deployed bridge's displayed type name is taken from this level, so each variant maps to its matching level; bridge images are selected by the exits bitmask, not the type level, so any level renders.
    • getCurrentCF

      public int getCurrentCF()
      Returns:
      the carried bridge's current Construction Factor; reduced as attacks are absorbed, and the bridge is destroyed when it reaches 0
    • setCurrentCF

      public void setCurrentCF(int constructionFactor)
      Sets the carried bridge's current Construction Factor, clamped to a minimum of 0.
      Parameters:
      constructionFactor - the new Construction Factor
    • isDeployed

      public boolean isDeployed()
      Returns:
      true once the folding bridge has been placed on the board and the mount is spent
    • setDeployed

      public void setDeployed(boolean deployed)
      Parameters:
      deployed - whether the folding bridge has been placed on the board
    • isDeployMechanismDisabled

      public boolean isDeployMechanismDisabled()
      Returns:
      true if a critical hit has disabled the deploy mechanism; the bridge can no longer be deployed
    • setDeployMechanismDisabled

      public void setDeployMechanismDisabled(boolean disabled)
      Parameters:
      disabled - whether a critical hit has disabled the deploy mechanism
    • isDeployPending

      public boolean isDeployPending()
      Returns:
      true while a deploy has been declared and is awaiting placement in a later End Phase
    • getDeployTarget

      @Nullable public Coords getDeployTarget()
      Returns:
      the hex the bridge will be placed in, or null when no deploy is pending
    • getDeployExits

      public int getDeployExits()
      Returns:
      the exits bitmask of the two hexsides the placed bridge will connect
    • getDeployDeclaredTurn

      public int getDeployDeclaredTurn()
      Returns:
      the game round in which the deploy was declared, or -1 if none is pending
    • startDeploy

      public void startDeploy(Coords target, int exits, int declaredTurn)
      Records a pending deploy declaration.
      Parameters:
      target - the hex the bridge will be placed in (directly in front of the unit)
      exits - the exits bitmask of the two hexsides the bridge will connect
      declaredTurn - the current game round in which the deploy was declared
    • clearPendingDeploy

      public void clearPendingDeploy()
      Clears any pending deploy declaration (cancellation or after placement).