Automatic assignment of entities

This commit is contained in:
Anuken
2020-04-27 01:31:41 -04:00
parent 2f3c098b50
commit a4d49f5d17
11 changed files with 102 additions and 29 deletions

View File

@@ -126,6 +126,24 @@ public class Units{
return result;
}
/** Returns the closest ally of this team. Filter by predicate. No range. */
public static Unitc closest(Team team, float x, float y, Boolf<Unitc> predicate){
result = null;
cdist = 0f;
for(Unitc e : Groups.unit){
if(!predicate.get(e) || e.team() != team) continue;
float dist = e.dst2(x, y);
if(result == null || dist < cdist){
result = e;
cdist = dist;
}
}
return result;
}
/** Returns the closest ally of this team. Filter by predicate. */
public static Unitc closest(Team team, float x, float y, float range, Boolf<Unitc> predicate){
result = null;