Package megamek.common.hexarea
Class HalfPlaneHexArea
java.lang.Object
megamek.common.hexarea.HalfPlaneHexArea
- All Implemented Interfaces:
Serializable
,HexArea
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:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from interface megamek.common.hexarea.HexArea
EMPTY_AREA
-
Constructor Summary
ConstructorsConstructorDescriptionHalfPlaneHexArea
(int coordinate, HalfPlaneHexArea.HalfPlaneType halfPlaneDirection) Creates a half plane shape. -
Method Summary
Modifier and TypeMethodDescriptionboolean
containsCoords
(Coords coords, Board board) Returns true if this shape contains the given coords.Returns a set of the coords of this area that are part of the given board.boolean
matchesBoardId
(Board board) Returns true if this HexArea is present on the given board.void
setBoardIds
(List<Integer> boardIds) Replaces the board IDs that this area is on with the given board IDs.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface megamek.common.hexarea.HexArea
matchesBoardId
-
Constructor Details
-
HalfPlaneHexArea
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/endshalfPlaneDirection
- The direction in which the half plane extends
-
-
Method Details
-
containsCoords
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. Note that this means that areas are *not* required to return true only for coords that are on the given board!Some shapes however may be relative to the board size, e.g. a shape that returns the borders of the board; or even relate to board contents, such as terrain.
- Parameters:
coords
- The coords that are tested if they are part of this shapeboard
- The board to limit the area coords to- Returns:
- True if this shape contains the coords
-
getCoords
Description copied from interface:HexArea
Returns a set of the coords of this area that are part of the given board. -
matchesBoardId
Description copied from interface:HexArea
Returns true if this HexArea is present on the given board. By default, forwards toHexArea.matchesBoardId(int)
. This method will usually not need to be overridden.- Specified by:
matchesBoardId
in interfaceHexArea
- Returns:
- True if this area is present on the given board
-
setBoardIds
Description copied from interface:HexArea
Replaces the board IDs that this area is on with the given board IDs.- Specified by:
setBoardIds
in interfaceHexArea
- Parameters:
boardIds
- The new board IDs to use for this area
-