diff --git a/core/src/io/anuke/mindustry/core/NetClient.java b/core/src/io/anuke/mindustry/core/NetClient.java index 3c7a24352c..dc3da1ad26 100644 --- a/core/src/io/anuke/mindustry/core/NetClient.java +++ b/core/src/io/anuke/mindustry/core/NetClient.java @@ -261,6 +261,11 @@ public class NetClient extends Module { player.weaponLeft = (Weapon)Upgrade.getByID(packet.left); player.weaponRight = (Weapon)Upgrade.getByID(packet.right); }); + + Net.handle(BlockTapPacket.class, packet -> { + Tile tile = Vars.world.tile(packet.position); + tile.block().tapped(tile); + }); } @Override @@ -274,6 +279,12 @@ public class NetClient extends Module { } } + public void handleBlockTap(Tile tile){ + BlockTapPacket packet = new BlockTapPacket(); + packet.position = tile.packedPosition(); + Net.send(packet, SendMode.tcp); + } + public void handleWeaponSwitch(){ WeaponSwitchPacket packet = new WeaponSwitchPacket(); packet.left = Vars.player.weaponLeft.id; diff --git a/core/src/io/anuke/mindustry/core/NetServer.java b/core/src/io/anuke/mindustry/core/NetServer.java index 51a86b890e..600926d989 100644 --- a/core/src/io/anuke/mindustry/core/NetServer.java +++ b/core/src/io/anuke/mindustry/core/NetServer.java @@ -174,6 +174,13 @@ public class NetServer extends Module{ Net.sendExcept(player.clientid, packet, SendMode.tcp); }); + + Net.handleServer(BlockTapPacket.class, packet -> { + Tile tile = Vars.world.tile(packet.position); + tile.block().tapped(tile); + + Net.sendExcept(Net.getLastConnection(), packet, SendMode.tcp); + }); } public void sendMessage(String message){ diff --git a/core/src/io/anuke/mindustry/core/World.java b/core/src/io/anuke/mindustry/core/World.java index bf67141db7..c50be11177 100644 --- a/core/src/io/anuke/mindustry/core/World.java +++ b/core/src/io/anuke/mindustry/core/World.java @@ -101,6 +101,10 @@ public class World extends Module{ public int height(){ return currentMap.getHeight(); } + + public Tile tile(int packed){ + return tile(packed % width(), packed / width()); + } public Tile tile(int x, int y){ if(tiles == null){ diff --git a/core/src/io/anuke/mindustry/entities/BulletType.java b/core/src/io/anuke/mindustry/entities/BulletType.java index 2d321330b8..7115ce8bef 100644 --- a/core/src/io/anuke/mindustry/entities/BulletType.java +++ b/core/src/io/anuke/mindustry/entities/BulletType.java @@ -124,7 +124,7 @@ public abstract class BulletType extends BaseBulletType{ DamageArea.damage(!(b.owner instanceof Enemy), b.x, b.y, 25f, (int)(damage * 2f/3f)); } }, - flak = new BulletType(3f, 8) { + flak = new BulletType(2.9f, 8) { public void init(Bullet b) { b.velocity.scl(Mathf.random(0.6f, 1f)); diff --git a/core/src/io/anuke/mindustry/input/AndroidInput.java b/core/src/io/anuke/mindustry/input/AndroidInput.java index 4d0f5a6dbd..bb164cdacf 100644 --- a/core/src/io/anuke/mindustry/input/AndroidInput.java +++ b/core/src/io/anuke/mindustry/input/AndroidInput.java @@ -6,6 +6,7 @@ import com.badlogic.gdx.math.Vector2; import io.anuke.mindustry.Vars; import io.anuke.mindustry.core.GameState; import io.anuke.mindustry.core.GameState.State; +import io.anuke.mindustry.net.Net; import io.anuke.mindustry.resource.ItemStack; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.types.Configurable; @@ -79,6 +80,11 @@ public class AndroidInput extends InputHandler{ }else if(!ui.configfrag.hasConfigMouse()){ ui.configfrag.hideConfig(); } + + if(linked != null) { + linked.block().tapped(linked); + if(Net.active()) netClient.handleBlockTap(linked); + } } } return false; diff --git a/core/src/io/anuke/mindustry/input/DesktopInput.java b/core/src/io/anuke/mindustry/input/DesktopInput.java index 3ac5f2c103..9929ca94a2 100644 --- a/core/src/io/anuke/mindustry/input/DesktopInput.java +++ b/core/src/io/anuke/mindustry/input/DesktopInput.java @@ -5,6 +5,7 @@ import com.badlogic.gdx.math.Vector2; import io.anuke.mindustry.Vars; import io.anuke.mindustry.core.GameState; import io.anuke.mindustry.core.GameState.State; +import io.anuke.mindustry.net.Net; import io.anuke.mindustry.resource.Weapon; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.types.Configurable; @@ -96,6 +97,11 @@ public class DesktopInput extends InputHandler{ }else if(!ui.configfrag.hasConfigMouse()){ ui.configfrag.hideConfig(); } + + if(linked != null) { + linked.block().tapped(linked); + if(Net.active()) netClient.handleBlockTap(linked); + } } if(Inputs.keyTap("break")){ diff --git a/core/src/io/anuke/mindustry/net/Packets.java b/core/src/io/anuke/mindustry/net/Packets.java index 683ae483d6..08093fa60a 100644 --- a/core/src/io/anuke/mindustry/net/Packets.java +++ b/core/src/io/anuke/mindustry/net/Packets.java @@ -123,4 +123,8 @@ public class Packets { public int playerid; public byte left, right; } + + public static class BlockTapPacket{ + public int position; + } } diff --git a/core/src/io/anuke/mindustry/net/Registrator.java b/core/src/io/anuke/mindustry/net/Registrator.java index baedb47bfe..1d100d2aa0 100644 --- a/core/src/io/anuke/mindustry/net/Registrator.java +++ b/core/src/io/anuke/mindustry/net/Registrator.java @@ -36,6 +36,7 @@ public class Registrator { KickPacket.class, UpgradePacket.class, WeaponSwitchPacket.class, + BlockTapPacket.class, Class.class, byte[].class, diff --git a/core/src/io/anuke/mindustry/resource/Recipes.java b/core/src/io/anuke/mindustry/resource/Recipes.java index c6542dfe97..e29d5e533e 100644 --- a/core/src/io/anuke/mindustry/resource/Recipes.java +++ b/core/src/io/anuke/mindustry/resource/Recipes.java @@ -49,7 +49,7 @@ public class Recipes { new Recipe(weapon, WeaponBlocks.titanturret, stack(Item.steel, 70), stack(Item.titanium, 50), stack(Item.dirium, 55)), new Recipe(crafting, ProductionBlocks.smelter, stack(Item.stone, 40), stack(Item.iron, 40)), - new Recipe(crafting, ProductionBlocks.crucible, stack(Item.titanium, 40), stack(Item.steel, 40)), + new Recipe(crafting, ProductionBlocks.crucible, stack(Item.titanium, 50), stack(Item.steel, 50)), new Recipe(crafting, ProductionBlocks.coalpurifier, stack(Item.steel, 10), stack(Item.iron, 10)), new Recipe(crafting, ProductionBlocks.titaniumpurifier, stack(Item.steel, 30), stack(Item.iron, 30)), new Recipe(crafting, ProductionBlocks.oilrefinery, stack(Item.steel, 15), stack(Item.iron, 15)), @@ -60,9 +60,9 @@ public class Recipes { new Recipe(production, ProductionBlocks.stonedrill, stack(Item.stone, 12)), new Recipe(production, ProductionBlocks.irondrill, stack(Item.stone, 25)), new Recipe(production, ProductionBlocks.coaldrill, stack(Item.stone, 25), stack(Item.iron, 40)), - new Recipe(production, ProductionBlocks.titaniumdrill, stack(Item.iron, 40), stack(Item.steel, 50)), + new Recipe(production, ProductionBlocks.titaniumdrill, stack(Item.iron, 50), stack(Item.steel, 50)), new Recipe(production, ProductionBlocks.uraniumdrill, stack(Item.iron, 40), stack(Item.steel, 40)), - new Recipe(production, ProductionBlocks.omnidrill, stack(Item.titanium, 30), stack(Item.dirium, 40)), + new Recipe(production, ProductionBlocks.omnidrill, stack(Item.titanium, 40), stack(Item.dirium, 40)), new Recipe(power, ProductionBlocks.coalgenerator, stack(Item.iron, 30), stack(Item.stone, 20)), new Recipe(power, ProductionBlocks.thermalgenerator, stack(Item.steel, 30), stack(Item.iron, 30)), diff --git a/core/src/io/anuke/mindustry/world/Block.java b/core/src/io/anuke/mindustry/world/Block.java index f52300c119..28c03a6498 100644 --- a/core/src/io/anuke/mindustry/world/Block.java +++ b/core/src/io/anuke/mindustry/world/Block.java @@ -106,6 +106,7 @@ public class Block{ public void drawPlace(int x, int y, int rotation, boolean valid){} public void postInit(){} public void placed(Tile tile){} + public void tapped(Tile tile){} public void getStats(Array list){ list.add("[gray]size: " + width + "x" + height); diff --git a/core/src/io/anuke/mindustry/world/blocks/ProductionBlocks.java b/core/src/io/anuke/mindustry/world/blocks/ProductionBlocks.java index be0158cc4f..5f6ef9260e 100644 --- a/core/src/io/anuke/mindustry/world/blocks/ProductionBlocks.java +++ b/core/src/io/anuke/mindustry/world/blocks/ProductionBlocks.java @@ -203,6 +203,7 @@ public class ProductionBlocks{ weaponFactory = new WeaponFactory("weaponfactory"){ { width = height = 2; + health = 250; } }; } diff --git a/core/src/io/anuke/mindustry/world/blocks/WeaponBlocks.java b/core/src/io/anuke/mindustry/world/blocks/WeaponBlocks.java index b3b2d9263e..69d491b2ae 100644 --- a/core/src/io/anuke/mindustry/world/blocks/WeaponBlocks.java +++ b/core/src/io/anuke/mindustry/world/blocks/WeaponBlocks.java @@ -102,10 +102,10 @@ public class WeaponBlocks{ shootsound = "bigshot"; rotatespeed = 0.2f; range = 120; - reload = 65f; + reload = 70f; bullet = BulletType.flak; shots = 3; - inaccuracy = 8f; + inaccuracy = 9f; ammo = Item.coal; ammoMultiplier = 5; health = 110; diff --git a/core/src/io/anuke/mindustry/world/blocks/types/defense/Door.java b/core/src/io/anuke/mindustry/world/blocks/types/defense/Door.java index 65c49d3568..434114b28c 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/defense/Door.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/defense/Door.java @@ -1,30 +1,28 @@ package io.anuke.mindustry.world.blocks.types.defense; -import static io.anuke.mindustry.Vars.*; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Vector2; - import io.anuke.mindustry.Vars; import io.anuke.mindustry.entities.TileEntity; import io.anuke.mindustry.graphics.Fx; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; -import io.anuke.mindustry.world.blocks.types.Configurable; import io.anuke.mindustry.world.blocks.types.Wall; import io.anuke.ucore.core.Draw; import io.anuke.ucore.core.Effects; import io.anuke.ucore.core.Effects.Effect; import io.anuke.ucore.entities.Entities; import io.anuke.ucore.entities.SolidEntity; -import io.anuke.ucore.scene.ui.layout.Table; import io.anuke.ucore.util.Tmp; -public class Door extends Wall implements Configurable{ +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +import static io.anuke.mindustry.Vars.player; +import static io.anuke.mindustry.Vars.tilesize; + +public class Door extends Wall{ protected Effect openfx = Fx.dooropen; protected Effect closefx = Fx.doorclose; @@ -54,7 +52,7 @@ public class Door extends Wall implements Configurable{ } @Override - public void buildTable(Tile tile, Table table){ + public void tapped(Tile tile){ DoorEntity entity = tile.entity(); if(anyEntities(tile) && entity.open){