Package megamek.common.equipment
Class TankTrailerHitch
java.lang.Object
megamek.common.equipment.TankTrailerHitch
- All Implemented Interfaces:
Serializable,Transporter
Represents a trailer hitch that allows a wheeled or tracked vehicle to tow trailers.
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTankTrailerHitch(boolean rear) Create a new hitch, specified as a (front) or rear mount. -
Method Summary
Modifier and TypeMethodDescriptionbooleanDetermines if this object can accept the given unit.booleanDetermines if this transporter can tow the given unit.intgetCargoMpReduction(Entity carrier) final EntitygetExteriorUnitAt(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.booleandoublefinal StringReturn a string that identifies the unused capacity of this transporter.protected StringgetVacancyString(boolean isLoaded) Get theStringto report the presence (or lack thereof) of a towed trailer.booleanisWeaponBlockedAt(int loc, boolean isRear) Determine if transported units prevent a weapon in the given location from firing.final voidLoad the given unit.voidclear out all troops listed in the transporter.voidtoString()final 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.equipment.Transporter
alwaysDamageCargoIfTransportHit, canPickupGroundObject, getCarryables, getNameForRecordSheets, getNumberLoadedThisTurn, getNumberUnloadedThisTurn, getTransporterType, hardpointCost, setEntity
-
Field Details
-
towed
protected int towedThe entity being towed by this hitch.
-
-
Constructor Details
-
TankTrailerHitch
public TankTrailerHitch(boolean rear) Create a new hitch, specified as a (front) or rear mount.
-
-
Method Details
-
getRearMounted
public boolean getRearMounted() -
getVacancyString
Get theStringto report the presence (or lack thereof) of a towed trailer.Subclasses are encouraged to override this method.
- Parameters:
isLoaded- - abooleanthat indicates a trailer is currently loaded (if the value istrue) or not (if the value isfalse).- Returns:
- a
Stringdescribing the occupancy state of this transporter.
-
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.
-
canTow
Description copied from interface:TransporterDetermines if this transporter can tow the given unit. By default, no.- Specified by:
canTowin interfaceTransporter
-
load
Load the given unit.- 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 interfaceTransporter- Returns:
- A
Vectorof loadedEntityunits. This list will never benull, but it may be empty. The returnedListis independent of the under-lying 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 is loaded in this space,falseotherwise.
-
getUnusedString
Return a string that identifies the unused capacity of this transporter.Subclasses should override the
getVacancyStringmethod.- Specified by:
getUnusedStringin interfaceTransporter- Returns:
- A
Stringmeant for a human. - See Also:
-
getUnused
public double getUnused()- Specified by:
getUnusedin interfaceTransporter- Returns:
- the number of unused spaces in this transporter.
-
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
-
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.
-
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
-
setGame
- Specified by:
setGamein interfaceTransporter
-