Fixed certain teams not attacking other units

This commit is contained in:
Anuken
2020-09-05 15:03:13 -04:00
parent 09e34da880
commit c483ae2c23
3 changed files with 19 additions and 4 deletions

View File

@@ -251,9 +251,20 @@ public class Units{
/** Iterates over all units that are enemies of this team. */
public static void nearbyEnemies(Team team, float x, float y, float width, float height, Cons<Unit> cons){
for(Team enemy : state.teams.enemiesOf(team)){
nearby(enemy, x, y, width, height, cons);
if(team.active()){
for(Team enemy : state.teams.enemiesOf(team)){
nearby(enemy, x, y, width, height, cons);
}
}else{
//inactive teams have no cache, check everything
//TODO cache all teams with units OR blocks
for(Team other : Team.all){
if(other != team && teamIndex.count(other) > 0){
nearby(other, x, y, width, height, cons);
}
}
}
}
/** Iterates over all units that are enemies of this team. */