Class HalfPlaneHexArea

java.lang.Object
megamek.common.hexarea.HalfPlaneHexArea
All Implemented Interfaces:
Serializable, HexArea

public class HalfPlaneHexArea extends Object
This class represents a half plane shape. The plane is delimited by the given coordinate, which is either a hex column or row (x or y) depending on the halfPlaneDirection given. A half plane with coordinate 5 and direction ABOVE extends from Coords (x, 5) upwards, i.e. (0, 0) is within that plane, (0, 10) is not. The given coordinate itself is part of the half plane.
See Also:
  • Constructor Details

    • HalfPlaneHexArea

      public HalfPlaneHexArea(int coordinate, HalfPlaneHexArea.HalfPlaneType halfPlaneDirection)
      Creates a half plane shape. The plane is delimited by the given coordinate, which is either a hex column or row (x or y) depending on the halfPlaneDirection given. A half plane with coordinate 5 and direction ABOVE extends from Coords (x, 5) upwards, i.e. (0, 0) is within that plane, (0, 10) is not. The given coordinate itself is part of the half plane.
      Parameters:
      coordinate - The x or y value where the half plane starts/ends
      halfPlaneDirection - The direction in which the half plane extends
  • Method Details

    • containsCoords

      public boolean containsCoords(Coords coords, Board board)
      Description copied from interface: HexArea
      Returns true if this shape contains the given coords. Returns false when the given coords is null. If this shape is absolute, i.e. does not depend on parameters outside itself, the board does not matter. Some shapes however may be relative to the board size, e.g. a shape that returns the borders of the board; or even board contents, such as terrain.
      Parameters:
      coords - The coords that are tested if they are part of this shape
      board - The board to limit the area coords to
      Returns:
      True if this shape contains the coords
    • getCoords

      public final Set<Coords> getCoords(Board board)
      Description copied from interface: HexArea
      Returns a set of the coords of this area that are part of the given board.
      Specified by:
      getCoords in interface HexArea
      Parameters:
      board - The board to limit the results to
      Returns:
      Coords of this shape that lie on the board