Class HexAreaIntersection

java.lang.Object
megamek.common.hexArea.HexAreaIntersection
All Implemented Interfaces:
Serializable, HexArea

public class HexAreaIntersection extends Object
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:
  • Constructor Details

    • HexAreaIntersection

      public HexAreaIntersection(HexArea firstShape, HexArea secondShape)
      Creates an intersection of the two given shapes.
      Parameters:
      firstShape - The first of the two shapes; the ordering of the shapes is not relevant
      secondShape - The second of the two shapes
  • 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. 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 shape
      board - The board to limit the area coords to
      Returns:
      True if this shape contains the coords
    • isSmall

      public boolean isSmall()
    • getCoords

      public Set<Coords> getCoords()
    • 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
    • matchesBoardId

      public boolean matchesBoardId(Board board)
      Description copied from interface: HexArea
      Returns true if this HexArea is present on the given board. By default, forwards to HexArea.matchesBoardId(int). This method will usually not need to be overridden.
      Specified by:
      matchesBoardId in interface HexArea
      Returns:
      True if this area is present on the given board
    • setBoardIds

      public void setBoardIds(List<Integer> boardIds)
      Description copied from interface: HexArea
      Replaces the board IDs that this area is on with the given board IDs.
      Specified by:
      setBoardIds in interface HexArea
      Parameters:
      boardIds - The new board IDs to use for this area