Class FloorTarget

java.lang.Object
megamek.common.board.FloorTarget
All Implemented Interfaces:
Serializable, InGameObject, BTObject, Targetable

public class FloorTarget extends Object implements Targetable
This class represents a single, targetable hex and floor of a building. The building itself may occupy multiple hexes.
See Also:
  • Constructor Details

    • FloorTarget

      public FloorTarget(Coords coords, Board board, int targetElevation)
      Target a single hex of a building.
      Parameters:
      coords - - the Coords of the hex being targeted.
      board - - the game's Board object.
      targetElevation - - Kind where in the building you want to aim at.
      Throws:
      IllegalArgumentException - will be thrown if the given coordinates do not contain a building.
  • Method Details

    • getTargetType

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

      public int getId()
      Description copied from interface: InGameObject
      Returns 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:
      getId in interface InGameObject
      Returns:
      The game-unique id of this InGameObject (Entity, AlphaStrikeElement etc.)
    • setId

      public void setId(int newId)
      Description copied from interface: InGameObject
      Sets 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:
      setId in interface InGameObject
      Parameters:
      newId - The game-unique id of this InGameObject (Entity, AlphaStrikeElement etc.)
    • getOwnerId

      public int getOwnerId()
      Description copied from interface: InGameObject
      Returns the unique id of this InGameObject's owning player. This id may be Player.NONE.
      Specified by:
      getOwnerId in interface InGameObject
      Returns:
      The player id of the owner of this InGameObject.
    • setOwnerId

      public void setOwnerId(int newOwnerId)
      Description copied from interface: InGameObject
      Sets the unique id of this InGameObject's owning player. This id may be Player.NONE.
      Specified by:
      setOwnerId in interface InGameObject
      Parameters:
      newOwnerId - The player id of the owner of this InGameObject.
    • getStrength

      public int getStrength()
      Description copied from interface: InGameObject
      Returns 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:
      getStrength in interface InGameObject
      Returns:
      The current battle strength (BV/PV)
    • getPosition

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

      public Map<Integer,Coords> getSecondaryPositions()
      Specified by:
      getSecondaryPositions in interface Targetable
    • relHeight

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

      public int getHeight()
      Description copied from interface: Targetable
      Returns the height of the target, that is, how many levels above its elevation it is for LOS purposes.
      Specified by:
      getHeight in interface Targetable
      Returns:
      height of the target in elevation levels
    • getElevation

      public int getElevation()
      Description copied from interface: Targetable
      Returns the elevation of this target, relative to the position Hex's surface
      Specified by:
      getElevation in interface Targetable
      Returns:
      elevation of the bottom (e.g. legs) of the target relative to surface
    • isImmobile

      public boolean isImmobile()
      Description copied from interface: Targetable
      Returns 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:
      isImmobile in interface Targetable
      Returns:
      True if the target is considered immobile
    • getDisplayName

      public String getDisplayName()
      Specified by:
      getDisplayName in interface Targetable
      Returns:
      name of the target for ui purposes
    • coordsToId

      public static int coordsToId(Coords c)
      Creates an id for this building based on its location as well as a building code. 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

      @Deprecated(since="0.51.0", forRemoval=true) public static Coords idToCoords(int id)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • 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.isAirborneVTOLorWIGE()
    • isAirborneVTOLorWIGE

      public boolean isAirborneVTOLorWIGE()
      Specified by:
      isAirborneVTOLorWIGE 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
    • isEnemyOf

      public boolean isEnemyOf(Entity other)
      Description copied from interface: Targetable
      Determines 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:
      isEnemyOf in interface Targetable
    • generalName

      public String generalName()
      Description copied from interface: BTObject
      Returns 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:
      generalName in interface BTObject
      Returns:
      The general name / chassis
    • specificName

      public String specificName()
      Description copied from interface: BTObject
      Returns 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:
      specificName in interface BTObject
      Returns:
      The specific name / model