diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 4a5672e505..73e2938c5c 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -293,6 +293,7 @@ item.steel.name=steel item.titanium.name=titanium item.dirium.name=dirium item.uranium.name=uranium +item.sand.name=sand liquid.water.name=water liquid.plasma.name=plasma liquid.lava.name=lava diff --git a/core/src/io/anuke/mindustry/core/Control.java b/core/src/io/anuke/mindustry/core/Control.java index ffedca49e5..9cc1fa23b7 100644 --- a/core/src/io/anuke/mindustry/core/Control.java +++ b/core/src/io/anuke/mindustry/core/Control.java @@ -356,7 +356,7 @@ public class Control extends Module{ for(int i = 0; i < spawnamount; i ++){ float range = 12f; - Timers.run(i*5f, ()->{ + Timers.run(i*5f, () -> { Enemy enemy = new Enemy(spawn.type); enemy.set(tile.worldx() + Mathf.range(range), tile.worldy() + Mathf.range(range)); diff --git a/core/src/io/anuke/mindustry/core/NetClient.java b/core/src/io/anuke/mindustry/core/NetClient.java index 81c074cf06..6d00c15242 100644 --- a/core/src/io/anuke/mindustry/core/NetClient.java +++ b/core/src/io/anuke/mindustry/core/NetClient.java @@ -2,7 +2,6 @@ package io.anuke.mindustry.core; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.utils.TimeUtils; -import com.badlogic.gdx.utils.compression.Lzma; import io.anuke.mindustry.Vars; import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.entities.Bullet; @@ -28,8 +27,6 @@ import io.anuke.ucore.entities.BaseBulletType; import io.anuke.ucore.entities.Entity; import io.anuke.ucore.modules.Module; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.IOException; import java.util.Arrays; @@ -82,16 +79,8 @@ public class NetClient extends Module { Net.handle(WorldData.class, data -> { Gdx.app.postRunnable(() -> { - ByteArrayOutputStream outc = new ByteArrayOutputStream(); - - try { - Lzma.decompress(data.stream, outc); - }catch (IOException e){ - throw new RuntimeException(e); - } - UCore.log("Recieved world data: " + data.stream.available() + " bytes."); - NetworkIO.load(new ByteArrayInputStream(outc.toByteArray())); + NetworkIO.load(data.stream); Vars.player.set(Vars.control.core.worldx(), Vars.control.core.worldy() - Vars.tilesize*2); GameState.set(State.playing); diff --git a/core/src/io/anuke/mindustry/core/NetServer.java b/core/src/io/anuke/mindustry/core/NetServer.java index 29388da57e..a70814bf01 100644 --- a/core/src/io/anuke/mindustry/core/NetServer.java +++ b/core/src/io/anuke/mindustry/core/NetServer.java @@ -4,7 +4,6 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.utils.IntArray; import com.badlogic.gdx.utils.IntMap; import com.badlogic.gdx.utils.TimeUtils; -import com.badlogic.gdx.utils.compression.Lzma; import io.anuke.mindustry.Vars; import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.entities.BulletType; @@ -50,19 +49,7 @@ public class NetServer extends Module{ NetworkIO.write(stream); UCore.log("Packed " + stream.size() + " uncompressed bytes of data."); - - ByteArrayInputStream inc = new ByteArrayInputStream(stream.toByteArray()); - ByteArrayOutputStream outc = new ByteArrayOutputStream(); - - try { - Lzma.compress(inc, outc); - }catch (IOException e){ - throw new RuntimeException(e); - } - - UCore.log("Packed " + outc.size() + " COMPRESSED bytes of data."); - - data.stream = new ByteArrayInputStream(outc.toByteArray()); + data.stream = new ByteArrayInputStream(stream.toByteArray()); Net.sendStream(id, data); diff --git a/core/src/io/anuke/mindustry/entities/BulletType.java b/core/src/io/anuke/mindustry/entities/BulletType.java index 7115ce8bef..fae051e255 100644 --- a/core/src/io/anuke/mindustry/entities/BulletType.java +++ b/core/src/io/anuke/mindustry/entities/BulletType.java @@ -448,7 +448,7 @@ public abstract class BulletType extends BaseBulletType{ } public void init(Bullet b) { - DamageArea.damageLine(true, Fx.beamhit, b.x, b.y, b.angle(), length, damage); + DamageArea.damageLine(b.owner, Fx.beamhit, b.x, b.y, b.angle(), length, damage); } public void draw(Bullet b) { diff --git a/core/src/io/anuke/mindustry/entities/Player.java b/core/src/io/anuke/mindustry/entities/Player.java index fb2ad42cb7..7662e5f59a 100644 --- a/core/src/io/anuke/mindustry/entities/Player.java +++ b/core/src/io/anuke/mindustry/entities/Player.java @@ -50,7 +50,7 @@ public class Player extends DestructibleEntity implements Syncable{ @Override public void damage(int amount){ - if(!Vars.debug) + if(!Vars.debug && !isAndroid) super.damage(amount); } diff --git a/core/src/io/anuke/mindustry/entities/effect/DamageArea.java b/core/src/io/anuke/mindustry/entities/effect/DamageArea.java index 7e7a070e7b..2bdca1de21 100644 --- a/core/src/io/anuke/mindustry/entities/effect/DamageArea.java +++ b/core/src/io/anuke/mindustry/entities/effect/DamageArea.java @@ -8,14 +8,20 @@ import io.anuke.mindustry.entities.enemies.Enemy; import io.anuke.mindustry.world.Tile; import io.anuke.ucore.core.Effects; import io.anuke.ucore.core.Effects.Effect; +import io.anuke.ucore.entities.DestructibleEntity; import io.anuke.ucore.entities.Entities; -import io.anuke.ucore.util.*; +import io.anuke.ucore.entities.Entity; +import io.anuke.ucore.entities.SolidEntity; +import io.anuke.ucore.function.Consumer; +import io.anuke.ucore.util.Angles; +import io.anuke.ucore.util.Mathf; +import io.anuke.ucore.util.Physics; public class DamageArea{ private static Rectangle rect = new Rectangle(); //only for entities, not tiles (yet!) - public static void damageLine(boolean enemies, Effect effect, float x, float y, float angle, float length, int damage){ + public static void damageLine(Entity owner, Effect effect, float x, float y, float angle, float length, int damage){ Angles.translation(angle, length); rect.setPosition(x, y).setSize(Angles.x(), Angles.y()); float x2 = Angles.x() + x, y2 = Angles.y() + y; @@ -37,23 +43,25 @@ public class DamageArea{ rect.width += expand*2; rect.height += expand*2; - if(enemies){ - Entities.getNearby(Vars.control.enemyGroup, rect, e -> { - Enemy enemy = (Enemy)e; - Rectangle other = enemy.hitbox.getRect(enemy.x, enemy.y); - other.y -= expand; - other.x -= expand; - other.width += expand*2; - other.height += expand*2; + Consumer cons = e -> { + if(e == owner || (e instanceof Player && ((Player)e).isAndroid)) return; + DestructibleEntity enemy = (DestructibleEntity) e; + Rectangle other = enemy.hitbox.getRect(enemy.x, enemy.y); + other.y -= expand; + other.x -= expand; + other.width += expand * 2; + other.height += expand * 2; - Vector2 vec = Physics.raycastRect(x, y, x2, y2, other); + Vector2 vec = Physics.raycastRect(x, y, x2, y2, other); - if(vec != null){ - Effects.effect(effect, vec.x, vec.y); - enemy.damage(damage); - } - }); - }//TODO else damage players and blocks? + if (vec != null) { + Effects.effect(effect, vec.x, vec.y); + enemy.damage(damage); + } + }; + + Entities.getNearby(Vars.control.enemyGroup, rect, cons); + Entities.getNearby(Vars.control.playerGroup, rect, cons); } public static void damageEntities(float x, float y, float radius, int damage){ diff --git a/core/src/io/anuke/mindustry/ui/dialogs/HostDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/HostDialog.java index 38f07ba697..2cd93fc14e 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/HostDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/HostDialog.java @@ -4,18 +4,19 @@ import io.anuke.mindustry.Vars; import io.anuke.mindustry.net.Net; import io.anuke.ucore.core.Settings; import io.anuke.ucore.core.Timers; -import io.anuke.ucore.scene.ui.Dialog; import io.anuke.ucore.util.Bundles; import io.anuke.ucore.util.Strings; import java.io.IOException; //TODO add port specification -public class HostDialog extends Dialog{ +public class HostDialog extends FloatingDialog{ float w = 300; public HostDialog(){ - super("$text.hostserver", "dialog"); + super("$text.hostserver"); + + addCloseButton(); content().table(t -> { t.add("$text.name").padRight(10); diff --git a/core/src/io/anuke/mindustry/ui/fragments/BlocksFragment.java b/core/src/io/anuke/mindustry/ui/fragments/BlocksFragment.java index 24fd7598cd..5d836ee8b3 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/BlocksFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/BlocksFragment.java @@ -44,7 +44,7 @@ public class BlocksFragment implements Fragment{ blocks = new table(){{ itemtable = new Table("button"); - itemtable.setVisible(() -> input.recipe == null); + itemtable.setVisible(() -> input.recipe == null && !Vars.control.getMode().infiniteResources); desctable = new Table("button"); desctable.setVisible(() -> input.recipe != null); diff --git a/core/src/io/anuke/mindustry/ui/fragments/ChatFragment.java b/core/src/io/anuke/mindustry/ui/fragments/ChatFragment.java index fd60b08f8f..f1b7b1937f 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/ChatFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/ChatFragment.java @@ -79,8 +79,9 @@ public class ChatFragment extends Table implements Fragment{ bottom().left().marginBottom(offsety).marginLeft(offsetx*2).add(fieldlabel).padBottom(4f); add(chatfield).padBottom(offsety).padLeft(offsetx).growX().padRight(offsetx).height(28); + if(Vars.android) { - addImageButton("icon-chat", 14 * 2, this::toggle).size(30f).visible(() -> chatOpen); + addImageButton("icon-arrow-right", 14 * 2, this::toggle).size(50f, 55f).visible(() -> chatOpen); } } diff --git a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java index 0bda06012b..20c28537f0 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/HudFragment.java @@ -22,7 +22,7 @@ import io.anuke.ucore.util.Bundles; import static io.anuke.mindustry.Vars.*; public class HudFragment implements Fragment{ - private ImageButton menu, flip, pause; + private ImageButton menu, flip; private Table respawntable; private Table wavetable; private boolean shown = true; @@ -43,7 +43,7 @@ public class HudFragment implements Fragment{ menu = new imagebutton("icon-menu", isize, ui.paused::show).get(); - flip = new imagebutton("icon-arrow-up", isize, ()->{ + flip = new imagebutton("icon-arrow-up", isize, () -> { if(wavetable.getActions().size != 0) return; float dur = 0.3f; @@ -62,7 +62,7 @@ public class HudFragment implements Fragment{ }).get(); - pause = new imagebutton("icon-pause", isize, ()->{ + new imagebutton("icon-pause", isize, () -> { if(Net.active() && Vars.android){ if(ui.chatfrag.chatOpen()){ ui.chatfrag.hide(); @@ -72,7 +72,7 @@ public class HudFragment implements Fragment{ }else { GameState.set(GameState.is(State.paused) ? State.playing : State.paused); } - }).update(i ->{ + }).update(i -> { if(Net.active() && Vars.android){ i.getStyle().imageUp = Core.skin.getDrawable("icon-chat"); }else { @@ -194,7 +194,7 @@ public class HudFragment implements Fragment{ getEnemiesRemaining() : (control.getTutorial().active() || Vars.control.getMode().toggleWaves) ? "$text.waiting" : Bundles.format("text.wave.waiting", (int) (control.getWaveCountdown() / 60f))) - .minWidth(140).padLeft(-6).padRight(-12).left(); + .minWidth(126).padLeft(-6).padRight(-12).left(); margin(10f); get().marginLeft(6); @@ -208,8 +208,7 @@ public class HudFragment implements Fragment{ private void playButton(float uheight){ new imagebutton("icon-play", 30f, ()->{ Vars.control.runWave(); - }).height(uheight).fillX().right().padTop(-8f).padBottom(-12f).padRight(-36) - .padLeft(-10f).width(40f).update(l->{ + }).height(uheight).fillX().right().padTop(-8f).padBottom(-12f).padRight(-36).width(40f).update(l->{ boolean vis = Vars.control.getMode().toggleWaves && Vars.control.getEnemiesRemaining() <= 0; boolean paused = GameState.is(State.paused) || !vis; diff --git a/core/src/io/anuke/mindustry/world/blocks/types/distribution/TunnelConveyor.java b/core/src/io/anuke/mindustry/world/blocks/types/distribution/TunnelConveyor.java index 15961d2937..e0c10d26c6 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/distribution/TunnelConveyor.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/distribution/TunnelConveyor.java @@ -24,7 +24,7 @@ public class TunnelConveyor extends Block{ @Override public void handleItem(Item item, Tile tile, Tile source){ Tile tunnel = getDestTunnel(tile, item); - if(tunnel == null) return; //TODO how is this possible? HOW DID THEY ACHIEVE SUCH A FEAT?! + if(tunnel == null) return; Tile to = tunnel.getNearby()[tunnel.getRotation()]; Timers.run(25, ()->{ diff --git a/core/src/io/anuke/mindustry/world/blocks/types/production/WeaponFactory.java b/core/src/io/anuke/mindustry/world/blocks/types/production/WeaponFactory.java index ac4c32c9d2..f91d929820 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/production/WeaponFactory.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/production/WeaponFactory.java @@ -99,7 +99,7 @@ public class WeaponFactory extends Block{ } }).size(49f, 54f).padBottom(-5).get(); - button.setDisabled(() -> control.hasWeapon(weapon)); + button.setDisabled(() -> control.hasWeapon(weapon) || !control.hasItems(requirements)); button.getStyle().imageUp = new TextureRegionDrawable(Draw.region(weapon.name)); button.addListener(tip); diff --git a/kryonet/src/io/anuke/kryonet/KryoClient.java b/kryonet/src/io/anuke/kryonet/KryoClient.java index 71267eaf3b..8209ef8b6f 100644 --- a/kryonet/src/io/anuke/kryonet/KryoClient.java +++ b/kryonet/src/io/anuke/kryonet/KryoClient.java @@ -118,7 +118,7 @@ public class KryoClient implements ClientProvider{ @Override public Array
discover(){ - List list = client.discoverHosts(Vars.port, 5000); + List list = client.discoverHosts(Vars.port, 3000); ObjectSet hostnames = new ObjectSet<>(); Array
result = new Array<>(); diff --git a/kryonet/src/io/anuke/kryonet/KryoServer.java b/kryonet/src/io/anuke/kryonet/KryoServer.java index 14166f0e6b..49143b840e 100644 --- a/kryonet/src/io/anuke/kryonet/KryoServer.java +++ b/kryonet/src/io/anuke/kryonet/KryoServer.java @@ -29,7 +29,7 @@ public class KryoServer implements ServerProvider { IntArray connections = new IntArray(); public KryoServer(){ - server = new Server(); + server = new Server(4096, 1024); //TODO tweak server.setDiscoveryHandler(new ServerDiscoveryHandler() { private ByteBuffer buffer = ByteBuffer.allocate(4);