Class Bay

java.lang.Object
megamek.common.bays.Bay
All Implemented Interfaces:
Serializable, Transporter, ITechnology
Direct Known Subclasses:
BattleArmorBay, CargoBay, CrewQuartersCargoBay, FirstClassQuartersCargoBay, InfantryBay, InsulatedCargoBay, LiquidCargoBay, LivestockCargoBay, RefrigeratedCargoBay, SecondClassQuartersCargoBay, StandardSeatCargoBay, SteerageQuartersCargoBay, UnitBay

public class Bay extends Object implements Transporter, ITechnology
Represents a volume of space set aside for carrying cargo of some sort aboard large spacecraft and mobile structures
See Also:
  • Field Details

    • UNSET_BAY

      public static final int UNSET_BAY
      See Also:
    • FIELD_SEPARATOR

      public static final String FIELD_SEPARATOR
      See Also:
    • FACING_PREFIX

      public static final String FACING_PREFIX
      See Also:
    • minDoors

      protected int minDoors
    • doors

      protected int doors
    • doorsNext

      protected int doorsNext
    • currentDoors

      protected int currentDoors
    • unloadedThisTurn

      protected int unloadedThisTurn
    • loadedThisTurn

      protected int loadedThisTurn
    • recoverySlots

      protected List<Integer> recoverySlots
    • bayNumber

      protected int bayNumber
    • game

      protected transient Game game
    • damage

      protected double damage
    • troops

      protected Vector<Integer> troops
      The troops being carried.
    • totalSpace

      protected double totalSpace
      The total amount of space available for troops.
    • currentSpace

      protected double currentSpace
      The current amount of space not occupied by troops or cargo.
  • Constructor Details

    • Bay

      protected Bay()
      The default constructor is only for serialization.
    • Bay

      public Bay(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.
      doors - The number of bay doors
      bayNumber - The id number for the bay
  • Method Details

    • getBayDamage

      public double getBayDamage()
      Bay damage to unit transport bays is tracked by number of cubicles/units. Damage to cargo bays is tracked by cargo tonnage.
      Returns:
      The reduction of bay capacity due to damage.
    • setBayDamage

      public void setBayDamage(double damage)
      Bay damage to unit transport bays is tracked by number of cubicles/units. Damage to cargo bays is tracked by cargo tonnage.
      Parameters:
      damage - The total amount of bay capacity reduced due to damage.
    • setCurrentSpace

      public void setCurrentSpace(double space)
      Method used by MHQ to update bay space when loading units in lobby. See Utilities.loadPlayerTransports This ensures that consumed space is kept in sync between the MM client and MHQ game thread
      Parameters:
      space - - double representing space consumed by the unit being loaded. 1 except in the case of infantry
    • getDoors

      public int getDoors()
    • getMinDoors

      public int getMinDoors()
    • setDoors

      public void setDoors(int d)
    • getTroops

      public Vector<Integer> getTroops()
    • getCurrentDoors

      public int getCurrentDoors()
    • setCurrentDoors

      public void setCurrentDoors(int d)
    • setDoorsNext

      public void setDoorsNext(int d)
    • getDoorsNext

      public int getDoorsNext()
    • resetDoors

      public void resetDoors()
    • resetCounts

      public void resetCounts()
    • spaceForUnit

      public double spaceForUnit(Entity unit)
      Most bay types track space by individual units. Infantry bays have variable space requirements and must track by cubicle tonnage.
      Parameters:
      unit - The unit to load/unload.
      Returns:
      The amount of bay space taken up by the unit.
    • resetTransporter

      public void resetTransporter()
      Description copied from interface: Transporter
      clear out all troops listed in the transporter. Used by MHQ to reset units after game
      Specified by:
      resetTransporter in interface Transporter
    • 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 Transporter
      Parameters:
      unit - - the Entity to be loaded.
      Returns:
      true if the unit can be loaded, false otherwise.
    • canUnloadUnits

      public boolean canUnloadUnits()
      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.
    • load

      public void load(Entity unit) throws IllegalArgumentException
      Description copied from interface: Transporter
      Load the given unit.
      Specified by:
      load in interface Transporter
      Parameters:
      unit - the Entity to be loaded.
      Throws:
      IllegalArgumentException - If the unit can't be loaded
    • getLoadedUnits

      public Vector<Entity> getLoadedUnits()
      Description copied from interface: Transporter
      Get a Vector of the units currently loaded into this payload.
      Specified by:
      getLoadedUnits in interface Transporter
      Returns:
      A List of loaded Entity units. This list will never be null, but it may be empty. The returned List is independent of the underlying data structure; modifying one does not affect the other.
    • getLoadedUnitIds

      public List<Integer> getLoadedUnitIds()
      Generate a raw list of the Ids stored in troops. Used by MHQ in cases where we can't get the entities via Game
      Returns:
      A list of unit IDs of loaded units
    • getLaunchableUnits

      public List<Entity> getLaunchableUnits()
      Returns:
      A (possibly empty) list of units from this bay that can be launched. Units in recovery cannot launch.
    • getDroppableUnits

      public List<Entity> getDroppableUnits()
      Returns:
      A (possibly empty) list of units from this bay that can be assault-dropped.
    • getUnloadableUnits

      public List<Entity> getUnloadableUnits()
      Returns:
      A (possibly empty) list of units from this bay that can be unloaded on the ground.
    • unload

      public boolean unload(Entity unit)
      Description copied from interface: Transporter
      Unload the given unit.
      Specified by:
      unload in interface Transporter
      Parameters:
      unit - - the Entity to be unloaded.
      Returns:
      true if the unit was contained in this space, false otherwise.
    • getUnusedString

      public String getUnusedString(boolean showRecovery)
      Return a string that identifies the unused capacity of this transporter.
      Returns:
      A String meant for a human.
    • numDoorsString

      protected String numDoorsString()
    • getUnusedString

      public String getUnusedString()
      Description copied from interface: Transporter
      Return a string that identifies the unused capacity of this transporter.
      Specified by:
      getUnusedString in interface Transporter
      Returns:
      A String meant for a human.
    • getUnused

      public double getUnused()
      Specified by:
      getUnused in interface Transporter
      Returns:
      the number of unused spaces in this transporter.
    • getUnusedSlots

      public double getUnusedSlots()
      Returns:
      The amount of unused space in the bay expressed in slots. For most bays this is the same as the unused space, but bays for units that can take up a variable amount of space (such as infantry bays) this calculates the number of the default unit size that can fit into the remaining space.
    • getDefaultSlotDescription

      public String getDefaultSlotDescription()
      Returns:
      A String that describes the default slot type. Only meaningful for bays with variable space requirements (like infantry).
    • isWeaponBlockedAt

      public boolean isWeaponBlockedAt(int loc, boolean isRear)
      Description copied from interface: Transporter
      Determine if transported units prevent a weapon in the given location from firing.
      Specified by:
      isWeaponBlockedAt in interface Transporter
      Parameters:
      loc - the location attempting to fire.
      isRear - true if the weapon is rear-facing
      Returns:
      True if a transported unit is in the way, false if the weapon can fire.
    • getExteriorUnitAt

      public Entity getExteriorUnitAt(int loc, boolean isRear)
      Description copied from interface: Transporter
      If a unit is being transported on the outside of the transporter, it can suffer damage when the transporter is hit by an attack. Currently, no more than one unit can be at any single location; that same unit can be "spread" over multiple locations.
      Specified by:
      getExteriorUnitAt in interface Transporter
      Parameters:
      loc - - the int location hit by attack.
      isRear - - a boolean value stating if the given location is rear facing; if false, the location is front facing.
      Returns:
      The Entity being transported on the outside at that location. This value will be null if no unit is transported on the outside at that location.
    • getExternalUnits

      public final List<Entity> getExternalUnits()
      Specified by:
      getExternalUnits in interface Transporter
      Returns:
      list of all units carried externally by this transporter
    • getCargoMpReduction

      public int getCargoMpReduction(Entity carrier)
      Specified by:
      getCargoMpReduction in interface Transporter
      Returns:
      the MP reduction due to cargo carried by this transporter
    • destroyDoorNext

      public void destroyDoorNext()
      Destroys a door for next turn.
    • destroyDoor

      public void destroyDoor()
    • restoreDoor

      @Deprecated(since="0.51.0", forRemoval=true) public void restoreDoor()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • restoreAllDoors

      @Deprecated(since="0.51.0", forRemoval=true) public void restoreAllDoors()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getNumberUnloadedThisTurn

      public int getNumberUnloadedThisTurn()
      Description copied from interface: Transporter
      Returns the number of units loaded on to this transporter this turn. Used to determine loading eligibility
      Specified by:
      getNumberUnloadedThisTurn in interface Transporter
      Returns:
      the number of units loaded
    • getNumberLoadedThisTurn

      @Deprecated(since="0.51.0", forRemoval=true) public int getNumberLoadedThisTurn()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: Transporter
      Returns the number of units loaded on to this transporter this turn. Used to determine loading eligibility
      Specified by:
      getNumberLoadedThisTurn in interface Transporter
      Returns:
      the number of units loaded
    • getWeight

      public double getWeight()
      Returns:
      the tonnage of the bay, not the actual mass or weight
    • getPersonnel

      public int getPersonnel(boolean clan)
      Parameters:
      clan - Whether the bay is installed in a Clan unit. Needed for infantry bays.
      Returns:
      The number of additional crew provided by the bay. This includes transport bays only; crew quarters are already accounted for in the crew total.
    • toString

      public String toString()
      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 Object
    • bayString

      public String bayString(String bayType, double space, int doors, int bayNumber, String infType, int facing, int bitmap)
    • bayString

      public String bayString(String bayType, double space, int doors, int bayNumber)
    • bayString

      public String bayString(String bayType, double space, int doors)
    • getCapacity

      public double getCapacity()
      Returns:
      The total size of the bay.
    • getBayNumber

      public int getBayNumber()
    • getFacing

      public int getFacing()
      Some bays (drop-shuttle and repair facility) have a maximum number per armor facing.
      Returns:
      The facing of the bay, or Entity.LOC_NONE if the bay does not require a facing.
    • setFacing

      public void setFacing(int facing)
      Sets the armor facing for the bay, if the bay type requires it. If not required by the bay type, does nothing.
      Parameters:
      facing - The location to use for the facing.
    • setGame

      public void setGame(Game game)
      Specified by:
      setGame in interface Transporter
    • techAdvancement

      public static TechAdvancement techAdvancement()
    • artsTechAdvancement

      public static TechAdvancement artsTechAdvancement()
      Shared by several types of bays
      Returns:
      Tech advancement for advanced robotic transport system.
    • getTechAdvancement

      public TechAdvancement getTechAdvancement()
    • isClan

      public boolean isClan()
      Specified by:
      isClan in interface ITechnology
    • isMixedTech

      public boolean isMixedTech()
      Specified by:
      isMixedTech in interface ITechnology
    • getTechBase

      public TechBase getTechBase()
      Specified by:
      getTechBase in interface ITechnology
    • getIntroductionDate

      public int getIntroductionDate()
      Specified by:
      getIntroductionDate in interface ITechnology
    • getPrototypeDate

      public int getPrototypeDate()
      Specified by:
      getPrototypeDate in interface ITechnology
    • getProductionDate

      public int getProductionDate()
      Specified by:
      getProductionDate in interface ITechnology
    • getCommonDate

      public int getCommonDate()
      Specified by:
      getCommonDate in interface ITechnology
    • getExtinctionDate

      public int getExtinctionDate()
      Specified by:
      getExtinctionDate in interface ITechnology
    • getReintroductionDate

      public int getReintroductionDate()
      Specified by:
      getReintroductionDate in interface ITechnology
    • getTechRating

      public TechRating getTechRating()
      Specified by:
      getTechRating in interface ITechnology
    • getBaseAvailability

      public AvailabilityValue getBaseAvailability(Era era)
      Specified by:
      getBaseAvailability in interface ITechnology
    • getIntroductionDate

      public int getIntroductionDate(boolean clan, Faction faction)
      Specified by:
      getIntroductionDate in interface ITechnology
    • getPrototypeDate

      public int getPrototypeDate(boolean clan, Faction faction)
      Specified by:
      getPrototypeDate in interface ITechnology
    • getProductionDate

      public int getProductionDate(boolean clan, Faction faction)
      Specified by:
      getProductionDate in interface ITechnology
    • getExtinctionDate

      public int getExtinctionDate(boolean clan, Faction faction)
      Specified by:
      getExtinctionDate in interface ITechnology
    • getReintroductionDate

      public int getReintroductionDate(boolean clan, Faction faction)
      Specified by:
      getReintroductionDate in interface ITechnology
    • getStaticTechLevel

      public SimpleTechLevel getStaticTechLevel()
      Description copied from interface: ITechnology
      For non-era-based usage, provide a single tech level that does not vary with date.
      Specified by:
      getStaticTechLevel in interface ITechnology
      Returns:
      The base rules level of the equipment or unit.
    • isQuarters

      public boolean isQuarters()
      Returns:
      true if this bay represents crew quarters or seating rather than a unit transport bay.
    • isCargo

      public boolean isCargo()
      Returns:
      true if this bay represents cargo capacity rather than unit transport or crew quarters.
    • getCost

      public long getCost()
      Returns:
      The cost of the bay in C-bills
    • getSafeLaunchRate

      public int getSafeLaunchRate()
      Returns:
      The safe launch rate for this particular bay: # of intact doors x 2