api: Add contains methods to WorldPoint and WorldArea
This commit is contained in:
committed by
Jordan Atwood
parent
86cda7de0b
commit
9c7fade732
@@ -151,6 +151,26 @@ public class WorldArea
|
||||
return distanceTo2D(new WorldArea(other, 1, 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a tile is contained within the area and in the same plane.
|
||||
*
|
||||
* @return {@code true} if the tile is contained within the bounds of this area, {@code false} otherwise.
|
||||
*/
|
||||
public boolean contains(WorldPoint worldPoint)
|
||||
{
|
||||
return distanceTo(worldPoint) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a tile is contained within the area while ignoring the plane.
|
||||
*
|
||||
* @return {@code true} if the tile is contained within the bounds of this area regardless of plane, {@code false} otherwise.
|
||||
*/
|
||||
public boolean contains2D(WorldPoint worldPoint)
|
||||
{
|
||||
return distanceTo2D(worldPoint) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether this area is within melee distance of another.
|
||||
* <p>
|
||||
|
||||
@@ -406,4 +406,40 @@ public class WorldPoint
|
||||
}
|
||||
return worldPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether this tile is located within any of the given areas.
|
||||
*
|
||||
* @param worldAreas areas to check within
|
||||
* @return {@code true} if any area contains this point, {@code false} otherwise.
|
||||
*/
|
||||
public boolean isInArea(WorldArea... worldAreas)
|
||||
{
|
||||
for (WorldArea area : worldAreas)
|
||||
{
|
||||
if (area.contains(this))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether this tile is located within any of the given areas, disregarding any plane differences.
|
||||
*
|
||||
* @param worldAreas areas to check within
|
||||
* @return {@code true} if any area contains this point, {@code false} otherwise.
|
||||
*/
|
||||
public boolean isInArea2D(WorldArea... worldAreas)
|
||||
{
|
||||
for (WorldArea area : worldAreas)
|
||||
{
|
||||
if (area.contains2D(this))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user