From 804758b1792846fc5eab880554810e64779122b3 Mon Sep 17 00:00:00 2001 From: Anuken Date: Thu, 11 Jan 2018 13:46:32 -0500 Subject: [PATCH] Many bugfixes for multiplayer, QoL, balancing, new difficulties --- android/AndroidManifest.xml | 4 +- core/assets/bundles/bundle.properties | 2 + core/src/io/anuke/mindustry/ai/Pathfind.java | 2 +- core/src/io/anuke/mindustry/core/Control.java | 26 +++++++----- .../io/anuke/mindustry/core/NetClient.java | 29 ++++++++++++- .../io/anuke/mindustry/core/NetServer.java | 41 +++++++++++++++++++ .../src/io/anuke/mindustry/core/Renderer.java | 2 +- core/src/io/anuke/mindustry/core/World.java | 6 ++- .../io/anuke/mindustry/entities/Player.java | 5 ++- .../io/anuke/mindustry/game/Difficulty.java | 28 +++++++++++++ .../{entities => game}/EnemySpawn.java | 9 ++-- .../mindustry/{world => game}/GameMode.java | 2 +- .../mindustry/{world => game}/SpawnPoint.java | 3 +- .../{entities => game}/WaveCreator.java | 3 +- .../mindustry/graphics/BlockRenderer.java | 2 +- .../anuke/mindustry/input/InputHandler.java | 10 +++-- core/src/io/anuke/mindustry/io/BundleGen.java | 2 +- core/src/io/anuke/mindustry/io/NetworkIO.java | 2 +- core/src/io/anuke/mindustry/io/SaveMeta.java | 2 +- core/src/io/anuke/mindustry/io/Saves.java | 2 +- .../anuke/mindustry/io/versions/Save12.java | 2 +- .../anuke/mindustry/io/versions/Save13.java | 1 + .../anuke/mindustry/io/versions/Save14.java | 2 +- core/src/io/anuke/mindustry/net/Packets.java | 5 +++ .../io/anuke/mindustry/net/Registrator.java | 2 + .../mindustry/ui/dialogs/LevelDialog.java | 2 +- .../mindustry/ui/dialogs/PausedDialog.java | 4 +- .../ui/dialogs/SettingsMenuDialog.java | 3 +- .../mindustry/ui/fragments/ChatFragment.java | 7 ++-- .../world/blocks/ProductionBlocks.java | 4 +- .../world/blocks/types/BlockPart.java | 3 +- .../blocks/types/defense/ShieldBlock.java | 4 +- .../blocks/types/production/Smelter.java | 4 +- 33 files changed, 172 insertions(+), 53 deletions(-) create mode 100644 core/src/io/anuke/mindustry/game/Difficulty.java rename core/src/io/anuke/mindustry/{entities => game}/EnemySpawn.java (83%) rename core/src/io/anuke/mindustry/{world => game}/GameMode.java (91%) rename core/src/io/anuke/mindustry/{world => game}/SpawnPoint.java (82%) rename core/src/io/anuke/mindustry/{entities => game}/WaveCreator.java (98%) diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index a1f1387d60..4c56edee62 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="51" + android:versionName="3.3b3" > diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 674892f245..a0078476f2 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -189,6 +189,8 @@ text.health=health setting.difficulty.easy=easy setting.difficulty.normal=normal setting.difficulty.hard=hard +setting.difficulty.insane=insane +setting.difficulty.purge=purge setting.difficulty.name=Difficulty setting.screenshake.name=Screen Shake setting.smoothcam.name=Smooth Camera diff --git a/core/src/io/anuke/mindustry/ai/Pathfind.java b/core/src/io/anuke/mindustry/ai/Pathfind.java index 46b3004dc5..4409a3c79d 100644 --- a/core/src/io/anuke/mindustry/ai/Pathfind.java +++ b/core/src/io/anuke/mindustry/ai/Pathfind.java @@ -7,7 +7,7 @@ import com.badlogic.gdx.math.Vector2; import io.anuke.mindustry.Vars; import io.anuke.mindustry.entities.enemies.Enemy; import io.anuke.mindustry.entities.enemies.EnemyType; -import io.anuke.mindustry.world.SpawnPoint; +import io.anuke.mindustry.game.SpawnPoint; import io.anuke.mindustry.world.Tile; import io.anuke.ucore.UCore; import io.anuke.ucore.core.Timers; diff --git a/core/src/io/anuke/mindustry/core/Control.java b/core/src/io/anuke/mindustry/core/Control.java index 37c8ca522d..20ec673b58 100644 --- a/core/src/io/anuke/mindustry/core/Control.java +++ b/core/src/io/anuke/mindustry/core/Control.java @@ -12,6 +12,10 @@ import io.anuke.mindustry.entities.*; import io.anuke.mindustry.entities.effect.Shield; import io.anuke.mindustry.entities.enemies.Enemy; import io.anuke.mindustry.entities.enemies.EnemyTypes; +import io.anuke.mindustry.game.Difficulty; +import io.anuke.mindustry.game.EnemySpawn; +import io.anuke.mindustry.game.SpawnPoint; +import io.anuke.mindustry.game.WaveCreator; import io.anuke.mindustry.graphics.Fx; import io.anuke.mindustry.input.AndroidInput; import io.anuke.mindustry.input.DesktopInput; @@ -53,16 +57,16 @@ public class Control extends Module{ public final EntityGroup bulletGroup = Entities.addGroup(Bullet.class); public final EntityGroup shieldGroup = Entities.addGroup(Shield.class); - Array spawns; + Array spawns; int wave = 1; int lastUpdated = -1; float wavetime; float extrawavetime; int enemies = 0; - GameMode mode = GameMode.waves; + io.anuke.mindustry.game.GameMode mode = io.anuke.mindustry.game.GameMode.waves; Tile core; - Array spawnpoints = new Array<>(); + Array spawnpoints = new Array<>(); boolean shouldUpdateItems = false; boolean wasPaused = false; @@ -275,7 +279,7 @@ public class Control extends Module{ return core; } - public Array getSpawnPoints(){ + public Array getSpawnPoints(){ return spawnpoints; } @@ -288,7 +292,7 @@ public class Control extends Module{ } public void addSpawnPoint(Tile tile){ - SpawnPoint point = new SpawnPoint(); + io.anuke.mindustry.game.SpawnPoint point = new SpawnPoint(); point.start = tile; spawnpoints.add(point); } @@ -306,11 +310,11 @@ public class Control extends Module{ Timers.run(18, ()-> ui.loadfrag.hide()); } - public GameMode getMode(){ + public io.anuke.mindustry.game.GameMode getMode(){ return mode; } - public void setMode(GameMode mode){ + public void setMode(io.anuke.mindustry.game.GameMode mode){ this.mode = mode; } @@ -411,9 +415,11 @@ public class Control extends Module{ } float waveSpacing(){ - int scale = Settings.getInt("difficulty"); - float out = (scale == 0 ? 2f : scale == 1f ? 1f : 0.5f); - return wavespace*out; + return wavespace*getDifficulty().timeScaling; + } + + public Difficulty getDifficulty(){ + return Difficulty.values()[Settings.getInt("difficulty")]; } public boolean isHighScore(){ diff --git a/core/src/io/anuke/mindustry/core/NetClient.java b/core/src/io/anuke/mindustry/core/NetClient.java index 258574615c..60c9608a79 100644 --- a/core/src/io/anuke/mindustry/core/NetClient.java +++ b/core/src/io/anuke/mindustry/core/NetClient.java @@ -2,6 +2,7 @@ package io.anuke.mindustry.core; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.utils.IntSet; import com.badlogic.gdx.utils.TimeUtils; import io.anuke.mindustry.Vars; import io.anuke.mindustry.core.GameState.State; @@ -39,12 +40,14 @@ public class NetClient extends Module { boolean connecting = false; boolean gotEntities = false, gotData = false; boolean kicked = false; + IntSet requests = new IntSet(); float playerSyncTime = 2; float dataTimeout = 60*10; public NetClient(){ Net.handle(Connect.class, packet -> { + requests.clear(); connecting = true; gotEntities = false; gotData = false; @@ -110,6 +113,10 @@ public class NetClient extends Module { } } + for(int i = 0; i < data.enemies.length; i ++){ + Net.handleClientReceived(data.enemies[i]); + } + for(int i = 0; i < data.weapons.length; i ++){ Vars.control.addWeapon((Weapon) Upgrade.getByID(data.weapons[i])); } @@ -129,7 +136,7 @@ public class NetClient extends Module { for(int i = 0; i < packet.ids.length; i ++){ int id = packet.ids[i]; if(id != Vars.player.id){ - Entity entity = null; + Entity entity; if(i >= packet.enemyStart){ entity = Vars.control.enemyGroup.getByID(id); }else { @@ -140,6 +147,13 @@ public class NetClient extends Module { if(sync == null){ Gdx.app.error("Mindustry", "Unknown entity ID: " + id + " " + (i >= packet.enemyStart ? "(enemy)" : "(player)")); + if(!requests.contains(id)){ + Gdx.app.error("Mindustry", "Sending entity request: " + id); + requests.add(id); + EntityRequestPacket req = new EntityRequestPacket(); + req.id = id; + Net.send(req, SendMode.tcp); + } continue; } @@ -175,6 +189,7 @@ public class NetClient extends Module { }); Net.handle(EnemySpawnPacket.class, spawn -> { + requests.remove(spawn.id); Gdx.app.postRunnable(() -> { Enemy enemy = new Enemy(EnemyType.getByID(spawn.type)); enemy.set(spawn.x, spawn.y); @@ -259,7 +274,12 @@ public class NetClient extends Module { } }); - Net.handle(Player.class, Player::add); + Net.handle(Player.class, player -> { + requests.remove(player.id); + player.getInterpolator().last.set(player.x, player.y); + player.getInterpolator().target.set(player.x, player.y); + player.add(); + }); Net.handle(ChatPacket.class, packet -> Gdx.app.postRunnable(() -> Vars.ui.chatfrag.addMessage(packet.text, Vars.netClient.colorizeName(packet.id, packet.name)))); @@ -303,6 +323,11 @@ public class NetClient extends Module { } } + public void disconnectQuietly(){ + kicked = true; + Net.disconnect(); + } + public String colorizeName(int id, String name){ return name == null ? null : "[#" + colorArray[id % colorArray.length].toString().toUpperCase() + "]" + name; } diff --git a/core/src/io/anuke/mindustry/core/NetServer.java b/core/src/io/anuke/mindustry/core/NetServer.java index d1ac35c712..9209245074 100644 --- a/core/src/io/anuke/mindustry/core/NetServer.java +++ b/core/src/io/anuke/mindustry/core/NetServer.java @@ -61,6 +61,8 @@ public class NetServer extends Module{ player.name = packet.name; player.isAndroid = packet.android; player.set(Vars.control.core.worldx(), Vars.control.core.worldy() - Vars.tilesize*2); + player.getInterpolator().last.set(player.x, player.y); + player.getInterpolator().target.set(player.x, player.y); player.add(); connections.put(id, player); @@ -73,6 +75,20 @@ public class NetServer extends Module{ dp.playerWeapons[i] = dp.players[i].weaponLeft.id; } + dp.enemies = new EnemySpawnPacket[Vars.control.enemyGroup.amount()]; + + for(int i = 0; i < Vars.control.enemyGroup.amount(); i ++){ + Enemy enemy = Vars.control.enemyGroup.all().get(i); + EnemySpawnPacket e = new EnemySpawnPacket(); + e.x = enemy.x; + e.y = enemy.y; + e.id = enemy.id; + e.tier = (byte)enemy.tier; + e.lane = (byte)enemy.lane; + e.type = enemy.type.id; + dp.enemies[i] = e; + } + UCore.log("Sending entities: " + Arrays.toString(dp.players)); Net.sendExcept(id, player, SendMode.tcp); @@ -102,6 +118,7 @@ public class NetServer extends Module{ Net.handleServer(PositionPacket.class, pos -> { Player player = connections.get(Net.getLastConnection()); + UCore.log("Recieving data: " + Arrays.toString(pos.data), "Player pos: " +player.x, player.y); player.getInterpolator().type.read(player, pos.data); }); @@ -187,6 +204,30 @@ public class NetServer extends Module{ Net.sendExcept(Net.getLastConnection(), packet, SendMode.tcp); }); + + Net.handleServer(EntityRequestPacket.class, packet -> { + int id = packet.id; + int dest = Net.getLastConnection(); + Gdx.app.postRunnable(() -> { + if(Vars.control.playerGroup.getByID(id) != null){ + Net.sendTo(dest, Vars.control.playerGroup.getByID(id), SendMode.tcp); + Gdx.app.error("Mindustry", "Replying to entity request: player, " + id); + }else if (Vars.control.enemyGroup.getByID(id) != null){ + Enemy enemy = Vars.control.enemyGroup.getByID(id); + EnemySpawnPacket e = new EnemySpawnPacket(); + e.x = enemy.x; + e.y = enemy.y; + e.id = enemy.id; + e.tier = (byte)enemy.tier; + e.lane = (byte)enemy.lane; + e.type = enemy.type.id; + Net.sendTo(dest, e, SendMode.tcp); + Gdx.app.error("Mindustry", "Replying to entity request: enemy, " + id); + }else{ + Gdx.app.error("Mindustry", "Entity request target not found!"); + } + }); + }); } public void sendMessage(String message){ diff --git a/core/src/io/anuke/mindustry/core/Renderer.java b/core/src/io/anuke/mindustry/core/Renderer.java index 4ccde53414..5af5ae2a24 100644 --- a/core/src/io/anuke/mindustry/core/Renderer.java +++ b/core/src/io/anuke/mindustry/core/Renderer.java @@ -19,7 +19,7 @@ import io.anuke.mindustry.graphics.Shaders; import io.anuke.mindustry.input.InputHandler; import io.anuke.mindustry.input.PlaceMode; import io.anuke.mindustry.ui.fragments.ToolFragment; -import io.anuke.mindustry.world.SpawnPoint; +import io.anuke.mindustry.game.SpawnPoint; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.Blocks; import io.anuke.mindustry.world.blocks.ProductionBlocks; diff --git a/core/src/io/anuke/mindustry/core/World.java b/core/src/io/anuke/mindustry/core/World.java index 4171e11cd9..faeb81397c 100644 --- a/core/src/io/anuke/mindustry/core/World.java +++ b/core/src/io/anuke/mindustry/core/World.java @@ -1,5 +1,6 @@ package io.anuke.mindustry.core; +import com.badlogic.gdx.Gdx; import com.badlogic.gdx.math.GridPoint2; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Vector2; @@ -24,7 +25,8 @@ import io.anuke.ucore.modules.Module; import io.anuke.ucore.util.Mathf; import io.anuke.ucore.util.Tmp; -import static io.anuke.mindustry.Vars.*; +import static io.anuke.mindustry.Vars.control; +import static io.anuke.mindustry.Vars.tilesize; public class World extends Module{ private int seed; @@ -108,7 +110,7 @@ public class World extends Module{ public Tile tile(int x, int y){ if(tiles == null){ - ui.showError("$text.error.crashmessage"); + Gdx.app.postRunnable(() -> Vars.ui.showError("$text.error.crashmessage")); GameState.set(State.menu); return null; } diff --git a/core/src/io/anuke/mindustry/entities/Player.java b/core/src/io/anuke/mindustry/entities/Player.java index e22336d09d..79fde2af1e 100644 --- a/core/src/io/anuke/mindustry/entities/Player.java +++ b/core/src/io/anuke/mindustry/entities/Player.java @@ -125,10 +125,13 @@ public class Player extends DestructibleEntity implements Syncable{ float speed = dashing ? Player.dashSpeed : Player.speed; - if(health < maxhealth && Timers.get(this, "regen", 50)) + if(health < maxhealth && Timers.get(this, "regen", 20)) health ++; + health = Mathf.clamp(health, -1, maxhealth); + Tile tile = world.tileWorld(x, y); + if(tile != null && tile.floor().liquid && tile.block() == Blocks.air){ damage(health+1); //drown } diff --git a/core/src/io/anuke/mindustry/game/Difficulty.java b/core/src/io/anuke/mindustry/game/Difficulty.java new file mode 100644 index 0000000000..a0524e96aa --- /dev/null +++ b/core/src/io/anuke/mindustry/game/Difficulty.java @@ -0,0 +1,28 @@ +package io.anuke.mindustry.game; + +import io.anuke.ucore.util.Bundles; + +public enum Difficulty { + easy(4f, 2f), + normal(2f, 1f), + hard(1.5f, 0.5f), + insane(0.5f, 0.25f), + purge(0.4f, 0.01f); + + /**The scaling of how many waves it takes for one more enemy of a type to appear. + * For example: with enemeyScaling = 2 and the default scaling being 2, it would take 4 waves for + * an enemy spawn to go from 1->2 enemies.*/ + public final float enemyScaling; + /**Multiplier of the time between waves.*/ + public final float timeScaling; + + Difficulty(float enemyScaling, float timeScaling){ + this.enemyScaling = enemyScaling; + this.timeScaling = timeScaling; + } + + @Override + public String toString() { + return Bundles.get("setting.difficulty." + name()); + } +} diff --git a/core/src/io/anuke/mindustry/entities/EnemySpawn.java b/core/src/io/anuke/mindustry/game/EnemySpawn.java similarity index 83% rename from core/src/io/anuke/mindustry/entities/EnemySpawn.java rename to core/src/io/anuke/mindustry/game/EnemySpawn.java index 0057953727..8bd05ac66f 100644 --- a/core/src/io/anuke/mindustry/entities/EnemySpawn.java +++ b/core/src/io/anuke/mindustry/game/EnemySpawn.java @@ -1,13 +1,10 @@ -package io.anuke.mindustry.entities; +package io.anuke.mindustry.game; +import io.anuke.mindustry.Vars; import io.anuke.mindustry.entities.enemies.EnemyType; -import io.anuke.ucore.core.Settings; import io.anuke.ucore.util.Mathf; public class EnemySpawn{ - /**Scaling multiplier for each difficulty. Easy, normal, hard.*/ - private static float[] scalings = {4f, 2.5f, 1.5f}; - /**The enemy type spawned*/ public final EnemyType type; /**When this spawns should end*/ @@ -37,7 +34,7 @@ public class EnemySpawn{ if(wave < after || wave > before || (wave - after) % spacing != 0){ return 0; } - float scaling = this.scaling * scalings[(Settings.getInt("difficulty"))]; + float scaling = this.scaling * Vars.control.getDifficulty().enemyScaling; return Math.min(amount-1 + Math.max((int)((wave / spacing) / scaling), 1) - (tier(wave, lane)-1) * tierscaleback, max); } diff --git a/core/src/io/anuke/mindustry/world/GameMode.java b/core/src/io/anuke/mindustry/game/GameMode.java similarity index 91% rename from core/src/io/anuke/mindustry/world/GameMode.java rename to core/src/io/anuke/mindustry/game/GameMode.java index be8fc218a3..0df08f07f5 100644 --- a/core/src/io/anuke/mindustry/world/GameMode.java +++ b/core/src/io/anuke/mindustry/game/GameMode.java @@ -1,4 +1,4 @@ -package io.anuke.mindustry.world; +package io.anuke.mindustry.game; import io.anuke.ucore.util.Bundles; diff --git a/core/src/io/anuke/mindustry/world/SpawnPoint.java b/core/src/io/anuke/mindustry/game/SpawnPoint.java similarity index 82% rename from core/src/io/anuke/mindustry/world/SpawnPoint.java rename to core/src/io/anuke/mindustry/game/SpawnPoint.java index 9735946ecd..3c647cab63 100644 --- a/core/src/io/anuke/mindustry/world/SpawnPoint.java +++ b/core/src/io/anuke/mindustry/game/SpawnPoint.java @@ -1,9 +1,10 @@ -package io.anuke.mindustry.world; +package io.anuke.mindustry.game; import com.badlogic.gdx.ai.pfa.PathFinder; import com.badlogic.gdx.ai.pfa.PathFinderRequest; import io.anuke.mindustry.ai.SmoothGraphPath; +import io.anuke.mindustry.world.Tile; public class SpawnPoint{ public Tile start; diff --git a/core/src/io/anuke/mindustry/entities/WaveCreator.java b/core/src/io/anuke/mindustry/game/WaveCreator.java similarity index 98% rename from core/src/io/anuke/mindustry/entities/WaveCreator.java rename to core/src/io/anuke/mindustry/game/WaveCreator.java index 60e09425de..e0905ae041 100644 --- a/core/src/io/anuke/mindustry/entities/WaveCreator.java +++ b/core/src/io/anuke/mindustry/game/WaveCreator.java @@ -1,4 +1,4 @@ -package io.anuke.mindustry.entities; +package io.anuke.mindustry.game; import com.badlogic.gdx.utils.Array; import io.anuke.mindustry.entities.enemies.EnemyTypes; @@ -6,6 +6,7 @@ import io.anuke.mindustry.entities.enemies.EnemyTypes; public class WaveCreator{ public static Array getSpawns(){ + return Array.with( new EnemySpawn(EnemyTypes.standard){{ scaling = 1; diff --git a/core/src/io/anuke/mindustry/graphics/BlockRenderer.java b/core/src/io/anuke/mindustry/graphics/BlockRenderer.java index 1f97f09e3f..332ae2030b 100644 --- a/core/src/io/anuke/mindustry/graphics/BlockRenderer.java +++ b/core/src/io/anuke/mindustry/graphics/BlockRenderer.java @@ -14,10 +14,10 @@ import com.badlogic.gdx.utils.Array; import io.anuke.mindustry.Vars; import io.anuke.mindustry.core.GameState; import io.anuke.mindustry.core.GameState.State; +import io.anuke.mindustry.game.SpawnPoint; import io.anuke.mindustry.world.*; import io.anuke.mindustry.world.blocks.Blocks; import io.anuke.mindustry.world.blocks.types.StaticBlock; -import io.anuke.ucore.UCore; import io.anuke.ucore.core.Core; import io.anuke.ucore.core.Draw; import io.anuke.ucore.core.Graphics; diff --git a/core/src/io/anuke/mindustry/input/InputHandler.java b/core/src/io/anuke/mindustry/input/InputHandler.java index 12de513138..d5a8828864 100644 --- a/core/src/io/anuke/mindustry/input/InputHandler.java +++ b/core/src/io/anuke/mindustry/input/InputHandler.java @@ -13,7 +13,7 @@ import io.anuke.mindustry.resource.ItemStack; import io.anuke.mindustry.resource.Recipe; import io.anuke.mindustry.resource.Recipes; import io.anuke.mindustry.world.Block; -import io.anuke.mindustry.world.SpawnPoint; +import io.anuke.mindustry.game.SpawnPoint; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.Blocks; import io.anuke.mindustry.world.blocks.ProductionBlocks; @@ -109,9 +109,11 @@ public abstract class InputHandler extends InputAdapter{ } } - for(Player player : Vars.control.playerGroup.all()){ - if(!player.isAndroid && Tmp.r2.overlaps(player.hitbox.getRect(player.x, player.y))){ - return false; + if(type.solid || type.solidifes) { + for (Player player : Vars.control.playerGroup.all()) { + if (!player.isAndroid && Tmp.r2.overlaps(player.hitbox.getRect(player.x, player.y))) { + return false; + } } } diff --git a/core/src/io/anuke/mindustry/io/BundleGen.java b/core/src/io/anuke/mindustry/io/BundleGen.java index 95c33a6996..0fd3ec2d9c 100644 --- a/core/src/io/anuke/mindustry/io/BundleGen.java +++ b/core/src/io/anuke/mindustry/io/BundleGen.java @@ -9,7 +9,7 @@ import io.anuke.mindustry.core.Tutorial.Stage; import io.anuke.mindustry.resource.Item; import io.anuke.mindustry.resource.Liquid; import io.anuke.mindustry.world.Block; -import io.anuke.mindustry.world.GameMode; +import io.anuke.mindustry.game.GameMode; import io.anuke.mindustry.world.Map; import io.anuke.ucore.core.Inputs.DeviceType; import io.anuke.ucore.core.KeyBinds; diff --git a/core/src/io/anuke/mindustry/io/NetworkIO.java b/core/src/io/anuke/mindustry/io/NetworkIO.java index 143a0fa896..18f936c9ba 100644 --- a/core/src/io/anuke/mindustry/io/NetworkIO.java +++ b/core/src/io/anuke/mindustry/io/NetworkIO.java @@ -8,7 +8,7 @@ import io.anuke.mindustry.entities.enemies.Enemy; import io.anuke.mindustry.entities.enemies.EnemyType; import io.anuke.mindustry.resource.Weapon; import io.anuke.mindustry.world.Block; -import io.anuke.mindustry.world.GameMode; +import io.anuke.mindustry.game.GameMode; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.Blocks; import io.anuke.mindustry.world.blocks.types.BlockPart; diff --git a/core/src/io/anuke/mindustry/io/SaveMeta.java b/core/src/io/anuke/mindustry/io/SaveMeta.java index 1c2d03710c..cc797361b0 100644 --- a/core/src/io/anuke/mindustry/io/SaveMeta.java +++ b/core/src/io/anuke/mindustry/io/SaveMeta.java @@ -2,7 +2,7 @@ package io.anuke.mindustry.io; import io.anuke.mindustry.Mindustry; import io.anuke.mindustry.Vars; -import io.anuke.mindustry.world.GameMode; +import io.anuke.mindustry.game.GameMode; import io.anuke.mindustry.world.Map; import java.util.Date; diff --git a/core/src/io/anuke/mindustry/io/Saves.java b/core/src/io/anuke/mindustry/io/Saves.java index 2fc650e2d4..b3a26238ca 100644 --- a/core/src/io/anuke/mindustry/io/Saves.java +++ b/core/src/io/anuke/mindustry/io/Saves.java @@ -6,7 +6,7 @@ import com.badlogic.gdx.utils.async.AsyncExecutor; import io.anuke.mindustry.Vars; import io.anuke.mindustry.core.GameState; import io.anuke.mindustry.core.GameState.State; -import io.anuke.mindustry.world.GameMode; +import io.anuke.mindustry.game.GameMode; import io.anuke.mindustry.world.Map; import io.anuke.ucore.core.Settings; import io.anuke.ucore.core.Timers; diff --git a/core/src/io/anuke/mindustry/io/versions/Save12.java b/core/src/io/anuke/mindustry/io/versions/Save12.java index 73ff49cb84..b97d5d3f93 100644 --- a/core/src/io/anuke/mindustry/io/versions/Save12.java +++ b/core/src/io/anuke/mindustry/io/versions/Save12.java @@ -10,7 +10,7 @@ import io.anuke.mindustry.resource.Item; import io.anuke.mindustry.resource.Upgrade; import io.anuke.mindustry.resource.Weapon; import io.anuke.mindustry.world.BlockLoader; -import io.anuke.mindustry.world.GameMode; +import io.anuke.mindustry.game.GameMode; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.Blocks; import io.anuke.ucore.core.Core; diff --git a/core/src/io/anuke/mindustry/io/versions/Save13.java b/core/src/io/anuke/mindustry/io/versions/Save13.java index e42186efc3..595f9a7efa 100644 --- a/core/src/io/anuke/mindustry/io/versions/Save13.java +++ b/core/src/io/anuke/mindustry/io/versions/Save13.java @@ -5,6 +5,7 @@ import com.badlogic.gdx.utils.TimeUtils; import io.anuke.mindustry.Vars; import io.anuke.mindustry.entities.enemies.Enemy; import io.anuke.mindustry.entities.enemies.EnemyType; +import io.anuke.mindustry.game.GameMode; import io.anuke.mindustry.io.SaveFileVersion; import io.anuke.mindustry.resource.Item; import io.anuke.mindustry.resource.Upgrade; diff --git a/core/src/io/anuke/mindustry/io/versions/Save14.java b/core/src/io/anuke/mindustry/io/versions/Save14.java index 3db66332a0..f48dbe0f2e 100644 --- a/core/src/io/anuke/mindustry/io/versions/Save14.java +++ b/core/src/io/anuke/mindustry/io/versions/Save14.java @@ -11,7 +11,7 @@ import io.anuke.mindustry.resource.Item; import io.anuke.mindustry.resource.Upgrade; import io.anuke.mindustry.resource.Weapon; import io.anuke.mindustry.world.Block; -import io.anuke.mindustry.world.GameMode; +import io.anuke.mindustry.game.GameMode; import io.anuke.mindustry.world.Generator; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.Blocks; diff --git a/core/src/io/anuke/mindustry/net/Packets.java b/core/src/io/anuke/mindustry/net/Packets.java index cbfac07154..b9982f90f8 100644 --- a/core/src/io/anuke/mindustry/net/Packets.java +++ b/core/src/io/anuke/mindustry/net/Packets.java @@ -21,6 +21,7 @@ public class Packets { public static class EntityDataPacket{ public Player[] players; + public EnemySpawnPacket[] enemies; public byte[] playerWeapons; public int playerid; public byte[] weapons; @@ -135,4 +136,8 @@ public class Packets { public int position; public byte data; } + + public static class EntityRequestPacket{ + public int id; + } } diff --git a/core/src/io/anuke/mindustry/net/Registrator.java b/core/src/io/anuke/mindustry/net/Registrator.java index d1a280ee81..fe742acfc0 100644 --- a/core/src/io/anuke/mindustry/net/Registrator.java +++ b/core/src/io/anuke/mindustry/net/Registrator.java @@ -38,6 +38,7 @@ public class Registrator { WeaponSwitchPacket.class, BlockTapPacket.class, BlockConfigPacket.class, + EntityRequestPacket.class, Class.class, byte[].class, @@ -49,6 +50,7 @@ public class Registrator { Player[].class, Array.class, Vector2.class, + EnemySpawnPacket[].class, Entity.class, Player.class, diff --git a/core/src/io/anuke/mindustry/ui/dialogs/LevelDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/LevelDialog.java index c232052ca6..798fde68d1 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/LevelDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/LevelDialog.java @@ -3,7 +3,7 @@ package io.anuke.mindustry.ui.dialogs; import com.badlogic.gdx.graphics.g2d.TextureRegion; import io.anuke.mindustry.Vars; -import io.anuke.mindustry.world.GameMode; +import io.anuke.mindustry.game.GameMode; import io.anuke.mindustry.world.Map; import io.anuke.ucore.core.Core; import io.anuke.ucore.core.Settings; diff --git a/core/src/io/anuke/mindustry/ui/dialogs/PausedDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/PausedDialog.java index 23c35cff0e..411597960b 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/PausedDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/PausedDialog.java @@ -67,7 +67,7 @@ public class PausedDialog extends FloatingDialog{ content().addButton("$text.quit", () -> { ui.showConfirm("$text.confirm", "$text.quit.confirm", () -> { - if(Net.active() && Net.client()) Net.disconnect(); + if(Net.active() && Net.client()) Vars.netClient.disconnectQuietly(); runSave(); hide(); GameState.set(State.menu); @@ -110,7 +110,7 @@ public class PausedDialog extends FloatingDialog{ new imagebutton("icon-quit", isize, () -> { Vars.ui.showConfirm("$text.confirm", "$text.quit.confirm", () -> { - if(Net.active() && Net.client()) Net.disconnect(); + if(Net.active() && Net.client()) Vars.netClient.disconnectQuietly(); runSave(); hide(); GameState.set(State.menu); diff --git a/core/src/io/anuke/mindustry/ui/dialogs/SettingsMenuDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/SettingsMenuDialog.java index 373d539a6a..e6008ebefa 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/SettingsMenuDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/SettingsMenuDialog.java @@ -7,6 +7,7 @@ import com.badlogic.gdx.utils.Align; import io.anuke.mindustry.Vars; import io.anuke.mindustry.core.GameState; import io.anuke.mindustry.core.GameState.State; +import io.anuke.mindustry.game.Difficulty; import io.anuke.mindustry.net.Net; import io.anuke.ucore.core.Core; import io.anuke.ucore.core.Settings; @@ -106,7 +107,7 @@ public class SettingsMenuDialog extends SettingsDialog{ void addSettings(){ sound.volumePrefs(); - game.sliderPref("difficulty", 1, 0, 2, i -> Bundles.get("setting.difficulty." + (i == 0 ? "easy" : i == 1 ? "normal" : "hard"))); + game.sliderPref("difficulty", 1, 0, Difficulty.values().length-1, i -> Difficulty.values()[i].toString()); game.screenshakePref(); game.checkPref("smoothcam", true); game.checkPref("effects", true); diff --git a/core/src/io/anuke/mindustry/ui/fragments/ChatFragment.java b/core/src/io/anuke/mindustry/ui/fragments/ChatFragment.java index a2a7214fb8..d701d2d86a 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/ChatFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/ChatFragment.java @@ -28,7 +28,7 @@ public class ChatFragment extends Table implements Fragment{ private final static int messagesShown = 10; private final static int maxLength = 150; private Array messages = new Array<>(); - private float fadetime; + private float fadetime, lastfade; private boolean chatOpen = false; private TextField chatfield; private Label fieldlabel = new Label(">"); @@ -157,12 +157,13 @@ public class ChatFragment extends Table implements Fragment{ scene.setKeyboardFocus(chatfield); chatfield.fireClick(); chatOpen = !chatOpen; + lastfade = fadetime; fadetime = messagesShown + 1; }else if(chatOpen){ scene.setKeyboardFocus(null); chatOpen = !chatOpen; + fadetime = lastfade; sendMessage(); - fadetime = messagesShown + 1; } } @@ -180,7 +181,7 @@ public class ChatFragment extends Table implements Fragment{ messages.insert(0, new ChatMessage(message, sender)); fadetime += 1f; - fadetime = Math.min(fadetime, messagesShown) + 2f; + fadetime = Math.min(fadetime, messagesShown) + 1f; } private static class ChatMessage{ diff --git a/core/src/io/anuke/mindustry/world/blocks/ProductionBlocks.java b/core/src/io/anuke/mindustry/world/blocks/ProductionBlocks.java index 5f6ef9260e..2830a111a1 100644 --- a/core/src/io/anuke/mindustry/world/blocks/ProductionBlocks.java +++ b/core/src/io/anuke/mindustry/world/blocks/ProductionBlocks.java @@ -35,8 +35,8 @@ public class ProductionBlocks{ inputs = new Item[]{Item.titanium, Item.steel}; fuel = Item.coal; result = Item.dirium; - burnDuration = 80f; - craftTime = 40f; + burnDuration = 40f; + craftTime = 20f; } }, diff --git a/core/src/io/anuke/mindustry/world/blocks/types/BlockPart.java b/core/src/io/anuke/mindustry/world/blocks/types/BlockPart.java index bcba95904c..18ba5467c3 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/BlockPart.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/BlockPart.java @@ -23,7 +23,8 @@ public class BlockPart extends Block implements PowerAcceptor, LiquidAcceptor{ @Override public boolean isSolidFor(Tile tile){ return tile.getLinked() == null - || (tile.getLinked().solid() || tile.getLinked().block().isSolidFor(tile.getLinked())); + || (tile.getLinked().block() instanceof BlockPart || tile.getLinked().solid() + || tile.getLinked().block().isSolidFor(tile.getLinked())); } @Override diff --git a/core/src/io/anuke/mindustry/world/blocks/types/defense/ShieldBlock.java b/core/src/io/anuke/mindustry/world/blocks/types/defense/ShieldBlock.java index eaeef5f9f6..4fef525c4c 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/defense/ShieldBlock.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/defense/ShieldBlock.java @@ -17,14 +17,14 @@ import io.anuke.ucore.util.Strings; public class ShieldBlock extends PowerBlock{ public float shieldRadius = 40f; public float powerDrain = 0.005f; - public float powerPerDamage = 0.07f; + public float powerPerDamage = 0.06f; public float maxRadius = 40f; public float radiusScale = 300f; public ShieldBlock(String name) { super(name); voltage = powerDrain; - powerCapacity = 40f; + powerCapacity = 80f; } @Override diff --git a/core/src/io/anuke/mindustry/world/blocks/types/production/Smelter.java b/core/src/io/anuke/mindustry/world/blocks/types/production/Smelter.java index c807d75f50..718ff9a5ca 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/production/Smelter.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/production/Smelter.java @@ -25,8 +25,8 @@ public class Smelter extends Block{ protected Item fuel; protected Item result; - protected float craftTime = 30f; //time to craft one item, so max 2 items per second by default - protected float burnDuration = 60f; //by default, the fuel will burn 60 frames, so that's 2 items/fuel at most + protected float craftTime = 15f; //time to craft one item, so max 4 items per second by default + protected float burnDuration = 45f; //by default, the fuel will burn 45 frames, so that's 4 items/fuel at most protected Effect craftEffect = Fx.smelt, burnEffect = Fx.fuelburn; protected int capacity = 20;