mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-25 05:51:47 -08:00
Re-added tap event for servers
This commit is contained in:
parent
059c729a2c
commit
d07c74b60f
5 changed files with 30 additions and 2 deletions
|
|
@ -108,7 +108,6 @@ importPackage(Packages.mindustry.world.draw)
|
|||
importPackage(Packages.mindustry.world.meta)
|
||||
importPackage(Packages.mindustry.world.meta.values)
|
||||
importPackage(Packages.mindustry.world.modules)
|
||||
importPackage(Packages.mindustry.world.producers)
|
||||
const PlayerIpUnbanEvent = Packages.mindustry.game.EventType.PlayerIpUnbanEvent
|
||||
const PlayerIpBanEvent = Packages.mindustry.game.EventType.PlayerIpBanEvent
|
||||
const PlayerUnbanEvent = Packages.mindustry.game.EventType.PlayerUnbanEvent
|
||||
|
|
@ -118,6 +117,7 @@ const PlayerConnect = Packages.mindustry.game.EventType.PlayerConnect
|
|||
const PlayerJoin = Packages.mindustry.game.EventType.PlayerJoin
|
||||
const UnitChangeEvent = Packages.mindustry.game.EventType.UnitChangeEvent
|
||||
const UnitCreateEvent = Packages.mindustry.game.EventType.UnitCreateEvent
|
||||
const UnitDrownEvent = Packages.mindustry.game.EventType.UnitDrownEvent
|
||||
const UnitDestroyEvent = Packages.mindustry.game.EventType.UnitDestroyEvent
|
||||
const BlockDestroyEvent = Packages.mindustry.game.EventType.BlockDestroyEvent
|
||||
const BuildSelectEvent = Packages.mindustry.game.EventType.BuildSelectEvent
|
||||
|
|
@ -128,6 +128,7 @@ const UnlockEvent = Packages.mindustry.game.EventType.UnlockEvent
|
|||
const StateChangeEvent = Packages.mindustry.game.EventType.StateChangeEvent
|
||||
const TileChangeEvent = Packages.mindustry.game.EventType.TileChangeEvent
|
||||
const GameOverEvent = Packages.mindustry.game.EventType.GameOverEvent
|
||||
const TapEvent = Packages.mindustry.game.EventType.TapEvent
|
||||
const ConfigEvent = Packages.mindustry.game.EventType.ConfigEvent
|
||||
const DepositEvent = Packages.mindustry.game.EventType.DepositEvent
|
||||
const WithdrawEvent = Packages.mindustry.game.EventType.WithdrawEvent
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ public class EventType{
|
|||
}
|
||||
}
|
||||
|
||||
/** Called when the configures sets a specific block. */
|
||||
/** Called when the player configures a specific building. */
|
||||
public static class ConfigEvent{
|
||||
public final Building tile;
|
||||
public final Player player;
|
||||
|
|
@ -161,6 +161,17 @@ public class EventType{
|
|||
}
|
||||
}
|
||||
|
||||
/** Called when a player taps any tile. */
|
||||
public static class TapEvent{
|
||||
public final Player player;
|
||||
public final Tile tile;
|
||||
|
||||
public TapEvent(Player player, Tile tile){
|
||||
this.tile = tile;
|
||||
this.player = player;
|
||||
}
|
||||
}
|
||||
|
||||
public static class GameOverEvent{
|
||||
public final Team winner;
|
||||
|
||||
|
|
|
|||
|
|
@ -459,6 +459,10 @@ public class DesktopInput extends InputHandler{
|
|||
}
|
||||
|
||||
if(Core.input.keyTap(Binding.select) && !Core.scene.hasMouse()){
|
||||
if(selected != null){
|
||||
Call.tileTap(player, selected);
|
||||
}
|
||||
|
||||
BuildPlan req = getRequest(cursorX, cursorY);
|
||||
|
||||
if(Core.input.keyDown(Binding.break_block)){
|
||||
|
|
|
|||
|
|
@ -274,6 +274,15 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||
Core.app.post(() -> Events.fire(new ConfigEvent(tile, player, value)));
|
||||
}
|
||||
|
||||
//only useful for servers or local mods, and is not replicated across clients
|
||||
//uses unreliable packets due to high frequency
|
||||
@Remote(targets = Loc.both, called = Loc.both, unreliable = true)
|
||||
public static void tileTap(@Nullable Player player, Tile tile){
|
||||
if(tile == null) return;
|
||||
|
||||
Events.fire(new TapEvent(player, tile));
|
||||
}
|
||||
|
||||
@Remote(targets = Loc.both, called = Loc.both, forward = true)
|
||||
public static void unitControl(Player player, @Nullable Unit unit){
|
||||
if(player == null) return;
|
||||
|
|
|
|||
|
|
@ -558,6 +558,9 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||
|
||||
//ignore off-screen taps
|
||||
if(cursor == null || Core.scene.hasMouse(x, y)) return false;
|
||||
|
||||
Call.tileTap(player, cursor);
|
||||
|
||||
Tile linked = cursor.build == null ? cursor : cursor.build.tile;
|
||||
|
||||
if(!player.dead()){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue