diff --git a/core/src/io/anuke/mindustry/core/GameState.java b/core/src/io/anuke/mindustry/core/GameState.java index 4e20c5ba75..bde128eb91 100644 --- a/core/src/io/anuke/mindustry/core/GameState.java +++ b/core/src/io/anuke/mindustry/core/GameState.java @@ -8,6 +8,9 @@ import io.anuke.mindustry.game.Teams; import io.anuke.mindustry.net.Net; import io.anuke.ucore.core.Events; +import static io.anuke.mindustry.Vars.unitGroups; +import static io.anuke.mindustry.Vars.waveTeam; + public class GameState{ public int wave = 1; public float wavetime; @@ -16,8 +19,13 @@ public class GameState{ public Difficulty difficulty = Difficulty.normal; public WaveSpawner spawner = new WaveSpawner(); public Teams teams = new Teams(); + public int enemies; private State state = State.menu; + public int enemies(){ + return Net.client() ? enemies : unitGroups[waveTeam.ordinal()].size(); + } + public void set(State astate){ Events.fire(new StateChangeEvent(state, astate)); state = astate; diff --git a/core/src/io/anuke/mindustry/core/NetClient.java b/core/src/io/anuke/mindustry/core/NetClient.java index a0b26e543f..99a224da9b 100644 --- a/core/src/io/anuke/mindustry/core/NetClient.java +++ b/core/src/io/anuke/mindustry/core/NetClient.java @@ -284,6 +284,7 @@ public class NetClient extends Module{ //read wave info state.wavetime = input.readFloat(); state.wave = input.readInt(); + state.enemies = input.readInt(); byte cores = input.readByte(); for(int i = 0; i < cores; i++){ diff --git a/core/src/io/anuke/mindustry/core/NetServer.java b/core/src/io/anuke/mindustry/core/NetServer.java index cc0f99441f..25ee6de9a4 100644 --- a/core/src/io/anuke/mindustry/core/NetServer.java +++ b/core/src/io/anuke/mindustry/core/NetServer.java @@ -477,6 +477,7 @@ public class NetServer extends Module{ //write wave datas dataStream.writeFloat(state.wavetime); dataStream.writeInt(state.wave); + dataStream.writeInt(state.enemies()); ObjectSet cores = state.teams.get(player.getTeam()).cores; diff --git a/core/src/io/anuke/mindustry/entities/traits/SyncTrait.java b/core/src/io/anuke/mindustry/entities/traits/SyncTrait.java index c41fcbf264..9509e4eb68 100644 --- a/core/src/io/anuke/mindustry/entities/traits/SyncTrait.java +++ b/core/src/io/anuke/mindustry/entities/traits/SyncTrait.java @@ -33,10 +33,11 @@ public interface SyncTrait extends Entity, TypeTrait{ if(isClipped()){ //move off screen when no longer in bounds - if(!Tmp.r1.setSize( - Core.camera.viewportWidth * Core.camera.zoom * NetClient.viewScale, - Core.camera.viewportHeight * Core.camera.zoom * NetClient.viewScale) - .setCenter(Core.camera.position.x, Core.camera.position.y).contains(getX(), getY())){ + Tmp.r1.setSize(Core.camera.viewportWidth * Core.camera.zoom * NetClient.viewScale, + Core.camera.viewportHeight * Core.camera.zoom * NetClient.viewScale) + .setCenter(Core.camera.position.x, Core.camera.position.y); + + if(!Tmp.r1.contains(getX(), getY()) && !Tmp.r1.contains(getInterpolator().last.x, getInterpolator().last.y)){ set(-99999f, -99999f); return; } diff --git a/core/src/io/anuke/mindustry/maps/missions/WaveMission.java b/core/src/io/anuke/mindustry/maps/missions/WaveMission.java index 5a257192a4..be7d83bf46 100644 --- a/core/src/io/anuke/mindustry/maps/missions/WaveMission.java +++ b/core/src/io/anuke/mindustry/maps/missions/WaveMission.java @@ -1,14 +1,12 @@ package io.anuke.mindustry.maps.missions; import com.badlogic.gdx.utils.Array; -import io.anuke.mindustry.Vars; import io.anuke.mindustry.game.GameMode; import io.anuke.mindustry.game.SpawnGroup; import io.anuke.mindustry.game.Team; import io.anuke.mindustry.game.Waves; import io.anuke.mindustry.maps.Sector; import io.anuke.mindustry.maps.generation.Generation; -import io.anuke.mindustry.net.Net; import io.anuke.ucore.util.Bundles; import static io.anuke.mindustry.Vars.*; @@ -62,9 +60,9 @@ public class WaveMission extends MissionWithStartingCore{ public String displayString(){ return state.wave > target ? Bundles.format( - Vars.unitGroups[Vars.waveTeam.ordinal()].size() > 1 && !Net.client() ? + state.enemies() > 1 ? "text.mission.wave.enemies" : - "text.mission.wave.enemy", target, target, Vars.unitGroups[Vars.waveTeam.ordinal()].size()) : + "text.mission.wave.enemy", target, target, state.enemies()) : Bundles.format("text.mission.wave", state.wave, target, (int)(state.wavetime/60)); } @@ -82,6 +80,6 @@ public class WaveMission extends MissionWithStartingCore{ @Override public boolean isComplete(){ - return state.wave > target && Vars.unitGroups[Vars.waveTeam.ordinal()].size() == 0; + return state.wave > target && state.enemies() == 0; } } diff --git a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java index b2deb85ce9..2da9f991a6 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java @@ -366,10 +366,10 @@ public class HudFragment extends Fragment{ table.labelWrap(() -> world.getSector() == null ? - (unitGroups[waveTeam.ordinal()].size() > 0 && state.mode.disableWaveTimer ? - wavef.get(state.wave) + "\n" + (unitGroups[waveTeam.ordinal()].size() == 1 ? - enemyf.get(unitGroups[waveTeam.ordinal()].size()) : - enemiesf.get(unitGroups[waveTeam.ordinal()].size())) : + (state.enemies() > 0 && state.mode.disableWaveTimer ? + wavef.get(state.wave) + "\n" + (state.enemies() == 1 ? + enemyf.get(state.enemies()) : + enemiesf.get(state.enemies())) : wavef.get(state.wave) + "\n" + (!state.mode.disableWaveTimer ? Bundles.format("text.wave.waiting", (int)(state.wavetime/60)) :