Class WeaponBayText

java.lang.Object
megameklab.printing.WeaponBayText
All Implemented Interfaces:
Comparable<WeaponBayText>

public class WeaponBayText extends Object implements Comparable<WeaponBayText>
Convenience class for storing information about weapon bays for printing. This consists of a list of the weapons in the bay with heat and damage, along with the location of the bay.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    The location of the bay, or locations if multiple identical bays are combined.
  • Constructor Summary

    Constructors
    Constructor
    Description
    WeaponBayText(int l, boolean rear)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addBayAmmo(megamek.common.equipment.WeaponType weaponType, megamek.common.equipment.AmmoMounted ammo)
    Add a new ammo into this bay.
    boolean
    addBayWeapon(megamek.common.equipment.Mounted<?> weapon)
    Add a new weapon into this bay.
    boolean
    allHaveAugmentation(megamek.common.equipment.EquipmentFlag flag)
     
    boolean
    Determines if two WeaponBayTexts are laterally similar and hence can be combined.
    void
    Combine two WeaponBayTexts.
    int
    Compare two WeaponBayTexts based upon location
    int
    countAugmentations(megamek.common.equipment.EquipmentFlag flag)
     
    int
    countAugmentations(megamek.common.equipment.WeaponType weaponType, megamek.common.equipment.EquipmentFlag flag)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • loc

      public List<Integer> loc
      The location of the bay, or locations if multiple identical bays are combined.
  • Constructor Details

    • WeaponBayText

      public WeaponBayText(int l, boolean rear)
      Parameters:
      l - The location index
      rear - Whether the bay is rear mounted (dropship wing/aft sides)
  • Method Details

    • addBayWeapon

      public boolean addBayWeapon(megamek.common.equipment.Mounted<?> weapon)
      Add a new weapon into this bay.
      Parameters:
      weapon - The weapon to add to the bay
      Returns:
      Whether true if the weapon was added as new, false if it was already in the bay and just incremented
    • addBayAmmo

      public void addBayAmmo(megamek.common.equipment.WeaponType weaponType, megamek.common.equipment.AmmoMounted ammo)
      Add a new ammo into this bay.
      Parameters:
      ammo - The ammo to add to the bay
    • canCombine

      public boolean canCombine(WeaponBayText other)
      Determines if two WeaponBayTexts are laterally similar and hence can be combined. That is, if there is a weapon bay on the left side that is identical to one on the right side, then those two can be combined in a location like FRS/FLS. This allows weapon lists to be compacted.
      Parameters:
      other - The other instance
      Returns:
      Whether the two bays are identical
    • combine

      public void combine(WeaponBayText other)
      Combine two WeaponBayTexts. Since they should both contain the same weapons, the only thing that needs to be updated is the locations. This should only be called if canCombine returns true for both WeaponBayTexts.
      Parameters:
      other - The other bay to combine with this one
    • countAugmentations

      public int countAugmentations(megamek.common.equipment.EquipmentFlag flag)
      Parameters:
      flag - A MiscType flag
      Returns:
      The number of weapons in the entire bay linked by equipment with the given flag
    • countAugmentations

      public int countAugmentations(megamek.common.equipment.WeaponType weaponType, megamek.common.equipment.EquipmentFlag flag)
      Parameters:
      weaponType - A type of weapon in the bay
      flag - A MiscType flag
      Returns:
      The number of weapons of the given type in the bay linked by equipment with the given flag
    • allHaveAugmentation

      public boolean allHaveAugmentation(megamek.common.equipment.EquipmentFlag flag)
      Parameters:
      flag - A MiscType flag
      Returns:
      Whether all weapons in the bay are linked by equipment with the given flag
    • compareTo

      public int compareTo(WeaponBayText o)
      Compare two WeaponBayTexts based upon location
      Specified by:
      compareTo in interface Comparable<WeaponBayText>