Cleaned up team assignment
This commit is contained in:
@@ -101,18 +101,20 @@ public class Units{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**Returns the neareset damaged tile.*/
|
/**Returns the neareset damaged tile.*/
|
||||||
public static io.anuke.mindustry.entities.type.TileEntity findDamagedTile(Team team, float x, float y){
|
public static TileEntity findDamagedTile(Team team, float x, float y){
|
||||||
Tile tile = Geometry.findClosest(x, y, world.indexer.getDamaged(team));
|
Tile tile = Geometry.findClosest(x, y, world.indexer.getDamaged(team));
|
||||||
return tile == null ? null : tile.entity;
|
return tile == null ? null : tile.entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**Returns the neareset ally tile in a range.*/
|
/**Returns the neareset ally tile in a range.*/
|
||||||
public static io.anuke.mindustry.entities.type.TileEntity findAllyTile(Team team, float x, float y, float range, Predicate<Tile> pred){
|
public static TileEntity findAllyTile(Team team, float x, float y, float range, Predicate<Tile> pred){
|
||||||
return world.indexer.findTile(team, x, y, range, pred);
|
return world.indexer.findTile(team, x, y, range, pred);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**Returns the neareset enemy tile in a range.*/
|
/**Returns the neareset enemy tile in a range.*/
|
||||||
public static io.anuke.mindustry.entities.type.TileEntity findEnemyTile(Team team, float x, float y, float range, Predicate<Tile> pred){
|
public static TileEntity findEnemyTile(Team team, float x, float y, float range, Predicate<Tile> pred){
|
||||||
|
if(team == Team.none) return null;
|
||||||
|
|
||||||
for(Team enemy : state.teams.enemiesOf(team)){
|
for(Team enemy : state.teams.enemiesOf(team)){
|
||||||
TileEntity entity = world.indexer.findTile(enemy, x, y, range, pred);
|
TileEntity entity = world.indexer.findTile(enemy, x, y, range, pred);
|
||||||
if(entity != null){
|
if(entity != null){
|
||||||
@@ -134,7 +136,7 @@ public class Units{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//then check all player groups
|
//then check all player groups
|
||||||
for(io.anuke.mindustry.entities.type.Player player : playerGroup.all()){
|
for(Player player : playerGroup.all()){
|
||||||
cons.accept(player);
|
cons.accept(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -156,6 +158,8 @@ public class Units{
|
|||||||
|
|
||||||
/**Returns the closest enemy of this team. Filter by predicate.*/
|
/**Returns the closest enemy of this team. Filter by predicate.*/
|
||||||
public static Unit getClosestEnemy(Team team, float x, float y, float range, Predicate<Unit> predicate){
|
public static Unit getClosestEnemy(Team team, float x, float y, float range, Predicate<Unit> predicate){
|
||||||
|
if(team == Team.none) return null;
|
||||||
|
|
||||||
result = null;
|
result = null;
|
||||||
cdist = 0f;
|
cdist = 0f;
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,6 @@ import io.anuke.arc.collection.ObjectSet;
|
|||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.waveTeam;
|
|
||||||
import static io.anuke.mindustry.Vars.world;
|
|
||||||
|
|
||||||
/**Class for various team-based utilities.*/
|
/**Class for various team-based utilities.*/
|
||||||
public class Teams{
|
public class Teams{
|
||||||
private TeamData[] map = new TeamData[Team.all.length];
|
private TeamData[] map = new TeamData[Team.all.length];
|
||||||
@@ -26,8 +23,7 @@ public class Teams{
|
|||||||
/**Returns team data by type.*/
|
/**Returns team data by type.*/
|
||||||
public TeamData get(Team team){
|
public TeamData get(Team team){
|
||||||
if(map[team.ordinal()] == null){
|
if(map[team.ordinal()] == null){
|
||||||
Array<Team> enemies = Array.with(Team.all).select(t -> t != team && ((t != Team.none && team != Team.none) || (world.isZone() && team == waveTeam)));
|
add(team, Array.with(Team.all).select(t -> t != team).toArray(Team.class));
|
||||||
add(team, enemies.toArray(Team.class));
|
|
||||||
}
|
}
|
||||||
return map[team.ordinal()];
|
return map[team.ordinal()];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user