Package megamek.common.hexArea
Class HexAreaIntersection
java.lang.Object
megamek.common.hexArea.HexAreaIntersection
- All Implemented Interfaces:
Serializable,HexArea
This class represents the intersection of two HexAreaShapes. A coord is only part of the resulting area if it is part
of both areas. This means that the board IDs of both areas must have some overlap for the resulting area to not be
empty.
Note that this HexArea itself has no board IDs. The result of this hex area is defined only by the two intersecting areas.
- See Also:
-
Field Summary
Fields inherited from interface megamek.common.hexArea.HexArea
EMPTY_AREA -
Constructor Summary
ConstructorsConstructorDescriptionHexAreaIntersection(HexArea firstShape, HexArea secondShape) Creates an intersection of the two given shapes. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsCoords(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.booleanisSmall()booleanmatchesBoardId(Board board) Returns true if this HexArea is present on the given board.voidsetBoardIds(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, waitMethods inherited from interface megamek.common.hexArea.HexArea
matchesBoardId
-
Constructor Details
-
HexAreaIntersection
Creates an intersection of the two given shapes.- Parameters:
firstShape- The first of the two shapes; the ordering of the shapes is not relevantsecondShape- The second of the two shapes
-
-
Method Details
-
containsCoords
Description copied from interface:HexAreaReturns 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
-
isSmall
public boolean isSmall() -
getCoords
-
getCoords
Description copied from interface:HexAreaReturns a set of the coords of this area that are part of the given board. -
matchesBoardId
Description copied from interface:HexAreaReturns 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:
matchesBoardIdin interfaceHexArea- Returns:
- True if this area is present on the given board
-
setBoardIds
Description copied from interface:HexAreaReplaces the board IDs that this area is on with the given board IDs.- Specified by:
setBoardIdsin interfaceHexArea- Parameters:
boardIds- The new board IDs to use for this area
-