Sorry I missed this last week.
I think the most straightforward way to do this to take a look at UnitActionSystemUI.cs.
We have an event we’re subscribing to UnitActionSystem.OnActionStarted.
In the event handler, right now, we’re simply updating the number of points available. Try adding UpdateSelectedVisual(); to this event handler
private void UnitActionSystem_OnActionStart(object sender, EventArgs e)
{
UpdateActionPoints();
UpdateSelectedVisual();
}
Now this by itself won’t actually do much, because the UnitActionSystem will still show the current selected action as the grenade, and it will just set the action. UpdateSelectedActionVisual() actuall calls
actionButtonUI.UpdateSelectedVisual();
on each actionButtonUI.
Let’s play around with the UpdateSelectedVisual() method in ActionButtonUI
public void UpdateSelectedVisual()
{
BaseAction selectedBaseAction = UnitActionSystem.Instance.GetSelectedAction();
selectedGameObject.SetActive(selectedBaseAction == baseAction);
}
Here, we can add one more line to the method to make the button interactable if the selectedBaseAction has not acted this turn and if the unit has enough points to take that action.
public void UpdateSelectedVisual()
{
BaseAction selectedBaseAction = UnitActionSystem.Instance.GetSelectedAction();
button.interactable = !selectedBaseAction.HasActedThisTurn() && selectedBaseAction.GetActionPointsCost() <=
selectedBaseAction.GetUnit().GetActionPoints();
selectedGameObject.SetActive(selectedBaseAction == baseAction);
}