Added unit stances

This commit is contained in:
Anuken 2023-09-20 21:55:06 -04:00
parent 0d1c56fb60
commit 3e15f70efa
11 changed files with 206 additions and 30 deletions

View file

@ -312,6 +312,29 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
}
}
@Remote(called = Loc.server, targets = Loc.both, forward = true)
public static void setUnitStance(Player player, int[] unitIds, UnitStance stance){
if(player == null || unitIds == null || stance == null) return;
if(net.server() && !netServer.admins.allowAction(player, ActionType.commandUnits, event -> {
event.unitIDs = unitIds;
})){
throw new ValidateException(player, "Player cannot command units.");
}
for(int id : unitIds){
Unit unit = Groups.unit.getByID(id);
if(unit != null && unit.team == player.team() && unit.controller() instanceof CommandAI ai){
if(stance == UnitStance.stopStance){ //not a real stance, just cancels orders
ai.clearCommands();
}else{
ai.stance = stance;
}
unit.lastCommanded = player.coloredName();
}
}
}
@Remote(called = Loc.server, targets = Loc.both, forward = true)
public static void commandBuilding(Player player, int[] buildings, Vec2 target){
if(player == null || target == null) return;