Class PartialCover

java.lang.Object
megamek.common.PartialCover

public final class PartialCover extends Object
Which unit types can receive partial cover at all.

Partial cover is a Mek rule: large support vehicles, grounded small craft and DropShips never receive it, even though they rise more than one level, and ProtoMeks never do because they are only the height of vehicles (TW p.102, p.171; Core p.66, p.136; TO:AR p.85). This class decides eligibility by unit type only. Whether the Mek is standing, and whether the terrain, water or building actually covers it, is decided by the caller: LosEffects for terrain, the building and water checks in the to-hit code and the bots for the rest.

  • Method Details

    • canReceive

      public static boolean canReceive(@Nullable Targetable target)
      Parameters:
      target - the unit being shot at
      Returns:
      true if the target's unit type can receive partial cover at all. This says nothing about whether it currently does - a prone Mek is eligible by type but is not covered.
    • isInPartialWater

      public static boolean isInPartialWater(@Nullable Entity target, @Nullable Hex targetHex, int targetRelativeHeight)
      Whether water in the target's own hex covers its lower half.

      The water has to be exactly as deep as the Mek is tall, and the Mek has to be standing on the bottom so that its top is level with the surface: Depth 1 for a standard Mek, Depth 2 for a superheavy, which stands three levels high (TW p.102; Core p.66, p.240). Shallower water covers nothing, deeper water submerges the Mek and blocks line of sight altogether, and a Mek held above the surface - on a bridge, or jumping - is in the open. Unlike cover from a neighbouring hex, this applies even when the attacker is higher than the target, because the water surrounds the Mek.

      Parameters:
      target - the unit being shot at
      targetHex - the hex the target occupies
      targetRelativeHeight - the height of the target's top above the surface of its own hex, as Entity.relHeight() reports it: 0 when the top is level with the surface
      Returns:
      true if the target is standing in water that covers its lower half