Class RectArea
- java.lang.Object
-
- net.eternalclient.api.wrappers.map.RectArea
-
-
Constructor Summary
Constructors Constructor Description RectArea(int x1, int y1, int x2, int y2)RectArea(int x1, int y1, int x2, int y2, int plane)RectArea(Positionable positionable, int radius)RectArea(Positionable positionable, int width, int height)RectArea(Positionable p1, Positionable p2)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancanEqual(java.lang.Object other)booleancanTravelInDirection(int dx, int dy)Determines if the area can travel in one of the 9 directions by using the standard collision detection algorithm.booleancanTravelInDirection(RSWorldView wv, int dx, int dy)Determines if the area can travel in one of the 9 directions by using the standard collision detection algorithm.booleancanTravelInDirection(RSWorldView wv, int dx, int dy, java.util.function.Predicate<? super Positionable> extraCondition)Determines if the area can travel in one of the 9 directions by using the standard collision detection algorithm.booleancontains(int x, int y, int plane)booleancontains(Positionable positionable)booleancontains2D(int x, int y)booleancontains2D(Positionable positionable)booleanequals(java.lang.Object o)static RectAreafromSize(int x, int y, int width, int height, int plane)intgetMaxX()intgetMaxY()intgetMinX()intgetMinY()intgetPlane()PositionablegetRandomTile()java.util.List<Positionable>getTiles()inthashCode()booleanhasLineOfSightTo(Positionable other)Determine if this WorldArea has line of sight to another WorldArea.booleanhasLineOfSightTo(RSWorldView wv, RectArea other)Determine if this WorldArea has line of sight to another WorldArea.booleanintersectsWith(RectArea other)Checks whether this area intersects with another.booleanisInMeleeDistance(Positionable other)Checks whether a coordinate is within melee distance of this area.booleanisInMeleeDistance(RectArea other)Checks whether this area is within melee distance of another.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.eternalclient.api.wrappers.map.Area
distanceTo, distanceTo, distanceTo2D, distanceTo2D, getAxisDistances, getCenter, getComparisonPoint, getHeight, getNearestTile, getNearestTile, getWidth
-
-
-
-
Constructor Detail
-
RectArea
public RectArea(int x1, int y1, int x2, int y2)
-
RectArea
public RectArea(int x1, int y1, int x2, int y2, int plane)
-
RectArea
public RectArea(Positionable positionable, int radius)
-
RectArea
public RectArea(Positionable positionable, int width, int height)
-
RectArea
public RectArea(Positionable p1, Positionable p2)
-
-
Method Detail
-
fromSize
public static RectArea fromSize(int x, int y, int width, int height, int plane)
-
contains
public boolean contains(Positionable positionable)
-
contains2D
public boolean contains2D(int x, int y)- Specified by:
contains2Din interfaceArea
-
contains2D
public boolean contains2D(Positionable positionable)
- Specified by:
contains2Din interfaceArea
-
getRandomTile
public Positionable getRandomTile()
- Specified by:
getRandomTilein interfaceArea
-
getTiles
public java.util.List<Positionable> getTiles()
-
isInMeleeDistance
public boolean isInMeleeDistance(RectArea other)
Checks whether this area is within melee distance of another.Melee distance is exactly 1 tile, so this method computes and returns whether the shortest distance to the passed area is directly on the outside of this areas edge.
- Parameters:
other- the other area- Returns:
- true if in melee distance, false otherwise
-
isInMeleeDistance
public boolean isInMeleeDistance(Positionable other)
Checks whether a coordinate is within melee distance of this area.- Parameters:
other- the coordinate- Returns:
- true if in melee distance, false otherwise
- See Also:
isInMeleeDistance(RectArea)
-
intersectsWith
public boolean intersectsWith(RectArea other)
Checks whether this area intersects with another.- Parameters:
other- the other area- Returns:
- true if the areas intersect, false otherwise
-
canTravelInDirection
public boolean canTravelInDirection(int dx, int dy)Determines if the area can travel in one of the 9 directions by using the standard collision detection algorithm.Note that this method does not consider other actors as a collision, but most non-boss NPCs do check for collision with some actors. For actor collision checking, use the
canTravelInDirection(RSWorldView, int, int, Predicate)method.- Parameters:
dx- the x-axis direction to travel (-1, 0, or 1)dy- the y-axis direction to travel (-1, 0, or 1)- Returns:
- true if the area can travel in the specified direction
-
canTravelInDirection
public boolean canTravelInDirection(RSWorldView wv, int dx, int dy)
Determines if the area can travel in one of the 9 directions by using the standard collision detection algorithm.Note that this method does not consider other actors as a collision, but most non-boss NPCs do check for collision with some actors. For actor collision checking, use the
canTravelInDirection(RSWorldView, int, int, Predicate)method.- Parameters:
dx- the x-axis direction to travel (-1, 0, or 1)dy- the y-axis direction to travel (-1, 0, or 1)- Returns:
- true if the area can travel in the specified direction
-
canTravelInDirection
public boolean canTravelInDirection(RSWorldView wv, int dx, int dy, java.util.function.Predicate<? super Positionable> extraCondition)
Determines if the area can travel in one of the 9 directions by using the standard collision detection algorithm.The passed x and y axis directions indicate the direction to travel in.
Note that this method does not normally consider other actors as a collision, but most non-boss NPCs do check for collision with some actors. However, using the
extraConditionparam it is possible to implement this check manually.- Parameters:
dx- the x-axis direction to travel (-1, 0, or 1)dy- the y-axis direction to travel (-1, 0, or 1)extraCondition- an additional condition to perform when checking valid tiles, such as performing a check for un-passable actors- Returns:
- true if the area can travel in the specified direction
-
hasLineOfSightTo
public boolean hasLineOfSightTo(RSWorldView wv, RectArea other)
Determine if this WorldArea has line of sight to another WorldArea.Note that the reverse isn't necessarily true, meaning this can return true while the other WorldArea does not have line of sight to this WorldArea.
- Parameters:
other- The other WorldArea to compare with- Returns:
- Returns true if this WorldArea has line of sight to the other
-
hasLineOfSightTo
public boolean hasLineOfSightTo(Positionable other)
Determine if this WorldArea has line of sight to another WorldArea.Note that the reverse isn't necessarily true, meaning this can return true while the other WorldArea does not have line of sight to this WorldArea.
- Parameters:
other- The other WorldTile to compare with- Returns:
- Returns true if this WorldTile has line of sight to the WorldTile
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
canEqual
protected boolean canEqual(java.lang.Object other)
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-