Hover unit display
This commit is contained in:
@@ -180,6 +180,25 @@ public class Units{
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Returns the closest ally of this team. Filter by predicate.
|
||||
* Unlike the closest() function, this only guarantees that unit hitboxes overlap the range. */
|
||||
public static Unitc closestOverlap(Team team, float x, float y, float range, Boolf<Unitc> predicate){
|
||||
result = null;
|
||||
cdist = 0f;
|
||||
|
||||
nearby(team, x - range, y - range, range*2f, range*2f, e -> {
|
||||
if(!predicate.get(e)) return;
|
||||
|
||||
float dist = e.dst2(x, y);
|
||||
if(result == null || dist < cdist){
|
||||
result = e;
|
||||
cdist = dist;
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Iterates over all units in a rectangle. */
|
||||
public static void nearby(Team team, float x, float y, float width, float height, Cons<Unitc> cons){
|
||||
teamIndex.tree(team).intersect(height, x, y, width, cons);
|
||||
|
||||
Reference in New Issue
Block a user