mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-13 19:39:04 +07:00
Cleaned up team assignment
This commit is contained in:
parent
6dd10b74d5
commit
9c179e559b
@ -101,18 +101,20 @@ public class Units{
|
||||
}
|
||||
|
||||
/**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));
|
||||
return tile == null ? null : tile.entity;
|
||||
}
|
||||
|
||||
/**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);
|
||||
}
|
||||
|
||||
/**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)){
|
||||
TileEntity entity = world.indexer.findTile(enemy, x, y, range, pred);
|
||||
if(entity != null){
|
||||
@ -134,7 +136,7 @@ public class Units{
|
||||
}
|
||||
|
||||
//then check all player groups
|
||||
for(io.anuke.mindustry.entities.type.Player player : playerGroup.all()){
|
||||
for(Player player : playerGroup.all()){
|
||||
cons.accept(player);
|
||||
}
|
||||
}
|
||||
@ -156,6 +158,8 @@ public class Units{
|
||||
|
||||
/**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){
|
||||
if(team == Team.none) return null;
|
||||
|
||||
result = null;
|
||||
cdist = 0f;
|
||||
|
||||
|
@ -6,9 +6,6 @@ import io.anuke.arc.collection.ObjectSet;
|
||||
import io.anuke.mindustry.Vars;
|
||||
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.*/
|
||||
public class Teams{
|
||||
private TeamData[] map = new TeamData[Team.all.length];
|
||||
@ -26,8 +23,7 @@ public class Teams{
|
||||
/**Returns team data by type.*/
|
||||
public TeamData get(Team team){
|
||||
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, enemies.toArray(Team.class));
|
||||
add(team, Array.with(Team.all).select(t -> t != team).toArray(Team.class));
|
||||
}
|
||||
return map[team.ordinal()];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user