NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
s_StateMethod.hpp
1#pragma once
2#include <game/sLib/s_StateInterfaces.hpp>
3
4/// @brief A class that handles state execution and transition.
5/// @details [Presumably, sStateMethod_c actually means "methods for state interaction", or something like that].
6/// @ingroup state
8public:
9 /**
10 * @brief Constructs a new sStateMethod_c instance.
11 *
12 * @param checker The state checker to use.
13 * @param factory The state factory to use.
14 * @param initialState The initial state ID of this instance.
15 */
16 sStateMethod_c(sStateIDChkIf_c &checker, sStateFctIf_c &factory, const sStateIDIf_c &initialState);
17 virtual ~sStateMethod_c(); ///< Destroys the sStateMethod_c instance.
18
19 virtual void initializeStateMethod(); ///< @copydoc sStateMgrIf_c::initializeState
20 virtual void executeStateMethod(); ///< @copydoc sStateMgrIf_c::executeState
21 virtual void finalizeStateMethod(); ///< @copydoc sStateMgrIf_c::finalizeState
22 virtual void changeStateMethod(const sStateIDIf_c &newStateID); ///< @copydoc sStateMgrIf_c::changeState
23 virtual void refreshStateMethod() { mRefreshStateMethod = true; } ///< @copydoc sStateMgrIf_c::refreshState
24 virtual sStateIf_c *getState() const { return mpState; } ///< @copydoc sStateMgrIf_c::getState
25 virtual const sStateIDIf_c *getNewStateID() const { return mpNewStateID; } ///< @copydoc sStateMgrIf_c::getNewStateID
26 virtual const sStateIDIf_c *getStateID() const { return mpStateID; } ///< @copydoc sStateMgrIf_c::getStateID
27 virtual const sStateIDIf_c *getOldStateID() const { return mpOldStateID; } ///< @copydoc sStateMgrIf_c::getOldStateID
28
29 virtual int initializeStateLocalMethod() = 0; ///< Performs the actual state initialization.
30 virtual void executeStateLocalMethod() = 0; ///< Performs the actual state execution.
31 virtual void finalizeStateLocalMethod() = 0; ///< Performs the actual state termination.
32 virtual void changeStateLocalMethod(const sStateIDIf_c &newStateID) = 0; ///< Performs the actual state transition.
33
34protected:
35 sStateIDChkIf_c &mpStateChk; ///< The state checker to use. @unused
36 sStateFctIf_c &mpStateFct; ///< The state factory which produces the state holder.
37
38 bool mInitFinalizeLock; ///< A lock to ensure ::initializeStateMethod and ::finalizeStateMethod are not called recursively.
39 bool mExecutionLock; ///< A lock to ensure ::executeStateMethod is not called recursively.
40 bool mIsValid; ///< If the state holder contains a valid state ID.
41 bool mStateChanged; ///< If the current state has changed during execution.
42 bool mRefreshStateMethod; ///< True, if after a state transition, the state should be executed again.
43
44 const sStateIDIf_c *mpNewStateID; ///< The next state ID.
45 const sStateIDIf_c *mpOldStateID; ///< The previous state ID.
46 const sStateIDIf_c *mpStateID; ///< The current state ID.
47
48 sStateIf_c *mpState; ///< The current state holder.
49};
The interface for state factories.
The interface for state ID checkers.
The interface for state IDs.
The interface for a state holder.
virtual void executeStateLocalMethod()=0
Performs the actual state execution.
virtual const sStateIDIf_c * getOldStateID() const
Gets the previous state ID.
virtual int initializeStateLocalMethod()=0
Performs the actual state initialization.
virtual void finalizeStateLocalMethod()=0
Performs the actual state termination.
virtual void initializeStateMethod()
Initializes the current state.
const sStateIDIf_c * mpStateID
The current state ID.
const sStateIDIf_c * mpOldStateID
The previous state ID.
bool mExecutionLock
A lock to ensure executeStateMethod is not called recursively.
sStateIDChkIf_c & mpStateChk
The state checker to use.
virtual const sStateIDIf_c * getNewStateID() const
Gets the next state ID.
virtual sStateIf_c * getState() const
Gets the state holder.
sStateMethod_c(sStateIDChkIf_c &checker, sStateFctIf_c &factory, const sStateIDIf_c &initialState)
Constructs a new sStateMethod_c instance.
virtual void finalizeStateMethod()
Prepares the current state for termination.
virtual void refreshStateMethod()
Marks the current state to be executed again.
virtual ~sStateMethod_c()
Destroys the sStateMethod_c instance.
sStateFctIf_c & mpStateFct
The state factory which produces the state holder.
bool mInitFinalizeLock
A lock to ensure initializeStateMethod and finalizeStateMethod are not called recursively.
bool mStateChanged
If the current state has changed during execution.
virtual void changeStateLocalMethod(const sStateIDIf_c &newStateID)=0
Performs the actual state transition.
sStateIf_c * mpState
The current state holder.
const sStateIDIf_c * mpNewStateID
The next state ID.
bool mIsValid
If the state holder contains a valid state ID.
virtual void executeStateMethod()
Executes the current state.
virtual void changeStateMethod(const sStateIDIf_c &newStateID)
Transitions to a new state ID.
bool mRefreshStateMethod
True, if after a state transition, the state should be executed again.
virtual const sStateIDIf_c * getStateID() const
Gets the current state ID.