Class CargoBay

java.lang.Object
megamek.common.bays.Bay
megamek.common.bays.CargoBay
All Implemented Interfaces:
Serializable, Transporter, ITechnology, InfantryTransporter

public final class CargoBay extends Bay implements InfantryTransporter
Represents a volume of space set aside for carrying general cargo aboard large spacecraft and mobile structures.
See Also:
  • Constructor Details

    • CargoBay

      public CargoBay(double space, int doors, int bayNumber)
      Create a space for the given tonnage of troops. For this class, only the weight of the troops (and their equipment) are considered; if you'd like to think that they are stacked like lumber, be my guest.
      Parameters:
      space - The weight of troops (in tons) this space can carry.
  • Method Details

    • canLoad

      public boolean canLoad(Entity unit)
      Description copied from interface: Transporter
      Determines if this object can accept the given unit. The unit may not be of the appropriate type or there may be no room for the unit.
      Specified by:
      canLoad in interface InfantryTransporter
      Specified by:
      canLoad in interface Transporter
      Overrides:
      canLoad in class Bay
      Parameters:
      unit - - the Entity to be loaded.
      Returns:
      true if the unit can be loaded, false otherwise.
    • canUnloadUnits

      public boolean canUnloadUnits()
      Overrides:
      canUnloadUnits in class Bay
      Returns:
      True when further doors are available to unload units this turn. This method checks only the state of bay doors, not if it has units left to unload or the status of those.
    • spaceForUnit

      public double spaceForUnit(Entity unit)
      Description copied from class: Bay
      Most bay types track space by individual units. Infantry bays have variable space requirements and must track by cubicle tonnage.
      Specified by:
      spaceForUnit in interface InfantryTransporter
      Overrides:
      spaceForUnit in class Bay
      Parameters:
      unit - The unit to load/unload.
      Returns:
      The amount of bay space taken up by the unit.
    • getUnusedString

      public String getUnusedString(boolean showRecovery)
      Description copied from class: Bay
      Return a string that identifies the unused capacity of this transporter.
      Overrides:
      getUnusedString in class Bay
      Returns:
      A String meant for a human.
    • getTransporterType

      public String getTransporterType()
      Specified by:
      getTransporterType in interface InfantryTransporter
      Specified by:
      getTransporterType in interface Transporter
    • toString

      public String toString()
      Description copied from class: Bay
      Updated toString() and helpers to normalize bay string output To match new 6-field format: type:space(current or total):doors:bayNumber:infantryType:facing:status bitmap See BLKFile.java:BLKFile constants
      Overrides:
      toString in class Bay
    • isCargo

      public boolean isCargo()
      Overrides:
      isCargo in class Bay
      Returns:
      true if this bay represents cargo capacity rather than unit transport or crew quarters.