NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
s_StateMethod.cpp
1#include <types.h>
2#include <game/sLib/s_StateInterfaces.hpp>
3#include <game/sLib/s_StateMethod.hpp>
4#include <game/sLib/s_StateID.hpp>
5
7 mpStateChk(checker),
8 mpStateFct(factory),
9 mInitFinalizeLock(false),
10 mExecutionLock(false),
11 mIsValid(false),
12 mStateChanged(false),
13 mRefreshStateMethod(false),
14 mpNewStateID(&initialState),
15 mpOldStateID(&sStateID::null),
16 mpStateID(&initialState),
17 mpState(nullptr) {
18}
19
21
24 mInitFinalizeLock = true;
25
28 if (ret != 0) {
29 mIsValid = true;
30 } else {
31 mIsValid = false;
32 }
33
34 mInitFinalizeLock = false;
35 }
36}
37
39 if (!mExecutionLock) {
40 do {
41 mRefreshStateMethod = false;
42 // We only want to execute if we have a valid next state
43 if (!mpNewStateID->isNull()) {
44 mExecutionLock = true;
46 mExecutionLock = false;
47 }
49 }
50}
51
63
65 if (!newID.isNull()) {
66 mpNewStateID = &newID;
68 mStateChanged = true;
69 }
70}
The interface for state factories.
The interface for state ID checkers.
The interface for state IDs.
virtual bool isNull() const =0
Returns whether this is a null state.
virtual void executeStateLocalMethod()=0
Performs the actual state execution.
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.
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 ~sStateMethod_c()
Destroys the sStateMethod_c instance.
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.
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.