Package megamek.common.units
Class InfantryCompartment
java.lang.Object
megamek.common.units.InfantryCompartment
- All Implemented Interfaces:
Serializable,Transporter,InfantryTransporter
Represents a volume of space set aside for carrying troops and their equipment under battle conditions. Typically, a
component of an APC.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionInfantryCompartment(double space) Create a space for the given tonnage of troops. -
Method Summary
Modifier and TypeMethodDescriptionbooleanDetermines if this object can accept the given unit.intgetCargoMpReduction(Entity carrier) getExteriorUnitAt(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.Get aListof the units currently loaded into this payload.doubledoubleReturn a string that identifies the unused capacity of this transporter.booleanisWeaponBlockedAt(int loc, boolean isRear) Determine if transported units prevent a weapon in the given location from firing.voidLoad the given unit.voidclear out all troops listed in the transporter.voiddoublespaceForUnit(Entity unit) toString()booleanUnload 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.units.InfantryTransporter
getCurrentDoorsMethods inherited from interface megamek.common.equipment.Transporter
alwaysDamageCargoIfTransportHit, canPickupGroundObject, canTow, getCarryables, getNameForRecordSheets, getNumberLoadedThisTurn, getNumberUnloadedThisTurn, hardpointCost, setEntity
-
Constructor Details
-
InfantryCompartment
public InfantryCompartment(double space) 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
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 interfaceInfantryTransporter- Specified by:
canLoadin interfaceTransporter- Parameters:
unit- - theEntityto be loaded.- Returns:
trueif the unit can be loaded,falseotherwise.
-
load
Load the given unit.- Specified by:
loadin interfaceInfantryTransporter- Specified by:
loadin interfaceTransporter- Parameters:
unit- theEntityto be loaded.- Throws:
IllegalArgumentException- If the unit can't be loaded
-
getLoadedUnits
Get aListof the units currently loaded into this payload.- Specified by:
getLoadedUnitsin interfaceInfantryTransporter- 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.
-
unload
Unload 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.- Specified by:
getUnusedStringin interfaceTransporter- Returns:
- A
Stringmeant for a human.
-
getUnused
public double getUnused()- Specified by:
getUnusedin interfaceInfantryTransporter- Specified by:
getUnusedin interfaceTransporter- Returns:
- the number of unused spaces in this transporter.
-
isWeaponBlockedAt
public boolean isWeaponBlockedAt(int loc, boolean isRear) Determine if transported units prevent a weapon in the given location from firing.- Specified by:
isWeaponBlockedAtin interfaceTransporter- Parameters:
loc- - theintlocation attempting to fire.isRear- - abooleanvalue stating if the given location is rear facing; iffalse, the location is front facing.- Returns:
trueif a transported unit is in the way,falseif the weapon can fire.
-
getExteriorUnitAt
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:
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.
-
getUnusedSlots
public double getUnusedSlots()- Specified by:
getUnusedSlotsin interfaceInfantryTransporter- 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.
-
getDroppableUnits
- Specified by:
getDroppableUnitsin interfaceInfantryTransporter- Returns:
- A (possibly empty) list of units from this bay that can be assault-dropped.
-
spaceForUnit
- Specified by:
spaceForUnitin interfaceInfantryTransporter
-
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
-
toString
-
getTransporterType
- Specified by:
getTransporterTypein interfaceInfantryTransporter- Specified by:
getTransporterTypein interfaceTransporter
-
setGame
- Specified by:
setGamein interfaceTransporter
-
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
-