This commit is contained in:
Anuken
2020-05-15 19:54:04 -04:00
parent 6a0dc4c965
commit 381df23bf2
8 changed files with 99 additions and 40 deletions

View File

@@ -1,16 +1,15 @@
package mindustry.async;
import arc.math.geom.*;
import arc.struct.*;
import mindustry.*;
import mindustry.game.*;
import mindustry.game.Teams.*;
import mindustry.gen.*;
import java.util.*;
/** Creates quadtrees per unit team. */
public class TeamIndexProcess implements AsyncProcess{
private QuadTree<Unitc>[] trees = new QuadTree[Team.all().length];
private Array<Team> active = new Array<>();
private int[] counts = new int[Team.all().length];
public QuadTree<Unitc> tree(Team team){
@@ -29,28 +28,20 @@ public class TeamIndexProcess implements AsyncProcess{
@Override
public void reset(){
active.clear();
counts = new int[Team.all().length];
trees = new QuadTree[Team.all().length];
}
@Override
public void begin(){
for(TeamData data : Vars.state.teams.getActive()){
if(!active.contains(data.team)){
active.add(data.team);
}
}
for(Team team : active){
for(Team team : Team.all()){
if(trees[team.uid] != null){
trees[team.uid].clear();
}
}
for(Team team : active){
counts[team.id] = 0;
}
Arrays.fill(counts, 0);
for(Unitc unit : Groups.unit){
tree(unit.team()).insert(unit);