Command hotkeys

This commit is contained in:
Anuken
2023-09-23 11:03:15 -04:00
parent f2bb712860
commit 2286b54011
3 changed files with 30 additions and 1 deletions

View File

@@ -77,6 +77,18 @@ public class PlacementFragment{
Binding.unit_stance_5,
};
Binding[] commandBindings = {
Binding.unit_command_1,
Binding.unit_command_2,
Binding.unit_command_3,
Binding.unit_command_4,
Binding.unit_command_5,
Binding.unit_command_6,
Binding.unit_command_7,
Binding.unit_command_8,
Binding.unit_command_9,
};
public PlacementFragment(){
Events.on(WorldLoadEvent.class, event -> {
Core.app.post(() -> {
@@ -601,6 +613,13 @@ public class PlacementFragment{
Call.setUnitStance(player, control.input.selectedUnits.mapInt(un -> un.id).toArray(), stances.get(i));
}
}
for(int i = 0; i < Math.min(commandBindings.length, commands.size); i++){
//first stance must always be the stop stance
if(Core.input.keyTap(commandBindings[i])){
Call.setUnitCommand(player, control.input.selectedUnits.mapInt(un -> un.id).toArray(), commands.get(i));
}
}
}
});
rebuildCommand.run();