I am full steam ahead with a game I am making with a team, and we are approaching the point of no return on one of our subsystems/architectural choices, and my lack of experience with it is frightening me.
It is Coroutines. We have implemented our state management using coroutines, and while i feel we have an excellent grasp of exactly how Coroutines in Unity behave, I am not, as you would say in poker, "all in" quite yet.
The main thing that bugs me, is that while Coroutines make state switching so so easy, there are a couple of operations that become non trivial (at least i think they are non trivial, maybe I'm wrong). The best way to describe our implementation using Coroutines is that it is a State Stack, with the option of having another state run in parallel. This description is terrible as the very word "State" is misused, but alas i think you get the point.
The issue at hand with a State Stack is our ability to plain ole switch to x state from y state where y is not above/below x on the stack.
It requires a check in every state between the two in order to make that switch. Now, in a JRPG, this might be fine, as mostly you progress from one state to another, and in a very few cases need to change to something as I previously described.
To that end i have provided an interface IState, which has prepare, validate, and clean methods. Every state in the game must prepare values for the state to run, and every frame validate that it is the correct state to be in, and on exit, clean itself up. The saving grace of the above is the Validate() method, for it will allow multi-state traversal across a stack. And if we take care as to how we cleanup a state (for example all Major state transitions: ExploreMode, CombatMode, WorldView Mode, Menus. If all of these modes cleanup with fading out the camera, then theoretically they all can go from one to another with no problem.)
Anyways, I certainly do not want to turn this into a rant . Thanks for reading and any thoughts are welcome!