megamek.common
Class BuildingTarget

java.lang.Object
  extended by megamek.common.BuildingTarget
All Implemented Interfaces:
java.io.Serializable, Targetable

public class BuildingTarget
extends java.lang.Object
implements Targetable

This class represents a single, targetable hex of a building. The building itself may occupy multiple hexex.

Version:
$Revision: 7122 $
Author:
Suvarov454@sourceforge.net (James A. Damour )
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface megamek.common.Targetable
TYPE_BLDG_IGNITE, TYPE_BUILDING, TYPE_ENTITY, TYPE_FLARE_DELIVER, TYPE_FUEL_TANK, TYPE_FUEL_TANK_IGNITE, TYPE_HEX_AERO_BOMB, TYPE_HEX_ARTILLERY, TYPE_HEX_BOMB, TYPE_HEX_CLEAR, TYPE_HEX_EXTINGUISH, TYPE_HEX_IGNITE, TYPE_HEX_SCREEN, TYPE_INARC_POD, TYPE_MINEFIELD_CLEAR, TYPE_MINEFIELD_DELIVER, TYPE_SEARCHLIGHT
 
Constructor Summary
BuildingTarget(Coords coords, IBoard board, boolean ignite)
          Target a single hex of a building.
BuildingTarget(Coords coords, IBoard board, int nType)
          Target a single hex of a building.
 
Method Summary
 int absHeight()
           
static int coordsToId(Coords c)
          The transformation encodes the y value in the top 5 decimal digits and the x value in the bottom 5.
 int getAltitude()
           
 java.lang.String getDisplayName()
           
 int getElevation()
           
 int getHeight()
           
 Coords getPosition()
           
 int getTargetId()
           
 int getTargetType()
           
static Coords idToCoords(int id)
           
protected  void init(Coords coords, IBoard board, boolean ignite)
          Initialize this object from the input.
 boolean isAirborne()
           
 boolean isAirborneVTOL()
           
 boolean isImmobile()
           
 boolean isOffBoard()
           
 int sideTable(Coords src)
           
 int sideTable(Coords src, boolean usePrior)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BuildingTarget

public BuildingTarget(Coords coords,
                      IBoard board,
                      int nType)
Target a single hex of a building.

Parameters:
coords - - the Coords of the hext being targeted.
board - - the game's Board object.
type - - an int value that indicates whether the player is attempting to set the building on fire, or not.
Throws:
an - IllegalArgumentException will be thrown if the given coordinates do not contain a building.

BuildingTarget

public BuildingTarget(Coords coords,
                      IBoard board,
                      boolean ignite)
Target a single hex of a building.

Parameters:
coords - - the Coords of the hext being targeted.
board - - the game's Board object.
ignite - - a boolean flag that indicates whether the player is attempting to set the building on fire, or not.
Throws:
an - IllegalArgumentException will be thrown if the given coordinates do not contain a building.
Method Detail

init

protected void init(Coords coords,
                    IBoard board,
                    boolean ignite)
Initialize this object from the input.

Parameters:
coords - - the Coords of the hext being targeted.
board - - the game's Board object.
ignite - - a boolean flag that indicates whether the player is attempting to set the building on fire, or not.
Throws:
an - IllegalArgumentException will be thrown if the given coordinates do not contain a building.

getTargetType

public int getTargetType()
Specified by:
getTargetType in interface Targetable

getTargetId

public int getTargetId()
Specified by:
getTargetId in interface Targetable

getPosition

public Coords getPosition()
Specified by:
getPosition in interface Targetable
Returns:
the coordinates of the hex containing the target

absHeight

public int absHeight()
Specified by:
absHeight in interface Targetable
Returns:
elevation of the top (e.g. torso) of the target relative to surface

getHeight

public int getHeight()
Specified by:
getHeight in interface Targetable
Returns:
height of the target in elevation levels

getElevation

public int getElevation()
Specified by:
getElevation in interface Targetable
Returns:
elevation of the bottom (e.g. legs) of the target relative to surface

isImmobile

public boolean isImmobile()
Specified by:
isImmobile in interface Targetable
Returns:
true if the target is immobile (-4 to hit)

getDisplayName

public java.lang.String getDisplayName()
Specified by:
getDisplayName in interface Targetable
Returns:
name of the target for ui purposes

coordsToId

public static int coordsToId(Coords c)
The transformation encodes the y value in the top 5 decimal digits and the x value in the bottom 5. Could more efficiently encode this by partitioning the binary representation, but this is more human readable and still allows for a 99999x99999 hex map.


idToCoords

public static Coords idToCoords(int id)

sideTable

public int sideTable(Coords src)
Specified by:
sideTable in interface Targetable
Returns:
side hit from location

sideTable

public int sideTable(Coords src,
                     boolean usePrior)
Specified by:
sideTable in interface Targetable
Returns:
side hit from location

isOffBoard

public boolean isOffBoard()
Specified by:
isOffBoard in interface Targetable
Returns:
if this is off the board

isAirborne

public boolean isAirborne()
Specified by:
isAirborne in interface Targetable
Returns:
Is the entity airborne in the fashion of an aerospace unit? Does not include VTOL movement (see Targetable.isAirborneVTOL()

isAirborneVTOL

public boolean isAirborneVTOL()
Specified by:
isAirborneVTOL in interface Targetable
Returns:
is the entity airborne in the fashion of a VTOL Not used for aerospace units, see Targetable.isAirborne()

getAltitude

public int getAltitude()
Specified by:
getAltitude in interface Targetable
Returns:
altitude of target