Package megamek.common.equipment
Class BridgeLayerLogic
java.lang.Object
megamek.common.equipment.BridgeLayerLogic
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 Summary
Modifier and TypeMethodDescriptionstatic booleancanDeclareBridgeDeploy(Entity entity, Game game) Determines whether the unit may declare a bridgelayer deployment now (during the movement phase).static intgetBridgeLayerExits(Entity entity) static MiscMountedgetBridgeLayerForHit(Entity entity, HitData hit) static CoordsgetBridgeLayerTargetCoords(Entity entity) static MiscMountedgetDeployableBridgeLayer(Entity entity) static List<MiscMounted> getDeployableBridgeLayers(Entity entity) static MiscMountedgetPendingDeployBridgeLayer(Entity entity) static booleanisBridgeLayerMotiveReady(Entity entity) static booleanisWeaponLocationBlockedByCarriedBridge(Entity entity, int location)
-
Method Details
-
getDeployableBridgeLayers
- 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
- Parameters:
entity- the unit to inspect- Returns:
- the first carried, still-deployable Bridge-Layer (AVLB) mount on the unit, or
nullif none. Used for eligibility checks; seegetDeployableBridgeLayers(Entity)for the full list the player chooses from.
-
getPendingDeployBridgeLayer
- Parameters:
entity- the unit to inspect- Returns:
- the Bridge-Layer mount on the unit that has a deploy declared and awaiting placement, or
nullif none.
-
getBridgeLayerForHit
- Parameters:
entity- the unit taking the hithit- the incoming hit- Returns:
- the carried (not-yet-deployed) bridgelayer mount whose folding bridge should absorb a hit to this
location, or
nullif 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). Returnsnullonce the carried bridge has no Construction Factor left - it is destroyed and the location then takes damage normally.
-
isWeaponLocationBlockedByCarriedBridge
- Parameters:
entity- the firing unitlocation- 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
- 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
- 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
nullif the unit has no board position.
-
getBridgeLayerExits
- 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
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 deploymentgame- the current game (for the board and the target hex validation)- Returns:
trueif a deployment may be declared
-