mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-12-06 02:40:23 -08:00
Added unit stances
This commit is contained in:
parent
0d1c56fb60
commit
3e15f70efa
11 changed files with 206 additions and 30 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue