Class BaConstructionUtil

java.lang.Object
megamek.common.units.BaConstructionUtil

public class BaConstructionUtil extends Object
Helper methods for constructing/changing Battle Armor units. This happens mostly in MML but some units have modular equipment which MM must be able to switch out and the code for this is involved and should be unified as much as possible.

This is the MM extension of BattleArmorUtil.

  • Constructor Details

    • BaConstructionUtil

      public BaConstructionUtil()
  • Method Details

    • unallocateMounted

      public static void unallocateMounted(BattleArmor battleArmor, Mounted<?> mounted)
      Unallocates (removes from arm/body etc to the unallocated equipment list) the given mounted. For special mounts for other equipment (DWP etc), that other equipment is removed from this mount first, emptying the given mounted. This method will unallocate regardless of the type of equipment, i.e., it does not check if this equipment should ever go unallocated (e.g. fixed location equipment). It is therefore up to the caller to select equipment to unallocate.
      Parameters:
      mounted - The equipment to unallocate
    • isFilledDwp

      public static boolean isFilledDwp(Mounted<?> mounted)
      Returns:
      True when the given mounted is a Detachable Weapon Pack and it has a weapon allocated to it.
    • isFilledApm

      public static boolean isFilledApm(Mounted<?> mounted)
      Returns:
      True when the given mounted is an Anti-Personnel weapon mount (only the misc item, not an armored glove!) and it has a weapon allocated to it.
    • isFilledArmoredGlove

      public static boolean isFilledArmoredGlove(Mounted<?> mounted)
      Returns:
      True when the given mounted is an Armored Glove manipulator and it has an AP weapon allocated to it.
    • emptyDwpApm

      public static void emptyDwpApm(Mounted<?> mount)
      Empties the given APM (including armored glove) or DWP, removing any weapon or other equipment attached to it. Can be safely called (does nothing) when there is no equipment on the given mount or the given mount is neither an APM nor DWP (in this case, logs a warning).
      Parameters:
      mount - The APM/DWP to empty
    • mountOnApm

      public static void mountOnApm(Mounted<?> weapon, Mounted<?> apm)
      Mounts the given weapon on the given Anti-Personnel Weapon Mount, which may be either the misc item or an armored glove. Any previously mounted weapon is removed from it, becoming unallocated. Does nothing and logs a warning when the given apm Mounted is not a suitable AP mount or the given weapon may not be mounted on an APM.
      Parameters:
      weapon - The weapon to mount on the APM
      apm - The APM to receive the weapon