Add TapEvent/TapConfigEvent (#1018)

* Update EventType.java

* Update InputHandler.java
This commit is contained in:
키에르
2019-11-09 04:58:24 +09:00
committed by Anuken
parent 505f802e20
commit 796241b40a
2 changed files with 26 additions and 0 deletions

View File

@ -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;

View File

@ -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<BuildRequest> allRequests(){