Fixed units not resetting to their default command

This commit is contained in:
Anuken
2025-05-05 12:09:58 -04:00
parent 31724ca88d
commit 317f9878dc

View File

@@ -43,7 +43,7 @@ public class CommandAI extends AIController{
/** Stance, usually related to firing mode. */
public UnitStance stance = UnitStance.shoot;
/** Current command this unit is following. */
public UnitCommand command = UnitCommand.moveCommand;
public UnitCommand command;
/** Current controller instance based on command. */
protected @Nullable AIController commandController;
/** Last command type assigned. Used for detecting command changes. */
@@ -63,6 +63,14 @@ public class CommandAI extends AIController{
}
}
@Override
public void init(){
if(command == null){
command = unit.type.defaultCommand == null && unit.type.commands.size > 0 ? unit.type.commands.first() : unit.type.defaultCommand;
if(command == null) command = UnitCommand.moveCommand;
}
}
@Override
public boolean isLogicControllable(){
return !hasCommand();