Multiple unit stance support
This commit is contained in:
@@ -372,15 +372,18 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
//make sure its current stance is valid with its current command
|
||||
stancesOut.clear();
|
||||
unit.type.getUnitStances(unit, stancesOut);
|
||||
if(stancesOut.size > 0 && !stancesOut.contains(ai.stance)){
|
||||
ai.stance = stancesOut.first();
|
||||
for(var stance : content.unitStances()){
|
||||
//disable stances that the unit does not support anymore (TODO: this is slow!)
|
||||
if(ai.hasStance(stance) && !stancesOut.contains(stance)){
|
||||
ai.disableStance(stance);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Remote(called = Loc.server, targets = Loc.both, forward = true)
|
||||
public static void setUnitStance(Player player, int[] unitIds, UnitStance stance){
|
||||
public static void setUnitStance(Player player, int[] unitIds, UnitStance stance, boolean enable){
|
||||
if(player == null || unitIds == null || stance == null) return;
|
||||
|
||||
if(net.server() && !netServer.admins.allowAction(player, ActionType.commandUnits, event -> {
|
||||
@@ -395,7 +398,8 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
if(stance == UnitStance.stop){ //not a real stance, just cancels orders
|
||||
ai.clearCommands();
|
||||
}else if(unit.type.allowStance(unit, stance)){
|
||||
ai.stance = stance;
|
||||
//if toggle is not allowed, the stance will always be set to true when pressed
|
||||
ai.setStance(stance, !stance.toggle || enable);
|
||||
}
|
||||
unit.lastCommanded = player.coloredName();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user