|
| | StateManager () |
| State & | top () |
| | Returns the top of the manager stack.
|
| bool | empty () const |
| | Returns whether the manager stack is empty.
|
| GameContext & | getGameContext () const |
| | Returns the GameContext struct.
|
| void | swap (const std::shared_ptr< State > &state) |
| | Helper function for swapping the top state with a new state. Does this by updating the pending command.
|
| void | push (const std::shared_ptr< State > &state) |
| | Pushes the state to the stack. Does this by updating pending command.
|
| void | pop () |
| | Pops the top state from the stack. Does this by updating pending command.
|
| void | clear (const std::shared_ptr< State > &state) |
| | Clears the state stack and pushes the new state. Does this by updating pending command.
|
| void | executeCommand () |
| | Applies any pending command, if there is any pending command.
|
StateManager class holds a stack with States. It makes use of the Command pattern to assure that at no point in time, states are deleting themselves instantly when calling StateManager methods.
Stack influencing methods update the StateManager::pendingCommand. The dedicated StateManager::executeCommand() function will execute the pending command. Implementation wise a State can now request to be popped/swapped or replaced, but it does not control when exactly happens.
stateManager->top().update(dt);
stateManager->executeCommand();