Fixed #3078 + action listeners for player control events
This commit is contained in:
@@ -279,7 +279,7 @@ public class DesktopInput extends InputHandler{
|
||||
|
||||
if(isPlacing() && mode == placing){
|
||||
updateLine(selectX, selectY);
|
||||
}else if(!selectRequests.isEmpty()){
|
||||
}else if(!selectRequests.isEmpty() && !ui.chatfrag.shown()){
|
||||
rotateRequests(selectRequests, Mathf.sign(Core.input.axisTap(Binding.rotate)));
|
||||
}
|
||||
}
|
||||
@@ -660,7 +660,7 @@ public class DesktopInput extends InputHandler{
|
||||
}
|
||||
|
||||
//update commander unit
|
||||
if(Core.input.keyTap(Binding.command)){
|
||||
if(Core.input.keyTap(Binding.command) && unit.type.commandLimit > 0){
|
||||
Call.unitCommand(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -336,6 +336,11 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
public static void unitControl(Player player, @Nullable Unit unit){
|
||||
if(player == null) return;
|
||||
|
||||
//make sure player is allowed to control the unit
|
||||
if(net.server() && !netServer.admins.allowAction(player, ActionType.control, action -> action.unit = unit)){
|
||||
throw new ValidateException(player, "Player cannot control a unit.");
|
||||
}
|
||||
|
||||
//clear player unit when they possess a core
|
||||
if((unit instanceof BlockUnitc && ((BlockUnitc)unit).tile() instanceof CoreBuild)){
|
||||
Fx.spawn.at(player);
|
||||
@@ -376,6 +381,11 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
public static void unitCommand(Player player){
|
||||
if(player == null || player.dead() || !(player.unit() instanceof Commanderc commander)) return;
|
||||
|
||||
//make sure player is allowed to make the command
|
||||
if(net.server() && !netServer.admins.allowAction(player, ActionType.command, action -> {})){
|
||||
throw new ValidateException(player, "Player cannot command a unit.");
|
||||
}
|
||||
|
||||
if(commander.isCommanding()){
|
||||
commander.clearCommand();
|
||||
}else if(player.unit().type.commandLimit > 0){
|
||||
|
||||
@@ -613,7 +613,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
//reset payload target
|
||||
payloadTarget = null;
|
||||
//apply command on double tap when own unit is tapped
|
||||
if(Mathf.within(worldx, worldy, player.unit().x, player.unit().y, player.unit().hitSize * 0.6f + 8f)){
|
||||
if(!player.dead() && Mathf.within(worldx, worldy, player.unit().x, player.unit().y, player.unit().hitSize * 0.6f + 8f) && player.unit().type.commandLimit > 0){
|
||||
Call.unitCommand(player);
|
||||
}else{
|
||||
//control a unit/block
|
||||
|
||||
Reference in New Issue
Block a user