So I always prefer to not have to click on things, so I added the tab key to switch between possible units with action points.
The next obvious step was action selection with the number keys.
The solution i came up with was to apply a ‘Scale’ to the action keys depending on what key was entered
eg. 1[keyboard] has a scale of 0, returns 0 when clicked.
This well let us return [0] from an array.
InputManager
public bool GetActionInput(out int keyIndex)
{
if (playerInputActions.Player.ActionSelection.WasPressedThisFrame())
{
keyIndex = (int)playerInputActions.Player.ActionSelection.ReadValue<float>();
return true;
}
else
{
keyIndex = -1;
return false;
}
}
UnitActionSystem
void TrySelectNewActionHotkey()
{
int actionIndex;
if(InputManager.Instance.GetActionInput(out actionIndex))
{
var selectedUnitAvailableActions = selectedUnit.GetBaseActionArray();
if(selectedUnitAvailableActions[actionIndex] != null)
{
SetSelectedAction(selectedUnitAvailableActions[actionIndex]);
}
}
}