DefenderAI that makes octs follow units (#4757)
This commit is contained in:
@@ -248,7 +248,7 @@ public class Units{
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Returns the closest ally of this team. Filter by predicate. */
|
||||
/** Returns the closest ally of this team in a range. Filter by predicate. */
|
||||
public static Unit closest(Team team, float x, float y, float range, Boolf<Unit> predicate){
|
||||
result = null;
|
||||
cdist = 0f;
|
||||
@@ -266,6 +266,24 @@ public class Units{
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Returns the closest ally of this team using a custom comparison function. Filter by predicate. */
|
||||
public static Unit closest(Team team, float x, float y, Boolf<Unit> predicate, Sortf sort){
|
||||
result = null;
|
||||
cdist = 0f;
|
||||
|
||||
for(Unit e : Groups.unit){
|
||||
if(!predicate.get(e) || e.team() != team) continue;
|
||||
|
||||
float cost = sort.cost(e, x, y);
|
||||
if(result == null || cost < cdist){
|
||||
result = e;
|
||||
cdist = cost;
|
||||
}
|
||||
}
|
||||
|
||||
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 Unit closestOverlap(Team team, float x, float y, float range, Boolf<Unit> predicate){
|
||||
|
||||
Reference in New Issue
Block a user