megamek.common
Class DockingCollar

java.lang.Object
  extended by megamek.common.DockingCollar
All Implemented Interfaces:
java.io.Serializable, Transporter

public class DockingCollar
extends java.lang.Object
implements Transporter

Represtents a volume of space set aside for carrying ASFs and Small Craft aboard DropShips

See Also:
Serialized Form

Field Summary
(package private)  int currentSpace
          The current amount of space available for troops.
(package private)  int totalSpace
          The total amount of space available for troops.
(package private)  java.util.Vector<Entity> troops
          The troops being carried.
 
Constructor Summary
protected DockingCollar()
          The default constructor is only for serialization.
  DockingCollar(int docks)
          Create a space for the given tonnage of troops.
 
Method Summary
 boolean canLoad(Entity unit)
          Determines if this object can accept the given unit.
 int getCargoMpReduction()
           
 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.
 boolean isDamaged()
           
 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.
 void setDamaged(boolean b)
           
 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

troops

java.util.Vector<Entity> troops
The troops being carried.


totalSpace

int totalSpace
The total amount of space available for troops.


currentSpace

int currentSpace
The current amount of space available for troops.

Constructor Detail

DockingCollar

protected DockingCollar()
The default constructor is only for serialization.


DockingCollar

public DockingCollar(int docks)
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 Detail

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 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:
- - If the unit can't be loaded, an IllegalArgumentException exception will be thrown.
java.lang.IllegalArgumentException

getLoadedUnits

public 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 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 contained in this space, false otherwise.

getUnusedString

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

Specified by:
getUnusedString in interface Transporter
Returns:
A String meant 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:
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.

getExteriorUnitAt

public 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.

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.

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

isDamaged

public boolean isDamaged()

setDamaged

public void setDamaged(boolean b)