Interface IBuilding

All Superinterfaces:
Serializable
All Known Implementing Classes:
AbstractBuildingEntity, BuildingEntity, BuildingTerrain, FuelTank, MobileStructure

public interface IBuilding extends Serializable
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 Details

  • Method Details

    • currentId

      static int currentId(Board board, Coords coords)
    • getId

      int getId()
      Get the ID of this building. The same ID applies to all hexes.
      Returns:
      the int ID of the building.
    • isIn

      default boolean isIn(Coords coords)
      Determine if the building occupies given coordinates. Multi-hex buildings will occupy multiple coordinates. Only one building per hex.
      Parameters:
      coords - - the Coords being examined.
      Returns:
      true if the building occupies the coordinates. false otherwise.
    • hasCFIn

      boolean hasCFIn(Coords coords)
      Determines if the coord exist in the currentCF has.
      Parameters:
      coords - - the Coords being examined.
      Returns:
      true if the building has CF at the coordinates. false otherwise.
    • getCoords

      Enumeration<Coords> getCoords()
      Get the coordinates that the building occupies.
      Returns:
      an Enumeration of the Coord objects.
    • getCoordsList

      List<Coords> 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 int code of the building's construction type.
    • getBldgClass

      int getBldgClass()
      Get the building class, per TacOps rules.
      Returns:
      the int code of the building's classification.
    • getBasementCollapsed

      boolean getBasementCollapsed(Coords coords)
      Get the building basement, per TacOps rules.
      Returns:
      the int code of the building basement type.
    • collapseBasement

      void collapseBasement(Coords coords, Board board, Vector<Report> vPhaseReport)
    • rollBasement

      boolean rollBasement(Coords coords, Board board, Vector<Report> vPhaseReport)
      Roll what kind of basement this building has
      Parameters:
      coords - the Coords of the building to roll for
      vPhaseReport - the Report Vector containing the phase report
      Returns:
      a boolean indicating weather the hex and building was changed or not
    • getCurrentCF

      int getCurrentCF(Coords coords)
      Get the current construction factor of the building hex at the passed coords. Any damage immediately updates this value.
      Parameters:
      coords - the Coords of the hex in question
      Returns:
      the int value of the building hex's current construction factor. This value will be greater than or equal to zero.
    • getPhaseCF

      int getPhaseCF(Coords coords)
      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 - the Coords of the hex in question
      Returns:
      the int value of the building's construction factor at the start of this phase. This value will be greater than or equal to zero.
    • getArmor

      int getArmor(Coords coords)
    • getHeight

      int getHeight(Coords coords)
      Get the height (BLDG_ELEV) of the building hex at the passed coords.
      Parameters:
      coords - the Coords of the hex in question
      Returns:
      the int value of the building hex's height. This value will be 0 if the hex is destroyed.
    • setCurrentCF

      void setCurrentCF(int cf, Coords coords)
      Set the current construction factor of the building hex. Call this method immediately when the building sustains any damage.
      Parameters:
      cf - the int value of the building hex's current construction factor. This value must be greater than or equal to zero.
      coords - the Coords of the hex in question
      Throws:
      IllegalArgumentException - if the passed value is less than zero
    • setPhaseCF

      void setPhaseCF(int cf, Coords coords)
      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 - the int value of the building hex's current construction factor. This value must be greater than or equal to zero.
      coords - the Coords of the hex in question
      Throws:
      IllegalArgumentException - if the passed value is less than zero
    • setArmor

      void setArmor(int a, Coords coords)
    • setHeight

      void setHeight(int h, Coords coords)
      Set the height of a specific building hex. Call this method when a hex is destroyed (set to 0).
      Parameters:
      h - the int value of the building hex's height. This value must be greater than or equal to zero.
      coords - the Coords of 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 String name of this building.
    • getDefaultCF

      static int getDefaultCF(BuildingType type)
      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 - - the int construction type of the building.
      Returns:
      the int default construction factor for that type of building. If a bad type value is passed, the constant Building.UNKNOWN will be returned instead.
    • className

      static String className(int bldgClass)
      Returns a string representation of the given building class, e.g. "Hangar".
    • isBurning

      boolean isBurning(Coords coords)
      Determine if this building is on fire.
      Returns:
      true if the building is on fire.
    • setBurning

      void setBurning(boolean onFire, Coords coords)
      Set the flag that indicates that this building is on fire.
      Parameters:
      onFire - - a boolean value that indicates whether this building is on fire.
    • addDemolitionCharge

      void addDemolitionCharge(int playerId, int damage, Coords pos)
    • removeDemolitionCharge

      void removeDemolitionCharge(DemolitionCharge charge)
    • getDemolitionCharges

      List<DemolitionCharge> getDemolitionCharges()
    • setDemolitionCharges

      void setDemolitionCharges(List<DemolitionCharge> charges)
    • removeHex

      void removeHex(Coords coords)
      Remove one building hex from the building
      Parameters:
      coords - - the Coords of 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

      default int getAbsorption(Coords pos)
      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

      BasementType getBasement(Coords coords)
    • setBasement

      void setBasement(Coords coords, BasementType basement)
    • setBasementCollapsed

      void setBasementCollapsed(Coords coords, boolean collapsed)
    • getBoardId

      int getBoardId()
    • setBoardId

      void setBoardId(int boardId)
    • getBoardOrigin

      default Coords 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

      default Building 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

      default CubeCoords boardToRelative(Coords boardCoords)
      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

      default Coords relativeToBoard(CubeCoords relativeCoords)
      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