runelite-api: add distance methods to actor and tile queries
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.api.queries;
|
package net.runelite.api.queries;
|
||||||
|
|
||||||
|
import static java.lang.Math.abs;
|
||||||
import net.runelite.api.Actor;
|
import net.runelite.api.Actor;
|
||||||
import net.runelite.api.Point;
|
import net.runelite.api.Point;
|
||||||
import net.runelite.api.Query;
|
import net.runelite.api.Query;
|
||||||
@@ -93,4 +94,23 @@ public abstract class ActorQuery<EntityType extends Actor, QueryType> extends Qu
|
|||||||
predicate = and(a -> a.getInteracting().equals(a));
|
predicate = and(a -> a.getInteracting().equals(a));
|
||||||
return (QueryType) this;
|
return (QueryType) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public QueryType isWithinDistance(Point to, int distance)
|
||||||
|
{
|
||||||
|
predicate = and(a -> a.getLocalLocation().distanceTo(to) <= distance);
|
||||||
|
return (QueryType) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public QueryType isWithinArea(Point from, int area)
|
||||||
|
{
|
||||||
|
predicate = and(a ->
|
||||||
|
{
|
||||||
|
Point localLocation = a.getLocalLocation();
|
||||||
|
return abs(localLocation.getX() - from.getX()) < area
|
||||||
|
&& abs(localLocation.getY() - from.getY()) < area;
|
||||||
|
});
|
||||||
|
return (QueryType) this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.api.queries;
|
package net.runelite.api.queries;
|
||||||
|
|
||||||
|
import static java.lang.Math.abs;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.Point;
|
import net.runelite.api.Point;
|
||||||
import net.runelite.api.Query;
|
import net.runelite.api.Query;
|
||||||
@@ -89,4 +90,23 @@ public abstract class TileObjectQuery<EntityType extends TileObject, QueryType>
|
|||||||
predicate = and(object -> object.getLocalLocation().equals(location));
|
predicate = and(object -> object.getLocalLocation().equals(location));
|
||||||
return (QueryType) this;
|
return (QueryType) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public QueryType isWithinDistance(Point to, int distance)
|
||||||
|
{
|
||||||
|
predicate = and(a -> a.getLocalLocation().distanceTo(to) <= distance);
|
||||||
|
return (QueryType) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public QueryType isWithinArea(Point from, int area)
|
||||||
|
{
|
||||||
|
predicate = and(a ->
|
||||||
|
{
|
||||||
|
Point localLocation = a.getLocalLocation();
|
||||||
|
return abs(localLocation.getX() - from.getX()) < area
|
||||||
|
&& abs(localLocation.getY() - from.getY()) < area;
|
||||||
|
});
|
||||||
|
return (QueryType) this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user