Hey guys, this question involves way more code than can easily be shown here, so I’ve tried to describe this as concisely as I can with a graphic below.
The situation is like this:
When GameState changes, the PlayerState is watching and will also change. But PlayerState can also be changed from input. What changes input can make happen depend on the Game State though. For instance:
If GameState is “InGame” and PlayerState is “Movement”, then input of ESC would change PlayerState to UI and make the pause menu appear. This is all handled in the PlayerState.
Suppose the same situation, except the GameState is “Menu”. In that case, we are in the Main Menu, so ESC would behave differently.
So it is a situation where we get some new states that are the product of GameState + PlayerState. Effectively, there are new states that are getting created, except they are not defined clearly. I have PlayerStates each wrapped in an object, but I cannot wrap the unique cases where GameState:A + PlayerState:A is different from GameState:B + PlayerState:A. That would get out of hand pretty fast.
The simple obvious solution is just to have the GameState enumerator filter certain input cases. But that has zero modularity and would not scale well.
It makes me feel like, there is probably some common programmer techniques to handle a situation like this, but I don’t know how to properly describe the situation to find some examples. Or perhaps I am mishandling these state machines in a weird way to begin with.
Any advice is appreciated.