I am currently struggling really bad to make the game states management. Before we dig into the problem, I must point out that I do know about state machines, I do have both implemented (states and state machine) and they look SIMILAR to this, or you can also see my real outdated implementation from my github. Alright, my questions are:
Do states usually operate state machines? Eg.: when the LoadingState finishes (based on the 'update' method) loading something, it tells the state machine to pop the stack (which would pop the LoadingState) and to push a new state, such as PlayingState OR should the LoadingState only notify the state machine and the state machine itself will be responsible of knowing whats the next state based on the state that has requested a pop? Knowing which state has requested a pop (pop, push or whatever) is kind of difficult because it needs some advanced C++11 stuff, which requires a lot of 'not-easy-to-understand' code and validations (asserts), unless we use an enumeration inside each state and do a simple switch (again, more typing).
Should the state machine be opperated/accessed (pointer/static functions) by any component (class, system, manager...) of the game? Eg.: the main player has moved into a map teleport and it triggered a map load, since it should be teleported to a new map. Should the Map class notify the state machine to push the MapTransitionState into the stack, through a static (it doesnt really make any sense to have a pointer to the state machine in the map class) public function?
Thanks a lot!