Olá Hugo,
Question around the use of the singleton for UnitActionSystem when it comes to the OnSelectedUnitChanged event. Could we not just use the sender
object, cast it to UnitActionSystem (since we know that’s what is being sent) and access the GetSelectedUnit()
method like that?
When you presented us with the challenge, my initial reaction was to write:
private void UnitActionSystem_OnSelectedUnitChanged(object sender, EventArgs empty)
{
var selectedUnit = ((UnitActionSystem)sender).GetSelectedUnit();
_meshRenderer.enabled = selectedUnit == unit;
}
Seems to work. Is there a specific reason to go with the Singleton here when the event is already giving us the sender object?
Cheers!
Paulo