Package megamek.common.bays
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
Represents a volume of space set aside for carrying cargo of some sort aboard large spacecraft and mobile structures
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected intprotected doubleThe current amount of space not occupied by troops or cargo.protected doubleprotected intprotected intstatic final Stringstatic final Stringprotected Gameprotected intprotected intprotected doubleThe total amount of space available for troops.The troops being carried.protected intstatic final intFields inherited from interface megamek.common.interfaces.ITechnology
DATE_ES, DATE_NONE, DATE_PS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic TechAdvancementShared by several types of baysbayString(String bayType, double space, int doors, int bayNumber, String infType, int facing, int bitmap) booleanDetermines if this object can accept the given unit.booleanvoidvoidDestroys a door for next turn.getBaseAvailability(Era era) doubleBay damage to unit transport bays is tracked by number of cubicles/units.intdoubleintgetCargoMpReduction(Entity carrier) intlonggetCost()intintgetDoors()intgetExteriorUnitAt(int loc, boolean isRear) If a unit is being transported on the outside of the transporter, it can suffer damage when the transporter is hit by an attack.intintgetExtinctionDate(boolean clan, Faction faction) intSome bays (drop-shuttle and repair facility) have a maximum number per armor facing.intintgetIntroductionDate(boolean clan, Faction faction) Generate a raw list of the Ids stored in troops.Get aVectorof the units currently loaded into this payload.intintDeprecated, for removal: This API element is subject to removal in a future version.intReturns the number of units loaded on to this transporter this turn.intgetPersonnel(boolean clan) intintgetProductionDate(boolean clan, Faction faction) intintgetPrototypeDate(boolean clan, Faction faction) intintgetReintroductionDate(boolean clan, Faction faction) intFor non-era-based usage, provide a single tech level that does not vary with date.doubledoubleReturn a string that identifies the unused capacity of this transporter.getUnusedString(boolean showRecovery) Return a string that identifies the unused capacity of this transporter.doublebooleanisCargo()booleanisClan()booleanbooleanbooleanisWeaponBlockedAt(int loc, boolean isRear) Determine if transported units prevent a weapon in the given location from firing.voidLoad the given unit.protected Stringvoidvoidvoidclear out all troops listed in the transporter.voidDeprecated, for removal: This API element is subject to removal in a future version.voidDeprecated, for removal: This API element is subject to removal in a future version.voidsetBayDamage(double damage) Bay damage to unit transport bays is tracked by number of cubicles/units.voidsetCurrentDoors(int d) voidsetCurrentSpace(double space) Method used by MHQ to update bay space when loading units in lobby.voidsetDoors(int d) voidsetDoorsNext(int d) voidsetFacing(int facing) Sets the armor facing for the bay, if the bay type requires it.voiddoublespaceForUnit(Entity unit) Most bay types track space by individual units.static TechAdvancementtoString()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 constantsbooleanUnload the given unit.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface megamek.common.interfaces.ITechnology
calcEraAvailability, calcEraAvailability, calcYearAvailability, calcYearAvailability, calcYearAvailability, findMinimumRulesLevel, findMinimumRulesLevel, getAdvancedRange, getAdvancedRange, getCodeFromIOAbbr, getCodeFromMMAbbr, getCommonDate, getEraAvailabilityName, getEraAvailabilityName, getExperimentalRange, getExperimentalRange, getExtinctionDate, getExtinctionRange, getExtinctionRange, getFullRatingName, getFullRatingName, getIntroductionDate, getProductionDate, getPrototypeDate, getReintroductionDate, getSimpleLevel, getSimpleLevel, getSimpleLevel, getStandardRange, getStandardRange, getTechLevel, getTechLevel, getTechRatingName, isAvailableIn, isAvailableIn, isAvailableIn, isExtinct, isExtinct, isExtinct, isIntroLevel, isLegal, isLegal, isUnofficialMethods inherited from interface megamek.common.equipment.Transporter
alwaysDamageCargoIfTransportHit, canPickupGroundObject, canTow, getCarryables, getNameForRecordSheets, getTransporterType, hardpointCost, setEntity
-
Field Details
-
UNSET_BAY
public static final int UNSET_BAY- See Also:
-
FIELD_SEPARATOR
- See Also:
-
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
-
bayNumber
protected int bayNumber -
game
-
damage
protected double damage -
troops
The troops being carried. -
totalSpace
protected double totalSpaceThe total amount of space available for troops. -
currentSpace
protected double currentSpaceThe 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 doorsbayNumber- 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
-
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
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:Transporterclear out all troops listed in the transporter. Used by MHQ to reset units after game- Specified by:
resetTransporterin interfaceTransporter
-
canLoad
Description copied from interface:TransporterDetermines 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:
canLoadin interfaceTransporter- Parameters:
unit- - theEntityto be loaded.- Returns:
trueif the unit can be loaded,falseotherwise.
-
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
Description copied from interface:TransporterLoad the given unit.- Specified by:
loadin interfaceTransporter- Parameters:
unit- theEntityto be loaded.- Throws:
IllegalArgumentException- If the unit can't be loaded
-
getLoadedUnits
Description copied from interface:TransporterGet aVectorof the units currently loaded into this payload.- Specified by:
getLoadedUnitsin interfaceTransporter- Returns:
- A
Listof loadedEntityunits. This list will never benull, but it may be empty. The returnedListis independent of the underlying data structure; modifying one does not affect the other.
-
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
- Returns:
- A (possibly empty) list of units from this bay that can be launched. Units in recovery cannot launch.
-
getDroppableUnits
- Returns:
- A (possibly empty) list of units from this bay that can be assault-dropped.
-
getUnloadableUnits
- Returns:
- A (possibly empty) list of units from this bay that can be unloaded on the ground.
-
unload
Description copied from interface:TransporterUnload the given unit.- Specified by:
unloadin interfaceTransporter- Parameters:
unit- - theEntityto be unloaded.- Returns:
trueif the unit was contained in this space,falseotherwise.
-
getUnusedString
Return a string that identifies the unused capacity of this transporter.- Returns:
- A
Stringmeant for a human.
-
numDoorsString
-
getUnusedString
Description copied from interface:TransporterReturn a string that identifies the unused capacity of this transporter.- Specified by:
getUnusedStringin interfaceTransporter- Returns:
- A
Stringmeant for a human.
-
getUnused
public double getUnused()- Specified by:
getUnusedin interfaceTransporter- 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
- 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:TransporterDetermine if transported units prevent a weapon in the given location from firing.- Specified by:
isWeaponBlockedAtin interfaceTransporter- 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
Description copied from interface:TransporterIf 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:
getExteriorUnitAtin interfaceTransporter- Parameters:
loc- - theintlocation hit by attack.isRear- - abooleanvalue stating if the given location is rear facing; iffalse, the location is front facing.- Returns:
- The
Entitybeing transported on the outside at that location. This value will benullif no unit is transported on the outside at that location.
-
getExternalUnits
- Specified by:
getExternalUnitsin interfaceTransporter- Returns:
- list of all units carried externally by this transporter
-
getCargoMpReduction
- Specified by:
getCargoMpReductionin interfaceTransporter- 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, for removal: This API element is subject to removal in a future version. -
restoreAllDoors
Deprecated, for removal: This API element is subject to removal in a future version. -
getNumberUnloadedThisTurn
public int getNumberUnloadedThisTurn()Description copied from interface:TransporterReturns the number of units loaded on to this transporter this turn. Used to determine loading eligibility- Specified by:
getNumberUnloadedThisTurnin interfaceTransporter- Returns:
- the number of units loaded
-
getNumberLoadedThisTurn
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:TransporterReturns the number of units loaded on to this transporter this turn. Used to determine loading eligibility- Specified by:
getNumberLoadedThisTurnin interfaceTransporter- 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
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 -
bayString
-
bayString
-
bayString
-
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
- Specified by:
setGamein interfaceTransporter
-
techAdvancement
-
artsTechAdvancement
Shared by several types of bays- Returns:
- Tech advancement for advanced robotic transport system.
-
getTechAdvancement
-
isClan
public boolean isClan()- Specified by:
isClanin interfaceITechnology
-
isMixedTech
public boolean isMixedTech()- Specified by:
isMixedTechin interfaceITechnology
-
getTechBase
- Specified by:
getTechBasein interfaceITechnology
-
getIntroductionDate
public int getIntroductionDate()- Specified by:
getIntroductionDatein interfaceITechnology
-
getPrototypeDate
public int getPrototypeDate()- Specified by:
getPrototypeDatein interfaceITechnology
-
getProductionDate
public int getProductionDate()- Specified by:
getProductionDatein interfaceITechnology
-
getCommonDate
public int getCommonDate()- Specified by:
getCommonDatein interfaceITechnology
-
getExtinctionDate
public int getExtinctionDate()- Specified by:
getExtinctionDatein interfaceITechnology
-
getReintroductionDate
public int getReintroductionDate()- Specified by:
getReintroductionDatein interfaceITechnology
-
getTechRating
- Specified by:
getTechRatingin interfaceITechnology
-
getBaseAvailability
- Specified by:
getBaseAvailabilityin interfaceITechnology
-
getIntroductionDate
- Specified by:
getIntroductionDatein interfaceITechnology
-
getPrototypeDate
- Specified by:
getPrototypeDatein interfaceITechnology
-
getProductionDate
- Specified by:
getProductionDatein interfaceITechnology
-
getExtinctionDate
- Specified by:
getExtinctionDatein interfaceITechnology
-
getReintroductionDate
- Specified by:
getReintroductionDatein interfaceITechnology
-
getStaticTechLevel
Description copied from interface:ITechnologyFor non-era-based usage, provide a single tech level that does not vary with date.- Specified by:
getStaticTechLevelin interfaceITechnology- 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
-