diff --git a/core/src/io/anuke/mindustry/game/EventType.java b/core/src/io/anuke/mindustry/game/EventType.java index fef2556d35..43f5010e30 100644 --- a/core/src/io/anuke/mindustry/game/EventType.java +++ b/core/src/io/anuke/mindustry/game/EventType.java @@ -141,6 +141,30 @@ public class EventType{ this.player = player; } } + + /** Called when the player taps a block. */ + public static class TapEvent{ + public final Tile tile; + public final Player player; + + public TapEvent(Tile tile, Player player){ + this.tile = tile; + this.player = player; + } + } + + /** Called when the player sets a specific block. */ + public static class TapConfigEvent{ + public final Tile tile; + public final Player player; + public final int value; + + public TapConfigEvent(Tile tile, Player player, int value){ + this.tile = tile; + this.player = player; + this.value = value; + } + } public static class GameOverEvent{ public final Team winner; diff --git a/core/src/io/anuke/mindustry/input/InputHandler.java b/core/src/io/anuke/mindustry/input/InputHandler.java index 2ab0fde1b4..d5aea01231 100644 --- a/core/src/io/anuke/mindustry/input/InputHandler.java +++ b/core/src/io/anuke/mindustry/input/InputHandler.java @@ -145,12 +145,14 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ if(tile == null || player == null) return; if(!Units.canInteract(player, tile)) return; tile.block().tapped(tile, player); + Core.app.post(() -> Events.fire(new TapEvent(tile, player))); } @Remote(targets = Loc.both, called = Loc.both, forward = true) public static void onTileConfig(Player player, Tile tile, int value){ if(tile == null || !Units.canInteract(player, tile)) return; tile.block().configured(tile, player, value); + Core.app.post(() -> Events.fire(new TapConfigEvent(tile, player, value))); } public Eachable allRequests(){