Package megamek.common.equipment
Class ExternalCargo
java.lang.Object
megamek.common.equipment.ExternalCargo
- All Implemented Interfaces:
Serializable,Transporter
Unprotected cargo transporter. Miscellaneous transporters that don't properly protect their cargo like a bay or
infantry compartment, but support cargo unlike clamp mounts or BA Handles.
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedExternalCargo(double tonnage, List<Integer> validPickupLocations) protectedExternalCargo(Entity entity) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancanLoad()If this specific transporter is capable of loading regardless of what the object is.booleanDetermines if this object can accept the given unit.booleancanLoadCarryable(ICarryable carryable) Determines if this object can accept the givenICarryable.intgetCargoMpReduction(Entity carrier) doubleRetrieves a list of allICarryableobjects currently carried by this transporter.getCarryables(int location) Retrieves a list ofICarryableobjects currently carried at the specified location.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 aVectorof the units currently loaded into this payload.Retrieves a list of valid pickup locations for this transporter.doubleReturn 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.voidloadCarryable(ICarryable carryable) Load the given carryable into the given locationvoidloadCarryable(ICarryable carryable, int location) Load the given carryable into the given locationprotected booleanmaxObjects(int location) voidclear out all troops listed in the transporter.voidExternal cargo transporters often need to get information about the entity, like if its TSM is active.voidbooleanUnload the given unit.booleanunloadCarryable(ICarryable carryable) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface megamek.common.equipment.Transporter
alwaysDamageCargoIfTransportHit, canPickupGroundObject, canTow, getNameForRecordSheets, getNumberLoadedThisTurn, getNumberUnloadedThisTurn, getTransporterType, hardpointCost
-
Field Details
-
game
-
entity
-
entityId
protected int entityId -
totalSpace
protected double totalSpaceThe total amount of space available for objects.
-
-
Constructor Details
-
ExternalCargo
-
ExternalCargo
-
-
Method Details
-
canLoad
protected boolean canLoad()If this specific transporter is capable of loading regardless of what the object is.- Returns:
trueif the transporter is capable of loading,falseotherwise.
-
canLoad
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:
canLoadin interfaceTransporter- Parameters:
unit- - theEntityto be loaded.- Returns:
trueif the unit can be loaded,falseotherwise.
-
canLoadCarryable
Determines if this object can accept the givenICarryable. The carryable may not be of the appropriate type or there may be room for the unit.- Parameters:
carryable- theICarryableto be loaded- Returns:
trueif the carryable can be loaded,falseotherwise.
-
load
Load the given unit.- Specified by:
loadin interfaceTransporter- Parameters:
unit- theEntityto be loaded.- Throws:
IllegalArgumentException- If the unit can't be loaded
-
loadCarryable
Load the given carryable into the given location- Parameters:
carryable- theICarryableto be loaded- Throws:
IllegalArgumentException- If the unit can't be loaded
-
loadCarryable
Load the given carryable into the given location- Parameters:
carryable- theICarryableto be loadedlocation- the location it should be loaded into- Throws:
IllegalArgumentException- If the unit can't be loaded
-
getLoadedUnits
Get 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 from the underlying data structure; modifying one does not affect the other.
-
getCarryables
Retrieves a list of allICarryableobjects currently carried by this transporter. If no objects are being carried, the returned list will be empty.The returned list is a separate instance and modifying it will not affect the underlying data structure of carried objects.
- Specified by:
getCarryablesin interfaceTransporter- Returns:
- a list of
ICarryableobjects currently carried. Never null, but may be empty.
-
getCarryables
Retrieves a list ofICarryableobjects currently carried at the specified location. If no objects are being carried at the given location, the returned list will be empty.The returned list is a separate instance and modifying it will not affect the underlying data structure of carried objects.
- Parameters:
location- the integer value representing the location to check for carried objects- Returns:
- a list of
ICarryableobjects at the specified location. The list is never null, but it may be empty.
-
getLocations
Retrieves a list of valid pickup locations for this transporter. The returned list is a new instance and modifying it will not affect the underlying data structure of valid pickup locations.- Returns:
- a list of integers representing valid pickup locations. The list will never be null, but it may be empty.
-
unload
Unload the given unit.- Specified by:
unloadin interfaceTransporter- Parameters:
unit- - theEntityto be unloaded.- Returns:
trueif the unit was contained in this space,falseotherwise.
-
unloadCarryable
-
getUnused
public double getUnused()- Specified by:
getUnusedin interfaceTransporter- Returns:
- the number of unused spaces in this transporter.
-
getCarriedTonnage
public double getCarriedTonnage() -
getUnusedString
Return a string that identifies the unused capacity of this transporter.- Specified by:
getUnusedStringin interfaceTransporter- Returns:
- A
Stringmeant for a human.
-
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- 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
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.
-
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
-
setGame
- Specified by:
setGamein interfaceTransporter
-
resetTransporter
public void resetTransporter()clear out all troops listed in the transporter. Used by MHQ to reset units after game- Specified by:
resetTransporterin interfaceTransporter
-
maxObjects
protected boolean maxObjects(int location) -
setEntity
External cargo transporters often need to get information about the entity, like if its TSM is active. If this transporter doesn't have an entity, let's set it. Tries to set entityId as well but the entity might not have that if the entity doesn't have a game yet.- Specified by:
setEntityin interfaceTransporter- Parameters:
entity- the entity to associate with this transporter
-