megamek.common
Class BattleArmorHandles

java.lang.Object
  extended by megamek.common.BattleArmorHandles
All Implemented Interfaces:
java.io.Serializable, Transporter
Direct Known Subclasses:
BattleArmorHandlesTank, ClampMountMech

 class BattleArmorHandles
extends java.lang.Object
implements Transporter

Represtents a set of handles on an OmniMech used by Battle Armor units equiped with Boarding Claws to attach themselves for transport. This is standard equipment on OmniMechs.

See Also:
MechFileParser.postLoadInit(megamek.common.Entity)

Field Summary
protected  Entity troopers
          The troopers being carried.
 
Constructor Summary
BattleArmorHandles()
          Create a set of handles.
 
Method Summary
 boolean canLoad(Entity unit)
          Determines if this object can accept the given unit.
 int getCargoMpReduction()
           
protected  int[] getExteriorLocs(boolean isRear)
          Get the exterior locations that a loaded squad covers.
 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.
 java.util.List<Entity> getExternalUnits()
           
 java.util.Vector<Entity> getLoadedUnits()
          Get a List of the units currently loaded into this payload.
 java.lang.String getUnusedString()
          Return a string that identifies the unused capacity of this transporter.
protected  java.lang.String getVacancyString(boolean isLoaded)
          Get the String to report the presence (or lack thereof) of a loaded squad of Battle Armor troopers.
 boolean isWeaponBlockedAt(int loc, boolean isRear)
          Determine if transported units prevent a weapon in the given location from firing.
 void load(Entity unit)
          Load the given unit.
 boolean unload(Entity unit)
          Unload the given unit.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

troopers

protected Entity troopers
The troopers being carried.

Constructor Detail

BattleArmorHandles

public BattleArmorHandles()
Create a set of handles.

Method Detail

getExteriorLocs

protected int[] getExteriorLocs(boolean isRear)
Get the exterior locations that a loaded squad covers.

Sub-classes are encouraged to override this method.

Parameters:
isRear - - a boolean value stating if the given location is rear facing; if false, the location is front facing.
Returns:
an array of int listing the exterior locations.

getVacancyString

protected java.lang.String getVacancyString(boolean isLoaded)
Get the String to report the presence (or lack thereof) of a loaded squad of Battle Armor troopers.

Sub-classes are encouraged to override this method.

Parameters:
isLoaded - - a boolean that indicates that troopers are currently loaded (if the value is true) or not (if the value is false).
Returns:
a String describing the occupancy state of this transporter.

canLoad

public boolean canLoad(Entity unit)
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 interface Transporter
Parameters:
unit - - the Entity to be loaded.
Returns:
true if the unit can be loaded, false otherwise.

load

public final void load(Entity unit)
                throws java.lang.IllegalArgumentException
Load the given unit.

Specified by:
load in interface Transporter
Parameters:
unit - - the Entity to be loaded.
Throws:
java.lang.IllegalArgumentException - - If the unit can't be loaded, an IllegalArgumentException exception will be thrown.

getLoadedUnits

public final java.util.Vector<Entity> getLoadedUnits()
Get a List of the units currently loaded into this payload.

Specified by:
getLoadedUnits in interface Transporter
Returns:
A List of loaded Entity units. This list will never be null, but it may be empty. The returned List is independant from the under- lying data structure; modifying one does not affect the other.

unload

public final boolean unload(Entity unit)
Unload the given unit.

Specified by:
unload in interface Transporter
Parameters:
unit - - the Entity to be unloaded.
Returns:
true if the unit was contain is loadeded in this space, false otherwise.

getUnusedString

public final java.lang.String getUnusedString()
Return a string that identifies the unused capacity of this transporter.

Sub-classes should override the getVacancyString method.

Specified by:
getUnusedString in interface Transporter
Returns:
A String meant for a human.
See Also:
getUnusedString()

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 interface Transporter
Parameters:
loc - - the int location attempting to fire.
isRear - - a boolean value stating if the given location is rear facing; if false, the location is front facing.
Returns:
true if a transported unit is in the way, false if the weapon can fire.
See Also:
megamek.common.BattleArmorHandles#getBlockedLocs(boolean)

getExteriorUnitAt

public 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. Currently, no more than one unit can be at any single location; that same unit can be "spread" over multiple locations.

Sub-classes should override the getExteriorLocs method.

Specified by:
getExteriorUnitAt in interface Transporter
Parameters:
loc - - the int location hit by attack.
isRear - - a boolean value stating if the given location is rear facing; if false, the location is front facing.
Returns:
The Entity being transported on the outside at that location. This value will be null if no unit is transported on the outside at that location.
See Also:
getExteriorLocs(boolean)

getExternalUnits

public final java.util.List<Entity> getExternalUnits()
Specified by:
getExternalUnits in interface Transporter
Returns:
list of all units carried externally by this transporter

getCargoMpReduction

public int getCargoMpReduction()
Specified by:
getCargoMpReduction in interface Transporter
Returns:
the MP reduction due to cargo carried by this transporter