This commit is contained in:
Anuken
2020-10-13 15:56:00 -04:00
parent ca875876cd
commit 5d76dd0e2f
7 changed files with 58 additions and 41 deletions

View File

@@ -3,9 +3,11 @@ package mindustry.entities;
import arc.*;
import arc.func.*;
import arc.math.geom.*;
import arc.struct.*;
import mindustry.annotations.Annotations.*;
import mindustry.content.*;
import mindustry.game.*;
import mindustry.game.Teams.*;
import mindustry.gen.*;
import mindustry.type.*;
import mindustry.world.*;
@@ -308,20 +310,12 @@ 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){
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 && other.data().unitCount > 0){
nearby(other, x, y, width, height, cons);
}
Seq<TeamData> data = state.teams.present;
for(int i = 0; i < data.size; i++){
if(data.items[i].team != team){
nearby(data.items[i].team, x, y, width, height, cons);
}
}
}
/** Iterates over all units that are enemies of this team. */