public class Area
extends java.lang.Object
Constructor and Description |
---|
Area(int swX,
int swY,
int neX,
int neY)
Creates a ground-level (plane = 0) rectangular area from x,y pairs representing south-west and north-east corners.
|
Area(int plane,
int swX,
int swY,
int neX,
int neY)
Creates a rectangular area from x,y pairs representing south-west and north-east corners.
|
Area(int plane,
Locatable... locatables)
Creates a polygonal area from the given locatables.
|
Area(int plane,
Locatable sw,
Locatable ne)
Creates a rectangular area from south-west and north-east locatables.
|
Area(Locatable... locatables)
Creates polygonal area from the given locatables.
|
Area(Locatable center,
int radius)
Creates a rectangular area (plane = center.getPlane()) with a radius around the given center.
|
Area(Locatable sw,
Locatable ne)
Creates a rectangular area from south-west and north-east locatables.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int x,
int y)
Appends a point to this area.
|
void |
add(Locatable locatable)
Appends a locatable to this area.
|
boolean |
contains(int x,
int y)
Determines if the x,y pair is contained in this area.
|
boolean |
contains(int plane,
int x,
int y)
Determines if the x,y pair is contained in this area.
|
boolean |
contains(int plane,
Locatable... locatables)
Determines if at least one of the given locatables is contained in this area.
|
boolean |
contains(Locatable... locatables)
Determines if at least one of the given locatables is contained in this area.
|
boolean |
containsAll(int plane,
Locatable... locatables)
Determines if every given locatable is contained in this area.
|
boolean |
containsAll(Locatable... locatables)
Determines if every given locatable is contained in this area.
|
void |
draw(java.awt.Graphics2D g2d) |
java.awt.Rectangle |
getBounds() |
Tile |
getCentralTile()
Gets the averaged center tile of this area.
|
int |
getHeight() |
Tile |
getNearestTile(APIContext ctx)
Finds the nearest tile in this area to the local player.
|
Tile |
getNearestTile(Tile base,
APIContext ctx)
Finds the nearest tile in this area to the base tile.
|
int |
getPlane() |
Tile |
getRandomTile()
Gets a random tile within this area.
|
Tile[] |
getTileArray() |
Tile[] |
getTiles() |
int |
getWidth() |
int |
getX() |
int |
getY() |
public Area(Locatable sw, Locatable ne)
sw
- the south-west locatable of this area.ne
- the north-east locatable of this area.public Area(Locatable... locatables)
locatables
- the locatables to create the area from.public Area(Locatable center, int radius)
center
- the center.radius
- the radius of the areapublic Area(int swX, int swY, int neX, int neY)
swX
- the x coordinate of the south-west corner, or the left side.swY
- the y coordinate of the south-west corner, or the bottom side.neX
- the x coordinate of the north-east corner, or the right side.neY
- the y coordinate of the north-east corner, or the top side.public Area(int plane, int swX, int swY, int neX, int neY)
plane
- the z-plane of this area.swX
- the x coordinate of the south-west corner, or the left side.swY
- the y coordinate of the south-west corner, or the bottom side.neX
- the x coordinate of the north-east corner, or the right side.neY
- the y coordinate of the north-east corner, or the top side.public Area(int plane, Locatable sw, Locatable ne)
plane
- the z-plane of this area.sw
- the south-west locatable of this area.ne
- the north-east locatable of this area.public Area(int plane, Locatable... locatables)
plane
- the z-plane of this area.locatables
- the locatables to create the area from.public void add(Locatable locatable)
locatable
- the locatable to add.public void add(int x, int y)
x
- the x coordinate.y
- the y coordinate.public boolean contains(int x, int y)
x
- the x coordinate.y
- the y coordinate.public boolean contains(int plane, int x, int y)
plane
- the z-plane to test on, can be -1x
- the x coordinate.y
- the y coordinate.public boolean contains(int plane, Locatable... locatables)
plane
- the z-plane to test the locatables on.locatables
- the locatables to assess.public boolean contains(Locatable... locatables)
locatables
- the locatables to assess.public boolean containsAll(int plane, Locatable... locatables)
plane
- the z-plane to test the locatables on.locatables
- the locatables to assess.public boolean containsAll(Locatable... locatables)
locatables
- the locatables to assess.public Tile getCentralTile()
Tile
public int getHeight()
public java.awt.Rectangle getBounds()
public Tile getNearestTile(APIContext ctx)
ctx
- APIContext
public Tile getNearestTile(Tile base, APIContext ctx)
base
- the tile to act as relative tile.ctx
- APIContext
public Tile[] getTiles()
public int getPlane()
public Tile[] getTileArray()
public int getWidth()
public int getX()
public int getY()
public void draw(java.awt.Graphics2D g2d)