Package megamek.common.units
Class BuildingTarget
java.lang.Object
megamek.common.units.BuildingTarget
- All Implemented Interfaces:
Serializable,InGameObject,BTObject,Targetable
This class represents a single, targetable hex of a building. The building itself may occupy multiple hexes.
- See Also:
-
Field Summary
Fields inherited from interface megamek.common.units.Targetable
TYPE_BLDG_IGNITE, TYPE_BLDG_TAG, 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_HEX_TAG, TYPE_I_NARC_POD, TYPE_MINEFIELD_CLEAR, TYPE_MINEFIELD_DELIVER, TYPE_SATURATION, TYPE_SEARCHLIGHT -
Constructor Summary
ConstructorsConstructorDescriptionBuildingTarget(Coords coords, Board board, boolean ignite) Target a single hex of a building.BuildingTarget(Coords coords, Board board, int nType) Target a single hex of a building.BuildingTarget(Game game, BoardLocation boardLocation, int nType) -
Method Summary
Modifier and TypeMethodDescriptionReturns the general name or type name of this unit/object.intintintReturns the elevation of this target, relative to the position Hex's surfaceintReturns the height of the target, that is, how many levels above its elevation it is for LOS purposes.intgetId()Returns this InGameObject's id.intReturns the unique id of this InGameObject's owning player.intReturns the current (remaining) battle strength of this unit or object.intprotected voidInitialize this object from the input.booleanbooleanbooleanDetermines if this target should be considered the enemy of the supplied player.booleanReturns true if the target is considered immobile (-4 to hit).booleanintvoidsetId(int newId) Sets this InGameObject's id.voidsetOwnerId(int newOwnerId) Sets the unique id of this InGameObject's owning player.intintReturns the specific name or type name of this unit/object.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface megamek.common.units.BTObject
getFluffImage, getIcon, hasAerodyneSpheroidDistinction, isAero, isAerodyne, isAerospace, isAerospaceFighter, isAerospaceSV, isBattleArmor, isBattlefieldSupportAsset, isBattleMek, isCarryableObject, isCombatVehicle, isConventionalFighter, isConventionalInfantry, isDropShip, isFighter, isFixedWingSupport, isGround, isHandheldWeapon, isIndustrialMek, isInfantry, isJumpShip, isLargeAerospace, isMek, isObjectiveMarker, isProtoMek, isQuadMek, isSingleUnit, isSmallCraft, isSpaceStation, isSpheroid, isSupportVehicle, isTripodMek, isUnitGroup, isVehicle, isWarShipMethods inherited from interface megamek.common.game.InGameObject
countForStrengthSum, hasOwnerMethods inherited from interface megamek.common.units.Targetable
equals, getBoardLocation, hashCode, isBomber, isBracing, isBuildingEntityOrGunEmplacement, isHexBeingBombed, isOnBoard, tracksHeat
-
Constructor Details
-
BuildingTarget
Target a single hex of a building.- Parameters:
coords- - theCoordsof the hex being targeted.board- - the game'sBoardobject.nType- - anintvalue that indicates whether the player is attempting to set the building on fire, or not.- Throws:
IllegalArgumentException- will be thrown if the given coordinates do not contain a building.
-
BuildingTarget
-
BuildingTarget
Target a single hex of a building.- Parameters:
coords- - theCoordsof the hex being targeted.board- - the game'sBoardobject.ignite- - abooleanflag that indicates whether the player is attempting to set the building on fire, or not.- Throws:
IllegalArgumentException- will be thrown if the given coordinates do not contain a building.
-
-
Method Details
-
init
Initialize this object from the input.- Parameters:
coords- - theCoordsof the hex being targeted.board- - the game'sBoardobject.nType- the target type- Throws:
IllegalArgumentException- will be thrown if the given coordinates do not contain a building.
-
getBoardId
public int getBoardId()- Specified by:
getBoardIdin interfaceTargetable- Returns:
- The board ID of the board this targetable is on. This defaults to 0 so that any code that doesn't support multiple boards yet safely points to the first (and only) board; should eventually default to -1
-
getTargetType
public int getTargetType()- Specified by:
getTargetTypein interfaceTargetable
-
getId
public int getId()Description copied from interface:InGameObjectReturns this InGameObject's id. The id must be unique to this InGameObject within the current game. equals() must return true for two InGameObject objects with the same id.- Specified by:
getIdin interfaceInGameObject- Returns:
- The game-unique id of this InGameObject (Entity, AlphaStrikeElement etc.)
-
setId
public void setId(int newId) Description copied from interface:InGameObjectSets this InGameObject's id. The id must be unique to this InGameObject within the current game. equals() must return true for two InGameObject objects with the same id.- Specified by:
setIdin interfaceInGameObject- Parameters:
newId- The game-unique id of this InGameObject (Entity, AlphaStrikeElement etc.)
-
getOwnerId
public int getOwnerId()Description copied from interface:InGameObjectReturns the unique id of this InGameObject's owning player. This id may be Player.NONE.- Specified by:
getOwnerIdin interfaceInGameObject- Returns:
- The player id of the owner of this InGameObject.
-
setOwnerId
public void setOwnerId(int newOwnerId) Description copied from interface:InGameObjectSets the unique id of this InGameObject's owning player. This id may be Player.NONE.- Specified by:
setOwnerIdin interfaceInGameObject- Parameters:
newOwnerId- The player id of the owner of this InGameObject.
-
getStrength
public int getStrength()Description copied from interface:InGameObjectReturns the current (remaining) battle strength of this unit or object. For combat units, this is the battle value (BV) or the point value (PV).- Specified by:
getStrengthin interfaceInGameObject- Returns:
- The current battle strength (BV/PV)
-
getPosition
- Specified by:
getPositionin interfaceTargetable- Returns:
- the coordinates of the hex containing the target
-
getSecondaryPositions
- Specified by:
getSecondaryPositionsin interfaceTargetable
-
relHeight
public int relHeight()- Specified by:
relHeightin interfaceTargetable- Returns:
- elevation of the top (e.g. torso) of the target relative to surface
-
getHeight
public int getHeight()Description copied from interface:TargetableReturns the height of the target, that is, how many levels above its elevation it is for LOS purposes.- Specified by:
getHeightin interfaceTargetable- Returns:
- height of the target in elevation levels
-
getElevation
public int getElevation()Description copied from interface:TargetableReturns the elevation of this target, relative to the position Hex's surface- Specified by:
getElevationin interfaceTargetable- Returns:
- elevation of the bottom (e.g. legs) of the target relative to surface
-
isImmobile
public boolean isImmobile()Description copied from interface:TargetableReturns true if the target is considered immobile (-4 to hit). If this is a game unit, implementations should check the status of the unit (shutdown, damage) and also the status of the crew (unconscious) if any.- Specified by:
isImmobilein interfaceTargetable- Returns:
- True if the target is considered immobile
-
getDisplayName
- Specified by:
getDisplayNamein interfaceTargetable- Returns:
- name of the target for ui purposes
-
sideTable
- Specified by:
sideTablein interfaceTargetable- Returns:
- side hit from location
-
sideTable
- Specified by:
sideTablein interfaceTargetable- Returns:
- side hit from location
-
isOffBoard
public boolean isOffBoard()- Specified by:
isOffBoardin interfaceTargetable- Returns:
- if this is off the board
-
isAirborne
public boolean isAirborne()- Specified by:
isAirbornein interfaceTargetable- Returns:
- Is the entity airborne in the fashion of an aerospace unit? Does not include VTOL movement (see
Targetable.isAirborneVTOLorWIGE()
-
isAirborneVTOLorWIGE
public boolean isAirborneVTOLorWIGE()- Specified by:
isAirborneVTOLorWIGEin interfaceTargetable- 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:
getAltitudein interfaceTargetable- Returns:
- altitude of target
-
isEnemyOf
Description copied from interface:TargetableDetermines if this target should be considered the enemy of the supplied player. Targets that aren't owned by any player, such as buildings or terrain, are always considered enemies, since this will most often be used to determine if something is valid to be shot at.- Specified by:
isEnemyOfin interfaceTargetable
-
generalName
Description copied from interface:BTObjectReturns the general name or type name of this unit/object. For standard individual units, this is the chassis. For other types of units or objects this can be the full designation or a general part of the designation. Much like the chassis, this can be much more narrow than the general type of unit ("Mek").The general name should not be empty and not return null. Return the chassis in Entity and AlphaStrikeElement.
- Specified by:
generalNamein interfaceBTObject- Returns:
- The general name / chassis
-
specificName
Description copied from interface:BTObjectReturns the specific name or type name of this unit/object. For standard individual units, this is the model. For other types of units or objects this can be a part of the designation, or empty.The specific name should not return null. Return the model in Entity and AlphaStrikeElement.
- Specified by:
specificNamein interfaceBTObject- Returns:
- The specific name / model
-