diff --git a/core/src/io/anuke/mindustry/entities/Units.java b/core/src/io/anuke/mindustry/entities/Units.java index d9c82f7ec0..d99b0aff67 100644 --- a/core/src/io/anuke/mindustry/entities/Units.java +++ b/core/src/io/anuke/mindustry/entities/Units.java @@ -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 pred){ + public static TileEntity findAllyTile(Team team, float x, float y, float range, Predicate 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 pred){ + public static TileEntity findEnemyTile(Team team, float x, float y, float range, Predicate 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 predicate){ + if(team == Team.none) return null; + result = null; cdist = 0f; diff --git a/core/src/io/anuke/mindustry/game/Teams.java b/core/src/io/anuke/mindustry/game/Teams.java index 4c32cbeceb..28ffdfc2a2 100644 --- a/core/src/io/anuke/mindustry/game/Teams.java +++ b/core/src/io/anuke/mindustry/game/Teams.java @@ -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 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()]; }