diff --git a/core/src/mindustry/ai/BlockIndexer.java b/core/src/mindustry/ai/BlockIndexer.java index 8f560a4072..e79077e3e9 100644 --- a/core/src/mindustry/ai/BlockIndexer.java +++ b/core/src/mindustry/ai/BlockIndexer.java @@ -221,8 +221,7 @@ public class BlockIndexer{ } public Building findEnemyTile(Team team, float x, float y, float range, Boolf pred){ - for(Team enemy : activeTeams){ - if(!team.isEnemy(enemy)) continue; + for(Team enemy : team.enemies()){ Building entity = indexer.findTile(enemy, x, y, range, pred, true); if(entity != null){ diff --git a/core/src/mindustry/entities/comp/BulletComp.java b/core/src/mindustry/entities/comp/BulletComp.java index 8843069d37..694426f5ad 100644 --- a/core/src/mindustry/entities/comp/BulletComp.java +++ b/core/src/mindustry/entities/comp/BulletComp.java @@ -27,7 +27,7 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw @Override public void getCollisions(Cons consumer){ - for(Team team : state.teams.enemiesOf(team)){ + for(Team team : team.enemies()){ consumer.get(teamIndex.tree(team)); } } diff --git a/core/src/mindustry/game/Team.java b/core/src/mindustry/game/Team.java index 278a603d24..0c3f4d391e 100644 --- a/core/src/mindustry/game/Team.java +++ b/core/src/mindustry/game/Team.java @@ -80,7 +80,7 @@ public class Team implements Comparable{ return state.rules.teams.get(this); } - public Seq enemies(){ + public Team[] enemies(){ return state.teams.enemiesOf(this); } diff --git a/core/src/mindustry/game/Teams.java b/core/src/mindustry/game/Teams.java index 0e27ef83d5..2327e1c0d2 100644 --- a/core/src/mindustry/game/Teams.java +++ b/core/src/mindustry/game/Teams.java @@ -4,7 +4,6 @@ import arc.func.*; import arc.math.geom.*; import arc.struct.*; import arc.util.ArcAnnotate.*; -import arc.util.*; import mindustry.ai.*; import mindustry.gen.*; import mindustry.world.blocks.storage.CoreBlock.*; @@ -23,13 +22,9 @@ public class Teams{ } public @Nullable CoreEntity closestEnemyCore(float x, float y, Team team){ - for(TeamData data : active){ - if(areEnemies(team, data.team)){ - CoreEntity tile = Geometry.findClosest(x, y, data.cores); - if(tile != null){ - return tile; - } - } + for(Team enemy : team.enemies()){ + CoreEntity tile = Geometry.findClosest(x, y, enemy.cores()); + if(tile != null) return tile; } return null; } @@ -38,7 +33,7 @@ public class Teams{ return Geometry.findClosest(x, y, get(team).cores); } - public Seq enemiesOf(Team team){ + public Team[] enemiesOf(Team team){ return get(team).enemies; } @@ -67,10 +62,10 @@ public class Teams{ /** Returns team data by type. */ public TeamData get(Team team){ - if(map[Pack.u(team.id)] == null){ - map[Pack.u(team.id)] = new TeamData(team); + if(map[team.uid] == null){ + map[team.uid] = new TeamData(team); } - return map[Pack.u(team.id)]; + return map[team.uid]; } public Seq playerCores(){ @@ -135,20 +130,23 @@ public class Teams{ } for(TeamData data : active){ - data.enemies.clear(); + Seq enemies = new Seq<>(); + for(TeamData other : active){ if(areEnemies(data.team, other.team)){ - data.enemies.add(other.team); + enemies.add(other.team); } } + + data.enemies = enemies.toArray(Team.class); } } public class TeamData{ public final Seq cores = new Seq<>(); - public final Seq enemies = new Seq<>(); public final Team team; public final BaseAI ai; + public Team[] enemies = {}; public Queue blocks = new Queue<>(); public TeamData(Team team){ diff --git a/core/src/mindustry/game/Universe.java b/core/src/mindustry/game/Universe.java index 94bcc78322..d0054d68dc 100644 --- a/core/src/mindustry/game/Universe.java +++ b/core/src/mindustry/game/Universe.java @@ -21,7 +21,7 @@ public class Universe{ private int turn; private float turnCounter; - private Schematic lastLoadout = Loadouts.basicShard; + private Schematic lastLoadout; private Seq lastLaunchResources = new Seq<>(); public Universe(){ @@ -94,6 +94,7 @@ public class Universe{ } public Schematic getLastLoadout(){ + if(lastLoadout == null) lastLoadout = Loadouts.basicShard; return lastLoadout; } diff --git a/core/src/mindustry/input/DesktopInput.java b/core/src/mindustry/input/DesktopInput.java index 04ccf40bec..e54642bf86 100644 --- a/core/src/mindustry/input/DesktopInput.java +++ b/core/src/mindustry/input/DesktopInput.java @@ -49,8 +49,12 @@ public class DesktopInput extends InputHandler{ @Override public void buildUI(Group group){ group.fill(t -> { - t.bottom().update(() -> t.getColor().a = Mathf.lerpDelta(t.getColor().a, player.builder().isBuilding() ? 1f : 0f, 0.15f)); - t.visible(() -> Core.settings.getBool("hints") && selectRequests.isEmpty()); + t.bottom(); + t.visible(() -> { + t.getColor().a = Mathf.lerpDelta(t.getColor().a, player.builder().isBuilding() ? 1f : 0f, 0.15f); + + return Core.settings.getBool("hints") && selectRequests.isEmpty() && t.getColor().a > 0.01f; + }); t.touchable(() -> t.getColor().a < 0.1f ? Touchable.disabled : Touchable.childrenOnly); t.table(Styles.black6, b -> { b.defaults().left();