diff --git a/core/src/io/anuke/mindustry/content/Mechs.java b/core/src/io/anuke/mindustry/content/Mechs.java index c946060560..63bf1615d1 100644 --- a/core/src/io/anuke/mindustry/content/Mechs.java +++ b/core/src/io/anuke/mindustry/content/Mechs.java @@ -24,6 +24,7 @@ public class Mechs implements ContentList{ speed = 0.5f; weapon = Weapons.blaster; trailColor = Palette.lightTrail; + maxSpeed = 3f; }}; delta = new Mech("delta-mech", false){{ @@ -37,16 +38,19 @@ public class Mechs implements ContentList{ weapon = Weapons.shockgun; ammoCapacity = 50; trailColor = Color.valueOf("d3ddff"); + maxSpeed = 3f; }}; tau = new Mech("tau-mech", false){{ drillPower = 2; speed = 0.5f; + maxSpeed = 3f; }}; omega = new Mech("omega-mech", false){{ drillPower = 1; speed = 0.4f; + maxSpeed = 3f; }}; dart = new Mech("dart-ship", true){{ diff --git a/core/src/io/anuke/mindustry/core/Logic.java b/core/src/io/anuke/mindustry/core/Logic.java index a29cb316bf..9f9af7e9bb 100644 --- a/core/src/io/anuke/mindustry/core/Logic.java +++ b/core/src/io/anuke/mindustry/core/Logic.java @@ -131,11 +131,11 @@ public class Logic extends Module{ if(!state.is(State.paused) || Net.active()){ - if(!state.mode.disableWaveTimer){ + if(!state.mode.disableWaveTimer && !state.mode.disableWaves){ state.wavetime -= Timers.delta(); } - if(!Net.client() && state.wavetime <= 0){ + if(!Net.client() && state.wavetime <= 0 && !state.mode.disableWaves){ runWave(); } diff --git a/core/src/io/anuke/mindustry/core/NetServer.java b/core/src/io/anuke/mindustry/core/NetServer.java index ee4a833465..edf15f17c5 100644 --- a/core/src/io/anuke/mindustry/core/NetServer.java +++ b/core/src/io/anuke/mindustry/core/NetServer.java @@ -12,9 +12,9 @@ import io.anuke.mindustry.content.Mechs; import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.entities.Player; import io.anuke.mindustry.entities.traits.SyncTrait; +import io.anuke.mindustry.game.Version; import io.anuke.mindustry.gen.Call; import io.anuke.mindustry.gen.RemoteReadServer; -import io.anuke.mindustry.game.Version; import io.anuke.mindustry.net.*; import io.anuke.mindustry.net.Administration.PlayerInfo; import io.anuke.mindustry.net.Packets.*; @@ -175,16 +175,14 @@ public class NetServer extends Module{ NetConnection connection = Net.getConnection(id); if(player == null || connection == null || packet.snapid < connection.lastRecievedClientSnapshot) return; - boolean verifyPosition = !player.isDead() && !debug && headless && !player.mech.flying && player.getCarrier() == null; + boolean verifyPosition = !player.isDead() && !debug && headless && player.getCarrier() == null; if(connection.lastRecievedClientTime == 0) connection.lastRecievedClientTime = TimeUtils.millis() - 16; long elapsed = TimeUtils.timeSinceMillis(connection.lastRecievedClientTime); - float maxSpeed = (packet.boosting && !player.mech.flying ? player.mech.boostSpeed : player.mech.speed) * 2.5f; - - //extra 1.1x multiplicaton is added just in case - float maxMove = elapsed / 1000f * 60f * maxSpeed * 1.1f; + float maxSpeed = packet.boosting && !player.mech.flying ? player.mech.boostSpeed : player.mech.speed; + float maxMove = elapsed / 1000f * 60f * Math.min(compound(maxSpeed, player.mech.drag) * 1.1f, player.mech.maxSpeed * 1.05f); player.pointerX = packet.pointerX; player.pointerY = packet.pointerY; @@ -238,6 +236,15 @@ public class NetServer extends Module{ }); } + private float compound(float speed, float drag){ + float total = 0f; + for(int i = 0; i < 10; i++){ + total *= (1f - drag); + total += speed; + } + return total; + } + /** * Sends a raw byte[] snapshot to a client, splitting up into chunks when needed. */ diff --git a/core/src/io/anuke/mindustry/core/World.java b/core/src/io/anuke/mindustry/core/World.java index 48cd71787e..d436f01771 100644 --- a/core/src/io/anuke/mindustry/core/World.java +++ b/core/src/io/anuke/mindustry/core/World.java @@ -219,6 +219,7 @@ public class World extends Module{ /**Loads up a sector map. This does not call play(), but calls reset().*/ public void loadSector(Sector sector){ currentSector = sector; + state.mode = sector.missions.peek().getMode(); Timers.mark(); Timers.mark(); diff --git a/core/src/io/anuke/mindustry/entities/Player.java b/core/src/io/anuke/mindustry/entities/Player.java index 1dec7b45e6..98d170daad 100644 --- a/core/src/io/anuke/mindustry/entities/Player.java +++ b/core/src/io/anuke/mindustry/entities/Player.java @@ -547,7 +547,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra velocity.add(movement); } float prex = x, prey = y; - updateVelocityStatus(mech.drag, 10f); + updateVelocityStatus(mech.drag, mech.maxSpeed); moved = distanceTo(prex, prey) > 0.01f; }else{ velocity.setZero(); diff --git a/core/src/io/anuke/mindustry/game/GameMode.java b/core/src/io/anuke/mindustry/game/GameMode.java index fcf9e8c09a..664739094a 100644 --- a/core/src/io/anuke/mindustry/game/GameMode.java +++ b/core/src/io/anuke/mindustry/game/GameMode.java @@ -4,20 +4,19 @@ import io.anuke.ucore.util.Bundles; public enum GameMode{ waves, - //disabled for technical reasons - /*sandbox{ - { - infiniteResources = true; - disableWaveTimer = true; - } - },*/ - freebuild{ - { - disableWaveTimer = true; - } - }; + sandbox{{ + infiniteResources = true; + disableWaveTimer = true; + }}, + freebuild{{ + disableWaveTimer = true; + }}, + noWaves{{ + disableWaves = true; + }}; public boolean infiniteResources; public boolean disableWaveTimer; + public boolean disableWaves; public String description(){ return Bundles.get("mode." + name() + ".description"); diff --git a/core/src/io/anuke/mindustry/maps/missions/BattleMission.java b/core/src/io/anuke/mindustry/maps/missions/BattleMission.java index ddbbd10d63..2f9ad85ea2 100644 --- a/core/src/io/anuke/mindustry/maps/missions/BattleMission.java +++ b/core/src/io/anuke/mindustry/maps/missions/BattleMission.java @@ -2,6 +2,7 @@ package io.anuke.mindustry.maps.missions; import io.anuke.mindustry.Vars; import io.anuke.mindustry.content.blocks.StorageBlocks; +import io.anuke.mindustry.game.GameMode; import io.anuke.mindustry.game.Team; import io.anuke.mindustry.maps.Sector; import io.anuke.mindustry.world.Tile; @@ -14,6 +15,11 @@ public class BattleMission implements Mission{ this.difficulty = difficulty; } + @Override + public GameMode getMode(){ + return GameMode.noWaves; + } + @Override public String displayString(){ return Bundles.get("text.mission.battle"); diff --git a/core/src/io/anuke/mindustry/maps/missions/Mission.java b/core/src/io/anuke/mindustry/maps/missions/Mission.java index d50caf72b5..dc0746c077 100644 --- a/core/src/io/anuke/mindustry/maps/missions/Mission.java +++ b/core/src/io/anuke/mindustry/maps/missions/Mission.java @@ -1,11 +1,13 @@ package io.anuke.mindustry.maps.missions; +import io.anuke.mindustry.game.GameMode; import io.anuke.mindustry.maps.Sector; import io.anuke.mindustry.world.Tile; public interface Mission{ boolean isComplete(); String displayString(); + GameMode getMode(); default void generate(Tile[][] tiles, Sector sector){} } diff --git a/core/src/io/anuke/mindustry/maps/missions/ResourceMission.java b/core/src/io/anuke/mindustry/maps/missions/ResourceMission.java index 4b7896ee5f..6f29e93f1d 100644 --- a/core/src/io/anuke/mindustry/maps/missions/ResourceMission.java +++ b/core/src/io/anuke/mindustry/maps/missions/ResourceMission.java @@ -1,6 +1,7 @@ package io.anuke.mindustry.maps.missions; import io.anuke.mindustry.Vars; +import io.anuke.mindustry.game.GameMode; import io.anuke.mindustry.type.Item; import io.anuke.ucore.util.Bundles; @@ -13,6 +14,11 @@ public class ResourceMission implements Mission{ this.amount = amount; } + @Override + public GameMode getMode(){ + return GameMode.waves; + } + @Override public boolean isComplete(){ return Vars.state.teams.getTeams(true).first().cores.first().entity.items.has(item, amount); diff --git a/core/src/io/anuke/mindustry/maps/missions/WaveMission.java b/core/src/io/anuke/mindustry/maps/missions/WaveMission.java index ba3575658a..d94bd02c94 100644 --- a/core/src/io/anuke/mindustry/maps/missions/WaveMission.java +++ b/core/src/io/anuke/mindustry/maps/missions/WaveMission.java @@ -1,8 +1,9 @@ package io.anuke.mindustry.maps.missions; +import io.anuke.mindustry.game.GameMode; import io.anuke.ucore.util.Bundles; -import static io.anuke.mindustry.Vars.*; +import static io.anuke.mindustry.Vars.state; public class WaveMission implements Mission{ private final int target; @@ -11,6 +12,11 @@ public class WaveMission implements Mission{ this.target = target; } + @Override + public GameMode getMode(){ + return GameMode.waves; + } + @Override public String displayString(){ return Bundles.format("text.mission.wave", target); diff --git a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java index 0245cfe2cb..5cddbd9d0b 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java @@ -285,6 +285,7 @@ public class HudFragment extends Fragment{ }); table.add().growX(); + table.visible(() -> !state.mode.disableWaves); playButton(uheight); }