megamek.common
Class Bay

java.lang.Object
  extended by megamek.common.Bay
All Implemented Interfaces:
java.io.Serializable, Transporter
Direct Known Subclasses:
ASFBay, BattleArmorBay, CargoBay, HeavyVehicleBay, InfantryBay, LightVehicleBay, MechBay, SmallCraftBay

public class Bay
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 doors
           
(package private)  int doorsNext
           
(package private)  java.util.Vector<java.lang.Integer> recoverySlots
           
(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 Bay()
          The default constructor is only for serialization.
  Bay(int space, int doors)
          Create a space for the given tonnage of troops.
 
Method Summary
 boolean canLoad(Entity unit)
          Determines if this object can accept the given unit.
 void destroyDoor()
           
 void destroyDoorNext()
           
 int getCargoMpReduction()
           
 int getDoors()
           
 int getDoorsNext()
           
 java.util.Vector<Entity> getDroppableUnits()
          get a vector of droppable units.
 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> getLaunchableUnits()
          get a vector of launchable units.
 java.util.Vector<Entity> getLoadedUnits()
          Get a List of the units currently loaded into this payload.
 java.lang.String getType()
           
 java.lang.String getUnusedString()
          Return a string that identifies the unused capacity of this transporter.
 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 resetDoors()
           
 void setDoors(int d)
           
 void setDoorsNext(int d)
           
 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

doors

int doors

doorsNext

int doorsNext

recoverySlots

java.util.Vector<java.lang.Integer> recoverySlots

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

Bay

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


Bay

public Bay(int space,
           int doors)
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

getDoors

public int getDoors()

setDoors

public void setDoors(int d)

setDoorsNext

public void setDoorsNext(int d)

getDoorsNext

public int getDoorsNext()

resetDoors

public void resetDoors()

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.

getLaunchableUnits

public java.util.Vector<Entity> getLaunchableUnits()
get a vector of launchable units. This is different from loaded in that units in recovery cannot launch


getDroppableUnits

public java.util.Vector<Entity> getDroppableUnits()
get a vector of droppable units.


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

getType

public java.lang.String getType()

destroyDoorNext

public void destroyDoorNext()

destroyDoor

public void destroyDoor()