Package org.rspeer.game.coord.shape
Class CoordPolygon
- java.lang.Object
-
- org.rspeer.game.coord.shape.CoordPolygon
-
- All Implemented Interfaces:
CoordShape
public class CoordPolygon extends Object implements CoordShape
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(SceneNode node)Determines whether the given coordinate lies inside this shape.static CoordPolygonfrom(Coord... vertices)Constructs a polygonal shape from the given vertices.Set<Coord>getBoundary(boolean outer)Returns all coordinates on the boundary (perimeter) of the shape.Set<Coord>getCoords()Returns all coordinates contained within this shape.intgetFloorLevel()Set<Coord>getVertices()Returns the set of vertices defining this shape.CoordPolygonignoreFloorLevel()Allows this polygon to match coordinates on any floor level instead of onlyfloorLevel.
-
-
-
Method Detail
-
from
public static CoordPolygon from(Coord... vertices)
Constructs a polygonal shape from the given vertices.The floor level is taken from the first vertex (or 0 if none are given).
- Parameters:
vertices- the polygon vertices, in order
-
ignoreFloorLevel
public CoordPolygon ignoreFloorLevel()
Allows this polygon to match coordinates on any floor level instead of onlyfloorLevel.- Returns:
- this polygon (for chaining)
-
contains
public boolean contains(SceneNode node)
Description copied from interface:CoordShapeDetermines whether the given coordinate lies inside this shape.- Specified by:
containsin interfaceCoordShape- Parameters:
node- the node to test- Returns:
trueif the shape contains the coordinate
-
getVertices
public Set<Coord> getVertices()
Description copied from interface:CoordShapeReturns the set of vertices defining this shape.For a rectangle, this is the 4 corner coordinates. For polygons, this would be all defining polygon points.
- Specified by:
getVerticesin interfaceCoordShape- Returns:
- an immutable set of shape-defining vertices
-
getBoundary
public Set<Coord> getBoundary(boolean outer)
Description copied from interface:CoordShapeReturns all coordinates on the boundary (perimeter) of the shape.- Specified by:
getBoundaryin interfaceCoordShape- Parameters:
outer- iftrue, returns the ring of tiles immediately surrounding the shape;
iffalse, returns only the tiles forming the perimeter on the shape itself.- Returns:
- a set of coordinates representing the boundary
-
getCoords
public Set<Coord> getCoords()
Description copied from interface:CoordShapeReturns all coordinates contained within this shape.For large shapes, this may be a large collection.
- Specified by:
getCoordsin interfaceCoordShape- Returns:
- a set of all coordinates inside the region
-
getFloorLevel
public int getFloorLevel()
-
-