I have a design question.
I’ve found a few times I have come across a method which makes sense to have a coroutine and non-coroutine version.
For example, let’s say I have a State class, and that State class has two methods: Activate() and Deactivate(). State.Activate() is called when the State is first enabled, and handles a transition to that state. Similarly, State.Deactivate() is called before a new state is activated.
In some instances, I just want to call State.Deactivate() and leave it at that. But then in other instances, I want to script a sequence, so I’d do something like this instead:
yield return StartCoroutine(OldState.Deactivate());
NewState.Activate();
Without getting into a discussion about better ways to handle State management (LOL!), I’m wondering if anyone has come across this problem of wanting a coroutine and non-coroutine version of a method, and how you handle it when you do?
Do you simply have two version of the method?
void Activate();
void ActivateCoroutine();
Or do you do something much more clever?