Package megamek.common.units
Class BuildingTerrain
java.lang.Object
megamek.common.units.BuildingTerrain
- All Implemented Interfaces:
Serializable,IBuilding
- Direct Known Subclasses:
FuelTank
BuildingTerrain represents a stationary building placed on the board.
It contains a Building (which stores data in relative coordinates) and handles translation between board coordinates and the Building's relative coordinate space.
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionBuildingTerrain(Coords coords, Board board, int structureType, BasementType basementType) Construct a BuildingTerrain from board information. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDemolitionCharge(int playerId, int damage, Coords pos) boardToRelative(Coords boardCoords) Convert board coordinates to relative CubeCoordinates.voidcollapseBasement(Coords coords, Board board, Vector<Report> vPhaseReport) booleanCompare the internal buildingintgetBasement(Coords coords) booleangetBasementCollapsed(Coords coords) Get the building basement, per TacOps rules.intGet the building class, per TacOps rules.intGet the facing/rotation of this building in board space.intGet the board coordinates of this building's origin (where relative 0,0 maps to).Get the construction type of the building.intGet the BOARD coordinates that the building occupies.Returns a list of this Building's BOARD coords.intgetCurrentCF(Coords coords) Get the current construction factor of the building hex at the passed coords.intGet the height (BLDG_ELEV) of the building hex at the passed coords.intgetId()Get the ID of this building.Get 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.inthashCode()booleanDetermine if this building is on fire.relativeToBoard(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.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface megamek.common.units.IBuilding
getAbsorption, getDamageFromScale, getDamageReductionFromOutside, getDamageToScale, getInfDmgFromInside, isIn
-
Constructor Details
-
BuildingTerrain
Construct a BuildingTerrain from board information. Reads the building from the board and creates internal Building with relative coords.
-
-
Method Details
-
getBoardOrigin
Description copied from interface:IBuildingGet 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- Specified by:
getBoardOriginin interfaceIBuilding- Returns:
- the board coordinates of the origin, or null if not placed
-
getBoardFacing
public int getBoardFacing()Description copied from interface:IBuildingGet the facing/rotation of this building in board space. 0 = north, 1-5 = clockwise rotation- Specified by:
getBoardFacingin interfaceIBuilding- Returns:
- the facing (0-5)
-
getInternalBuilding
Description copied from interface:IBuildingGet the internal Building instance that stores data in relative coordinates. Building returns itself; BuildingTerrain/BuildingEntity override to return wrapped instance.- Specified by:
getInternalBuildingin interfaceIBuilding- Returns:
- the internal Building instance
-
boardToRelative
Description copied from interface:IBuildingConvert board coordinates to relative CubeCoordinates. Default: convert board Coords to CubeCoords. BuildingTerrain/BuildingEntity override to translate using their coord maps.- Specified by:
boardToRelativein interfaceIBuilding- Parameters:
boardCoords- the board coordinates- Returns:
- the relative CubeCoordinates
-
relativeToBoard
Description copied from interface:IBuildingConvert relative CubeCoordinates to board coordinates. Default: convert CubeCoords to offset Coords. BuildingTerrain/BuildingEntity override to translate using their coord maps.- Specified by:
relativeToBoardin interfaceIBuilding- Parameters:
relativeCoords- the relative CubeCoordinates- Returns:
- the board coordinates
-
getId
public int getId()Get the ID of this building. The same ID applies to all hexes. -
hasCFIn
Determines if the coord exist in the currentCF has. -
getCoords
Get the BOARD coordinates that the building occupies. -
getCoordsList
Returns a list of this Building's BOARD coords. The list is unmodifiable.- Specified by:
getCoordsListin interfaceIBuilding
-
getBuildingType
Get the construction type of the building. This value will be one of the values defined in megamek.common.enums.BuildingType- Specified by:
getBuildingTypein interfaceIBuilding- Returns:
- the
intcode of the building's construction type.
-
getBldgClass
public int getBldgClass()Get the building class, per TacOps rules.- Specified by:
getBldgClassin interfaceIBuilding- Returns:
- the
intcode of the building's classification.
-
getBasementCollapsed
Get the building basement, per TacOps rules.- Specified by:
getBasementCollapsedin interfaceIBuilding- Parameters:
coords- BOARD coordinates- Returns:
- the
intcode of the building basement type.
-
collapseBasement
- Specified by:
collapseBasementin interfaceIBuilding
-
rollBasement
Roll what kind of basement this building has- Specified by:
rollBasementin interfaceIBuilding- Parameters:
coords- BOARD coordinates of the building to roll forboard- the game boardvPhaseReport- 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.- Specified by:
getCurrentCFin interfaceIBuilding- Parameters:
coords- the BOARDCoordsof 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.- Specified by:
getPhaseCFin interfaceIBuilding- Parameters:
coords- the BOARDCoordsof 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
-
setCurrentCF
Set the current construction factor of the building hex. Call this method immediately when the building sustains any damage.- Specified by:
setCurrentCFin interfaceIBuilding- Parameters:
cf- theintvalue of the building hex's current construction factor. This value must be greater than or equal to zero.coords- the BOARDCoordsof 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.- Specified by:
setPhaseCFin interfaceIBuilding- Parameters:
cf- theintvalue of the building hex's current construction factor. This value must be greater than or equal to zero.coords- the BOARDCoordsof the hex in question- Throws:
IllegalArgumentException- if the passed value is less than zero
-
setArmor
-
getHeight
Description copied from interface:IBuildingGet the height (BLDG_ELEV) of the building hex at the passed coords. -
setHeight
Description copied from interface:IBuildingSet the height of a specific building hex. Call this method when a hex is destroyed (set to 0). -
getName
Get the name of this building. -
isBurning
Determine if this building is on fire. -
setBurning
Set the flag that indicates that this building is on fire.- Specified by:
setBurningin interfaceIBuilding- Parameters:
onFire- - abooleanvalue that indicates whether this building is on fire.coords- BOARD coordinates
-
addDemolitionCharge
- Specified by:
addDemolitionChargein interfaceIBuilding
-
removeDemolitionCharge
- Specified by:
removeDemolitionChargein interfaceIBuilding
-
getDemolitionCharges
- Specified by:
getDemolitionChargesin interfaceIBuilding
-
setDemolitionCharges
- Specified by:
setDemolitionChargesin interfaceIBuilding
-
removeHex
Remove one building hex from the building -
getOriginalHexCount
public int getOriginalHexCount()- Specified by:
getOriginalHexCountin interfaceIBuilding
-
getCollapsedHexCount
public int getCollapsedHexCount()- Specified by:
getCollapsedHexCountin interfaceIBuilding
-
getBasement
- Specified by:
getBasementin interfaceIBuilding
-
setBasement
- Specified by:
setBasementin interfaceIBuilding
-
setBasementCollapsed
- Specified by:
setBasementCollapsedin interfaceIBuilding
-
getBoardId
public int getBoardId()- Specified by:
getBoardIdin interfaceIBuilding
-
setBoardId
public void setBoardId(int boardId) - Specified by:
setBoardIdin interfaceIBuilding
-
equals
Compare the internal building -
toString
-
hashCode
public int hashCode()
-