Package megamek.common.units
Interface IBuilding
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
AbstractBuildingEntity,BuildingEntity,BuildingTerrain,FuelTank,MobileStructure
This class represents a single, possibly multi-hex building on the board.
FIXME : This needs a complete rewrite to properly handle the latest building rules
Rewrite Notes: TODO : 1) Migrate Magic Numbers to Enums TODO : 2) Offboard Gun Emplacements: Revisit with a required rules query (CustomMekDialog - 22-Feb-2022)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final int -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDemolitionCharge(int playerId, int damage, Coords pos) default CubeCoordsboardToRelative(Coords boardCoords) Convert board coordinates to relative CubeCoordinates.static StringclassName(int bldgClass) Returns a string representation of the given building class, e.g.voidcollapseBasement(Coords coords, Board board, Vector<Report> vPhaseReport) static intdefault intgetAbsorption(Coords pos) intgetBasement(Coords coords) booleangetBasementCollapsed(Coords coords) Get the building basement, per TacOps rules.intGet the building class, per TacOps rules.default intGet the facing/rotation of this building in board space.intdefault CoordsGet the board coordinates of this building's origin (where relative 0,0 maps to).Get the construction type of the building.intGet the coordinates that the building occupies.Returns a list of this Building's coords.intgetCurrentCF(Coords coords) Get the current construction factor of the building hex at the passed coords.default doubledefault floatPer page 172 of Total Warfare, this is the fraction of a weapon's damage that passes through to infantry inside the building.default doublestatic intgetDefaultCF(int type) Get the default construction factor for the given type of building.static intgetDefaultCF(BuildingType type) Get the default construction factor for the given type of building.intGet the height (BLDG_ELEV) of the building hex at the passed coords.intgetId()Get the ID of this building.default doubleReturns the percentage of damage done to the building for attacks against infantry in the building from other units within the building.default BuildingGet the internal Building instance that stores data in relative coordinates.getName()Get the name of this building.intintgetPhaseCF(Coords coords) Get the construction factor of the building hex at the passed coords at the start of the current phase.booleanDetermines if the coord exist in the currentCF has.booleanDetermine if this building is on fire.default booleanDetermine if the building occupies given coordinates.default CoordsrelativeToBoard(CubeCoords relativeCoords) Convert relative CubeCoordinates to board coordinates.voidvoidRemove one building hex from the buildingbooleanrollBasement(Coords coords, Board board, Vector<Report> vPhaseReport) Roll what kind of basement this building hasvoidvoidsetBasement(Coords coords, BasementType basement) voidsetBasementCollapsed(Coords coords, boolean collapsed) voidsetBoardId(int boardId) voidsetBurning(boolean onFire, Coords coords) Set the flag that indicates that this building is on fire.voidsetCurrentCF(int cf, Coords coords) Set the current construction factor of the building hex.voidsetDemolitionCharges(List<DemolitionCharge> charges) voidSet the height of a specific building hex.voidsetPhaseCF(int cf, Coords coords) Set the construction factor of the building hex for the start of the next phase.
-
Field Details
-
UNKNOWN
static final int UNKNOWN- See Also:
-
STANDARD
static final int STANDARD- See Also:
-
HANGAR
static final int HANGAR- See Also:
-
FORTRESS
static final int FORTRESS- See Also:
-
GUN_EMPLACEMENT
static final int GUN_EMPLACEMENT- See Also:
-
-
Method Details
-
currentId
-
getId
int getId()Get the ID of this building. The same ID applies to all hexes.- Returns:
- the
intID of the building.
-
isIn
Determine if the building occupies given coordinates. Multi-hex buildings will occupy multiple coordinates. Only one building per hex.- Parameters:
coords- - theCoordsbeing examined.- Returns:
trueif the building occupies the coordinates.falseotherwise.
-
hasCFIn
Determines if the coord exist in the currentCF has.- Parameters:
coords- - theCoordsbeing examined.- Returns:
trueif the building has CF at the coordinates.falseotherwise.
-
getCoords
Enumeration<Coords> getCoords()Get the coordinates that the building occupies.- Returns:
- an
Enumerationof theCoordobjects.
-
getCoordsList
Returns a list of this Building's coords. The list is unmodifiable. -
getBuildingType
BuildingType getBuildingType()Get the construction type of the building. This value will be one of the values defined in megamek.common.enums.BuildingType- Returns:
- the
intcode of the building's construction type.
-
getBldgClass
int getBldgClass()Get the building class, per TacOps rules.- Returns:
- the
intcode of the building's classification.
-
getBasementCollapsed
Get the building basement, per TacOps rules.- Returns:
- the
intcode of the building basement type.
-
collapseBasement
-
rollBasement
Roll what kind of basement this building has- Parameters:
coords- theCoordsof the building to roll forvPhaseReport- theReportVectorcontaining the phase report- Returns:
- a
booleanindicating weather the hex and building was changed or not
-
getCurrentCF
Get the current construction factor of the building hex at the passed coords. Any damage immediately updates this value.- Parameters:
coords- theCoordsof the hex in question- Returns:
- the
intvalue of the building hex's current construction factor. This value will be greater than or equal to zero.
-
getPhaseCF
Get the construction factor of the building hex at the passed coords at the start of the current phase. Damage that is received during the phase is applied at the end of the phase.- Parameters:
coords- theCoordsof the hex in question- Returns:
- the
intvalue of the building's construction factor at the start of this phase. This value will be greater than or equal to zero.
-
getArmor
-
getHeight
Get the height (BLDG_ELEV) of the building hex at the passed coords.- Parameters:
coords- theCoordsof the hex in question- Returns:
- the
intvalue of the building hex's height. This value will be 0 if the hex is destroyed.
-
setCurrentCF
Set the current construction factor of the building hex. Call this method immediately when the building sustains any damage.- Parameters:
cf- theintvalue of the building hex's current construction factor. This value must be greater than or equal to zero.coords- theCoordsof the hex in question- Throws:
IllegalArgumentException- if the passed value is less than zero
-
setPhaseCF
Set the construction factor of the building hex for the start of the next phase. Call this method at the end of the phase to apply damage sustained by the building during the phase.- Parameters:
cf- theintvalue of the building hex's current construction factor. This value must be greater than or equal to zero.coords- theCoordsof the hex in question- Throws:
IllegalArgumentException- if the passed value is less than zero
-
setArmor
-
setHeight
Set the height of a specific building hex. Call this method when a hex is destroyed (set to 0).- Parameters:
h- theintvalue of the building hex's height. This value must be greater than or equal to zero.coords- theCoordsof the hex in question- Throws:
IllegalArgumentException- if the passed value is less than zero
-
getName
String getName()Get the name of this building.- Returns:
- the
Stringname of this building.
-
getDefaultCF
Get the default construction factor for the given type of building. -
getDefaultCF
static int getDefaultCF(int type) Get the default construction factor for the given type of building. Retained for backwards compatibility- Parameters:
type- - theintconstruction type of the building.- Returns:
- the
intdefault construction factor for that type of building. If a bad type value is passed, the constantBuilding.UNKNOWNwill be returned instead.
-
className
Returns a string representation of the given building class, e.g. "Hangar". -
isBurning
Determine if this building is on fire.- Returns:
trueif the building is on fire.
-
setBurning
Set the flag that indicates that this building is on fire.- Parameters:
onFire- - abooleanvalue that indicates whether this building is on fire.
-
addDemolitionCharge
-
removeDemolitionCharge
-
getDemolitionCharges
List<DemolitionCharge> getDemolitionCharges() -
setDemolitionCharges
-
removeHex
Remove one building hex from the building- Parameters:
coords- - theCoordsof the hex to be removed
-
getOriginalHexCount
int getOriginalHexCount() -
getCollapsedHexCount
int getCollapsedHexCount() -
getDamageFromScale
default double getDamageFromScale()- Returns:
- the damage scale multiplier for units passing through this building
-
getDamageToScale
default double getDamageToScale()- Returns:
- the damage scale multiplier for damage applied to this building (and occupants)
-
getAbsorption
- Returns:
- the amount of damage the building absorbs
-
getInfDmgFromInside
default double getInfDmgFromInside()Returns the percentage of damage done to the building for attacks against infantry in the building from other units within the building. TW pg175. -
getDamageReductionFromOutside
default float getDamageReductionFromOutside()Per page 172 of Total Warfare, this is the fraction of a weapon's damage that passes through to infantry inside the building.- Returns:
- Damage fraction.
-
getBasement
-
setBasement
-
setBasementCollapsed
-
getBoardId
int getBoardId() -
setBoardId
void setBoardId(int boardId) -
getBoardOrigin
Get the board coordinates of this building's origin (where relative 0,0 maps to). For BuildingTerrain: the static placement coords For AbstractBuildingEntity: the entity's current position- Returns:
- the board coordinates of the origin, or null if not placed
-
getBoardFacing
default int getBoardFacing()Get the facing/rotation of this building in board space. 0 = north, 1-5 = clockwise rotation- Returns:
- the facing (0-5)
-
getInternalBuilding
Get the internal Building instance that stores data in relative coordinates. Building returns itself; BuildingTerrain/BuildingEntity override to return wrapped instance.- Returns:
- the internal Building instance
-
boardToRelative
Convert board coordinates to relative CubeCoordinates. Default: convert board Coords to CubeCoords. BuildingTerrain/BuildingEntity override to translate using their coord maps.- Parameters:
boardCoords- the board coordinates- Returns:
- the relative CubeCoordinates
-
relativeToBoard
Convert relative CubeCoordinates to board coordinates. Default: convert CubeCoords to offset Coords. BuildingTerrain/BuildingEntity override to translate using their coord maps.- Parameters:
relativeCoords- the relative CubeCoordinates- Returns:
- the board coordinates
-