Having ActionButtonUI determine their own "selection" status?

This is probably a coding philosophy question, but was hoping to get feedback on it.

We currently have an UpdateSelectedVisual() method on each button, and that means each button is responsible for deciding whether or not it should show a selection border.

In my head, that feels like something the UnitActionSystemUI would decide. Eg, buttons have their own functionality, but they don’t make larger decisions. It would mean only one call to the UnitActionSystem.Instance.GetSelectedAction(), and we’d cycle through our already-existing list of buttons tell them to set selection to true or false, depending on if their baseAction == the GetSelectedAction.

I’m not saying I’m right at all, more just hoping to check my understanding of what individual objects should do versus their managers? Having each button poll the UnitActionSystem feels almost like “going over the manager’s head.” :smiley:

4 Likes

Either method works.
I like to have the Manager spawn the buttons as needed, and then do nothing until the next character’s turn has come, where the buttons get recycled and spawned again, leaving all of the display logic to the buttons including the selection.
That doesn’t automatically mean that the way you are inferring is wrong. A profiler might show that your idea is faster.
It’s difficult to say which method fits with a Single Responsibility Principle, as technically either the Manager and the Button would be taking on an additional responsibility.

2 Likes

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms