Package megamek.common
Class TankTrailerHitch
java.lang.Object
megamek.common.TankTrailerHitch
- All Implemented Interfaces:
Serializable
,Transporter
Represents a trailer hitch that allows a wheeled or tracked vehicle to tow trailers.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTankTrailerHitch
(boolean rear) Create a new hitch, specified as a (front) or rear mount. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Determines if this object can accept the given unit.boolean
Determines if this transporter can tow the given unit.int
getCargoMpReduction
(Entity carrier) final Entity
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 aList
of the units currently loaded into this payload.boolean
double
final String
Return a string that identifies the unused capacity of this transporter.protected String
getVacancyString
(boolean isLoaded) Get theString
to report the presence (or lack thereof) of a towed trailer.boolean
isWeaponBlockedAt
(int loc, boolean isRear) Determine if transported units prevent a weapon in the given location from firing.final void
Load the given unit.void
clear out all troops listed in the transporter.void
toString()
final boolean
Unload the given unit.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface megamek.common.Transporter
getNumberLoadedThisTurn, getNumberUnloadedThisTurn, getType, hardpointCost
-
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 theString
to report the presence (or lack thereof) of a towed trailer.Sub-classes are encouraged to override this method.
- Parameters:
isLoaded
- - aboolean
that indicates a trailer is currently loaded (if the value istrue
) or not (if the value isfalse
).- Returns:
- a
String
describing 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:
canLoad
in interfaceTransporter
- Parameters:
unit
- - theEntity
to be loaded.- Returns:
true
if the unit can be loaded,false
otherwise.
-
canTow
Description copied from interface:Transporter
Determines if this transporter can tow the given unit. By default, no.- Specified by:
canTow
in interfaceTransporter
-
load
Load the given unit.- Specified by:
load
in interfaceTransporter
- Parameters:
unit
- theEntity
to be loaded.- Throws:
IllegalArgumentException
- If the unit can't be loaded
-
getLoadedUnits
Get aList
of the units currently loaded into this payload.- Specified by:
getLoadedUnits
in interfaceTransporter
- Returns:
- A
Vector
of loadedEntity
units. This list will never benull
, but it may be empty. The returnedList
is independent from the under- lying data structure; modifying one does not affect the other.
-
unload
Unload the given unit.- Specified by:
unload
in interfaceTransporter
- Parameters:
unit
- - theEntity
to be unloaded.- Returns:
true
if the unit was contained is loaded in this space,false
otherwise.
-
getUnusedString
Return a string that identifies the unused capacity of this transporter.Sub-classes should override the
getVacancyString
method.- Specified by:
getUnusedString
in interfaceTransporter
- Returns:
- A
String
meant for a human. - See Also:
-
getUnused
public double getUnused()- Specified by:
getUnused
in interfaceTransporter
- Returns:
- the number of unused spaces in this transporter.
-
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 interfaceTransporter
-
isWeaponBlockedAt
public boolean isWeaponBlockedAt(int loc, boolean isRear) Determine if transported units prevent a weapon in the given location from firing.- Specified by:
isWeaponBlockedAt
in interfaceTransporter
- Parameters:
loc
- - theint
location attempting to fire.isRear
- - aboolean
value stating if the given location is rear facing; iffalse
, the location is front 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:
getExteriorUnitAt
in interfaceTransporter
- Parameters:
loc
- - theint
location hit by attack.isRear
- - aboolean
value stating if the given location is rear facing; iffalse
, the location is front facing.- Returns:
- The
Entity
being transported on the outside at that location. This value will benull
if no unit is transported on the outside at that location.
-
getExternalUnits
- Specified by:
getExternalUnits
in interfaceTransporter
- Returns:
- list of all units carried externally by this transporter
-
getCargoMpReduction
- Specified by:
getCargoMpReduction
in interfaceTransporter
- Returns:
- the MP reduction due to cargo carried by this transporter
-
toString
-
setGame
- Specified by:
setGame
in interfaceTransporter
-