Files
ss/include/s/s_StateMgr.hpp
T
robojumper 1180e1f486 m3d (#13)
* Initial M3d Pass
* `m_bmdl` and `m_bline` left

---------

Co-authored-by: elijah-thomas774 <elijahthomas774@gmail.com>
Co-authored-by: Elijah Thomas <42302100+elijah-thomas774@users.noreply.github.com>
2024-09-12 16:36:34 -04:00

50 lines
1.6 KiB
C++

#ifndef S_STATEMGR_H
#define S_STATEMGR_H
#include <s/s_StateInterfaces.hpp>
// Note: Ported from https://github.com/NSMBW-Community/NSMBW-Decomp/tree/master/include/dol/sLib
// See include/s/README.txt for changes made
/**
* @brief An implementation of sStateMgrIf_c.
*
* @tparam T The parent class for this state manager.
* @tparam Method The state method handler to use.
* @tparam Factory The state factory to use.
* @tparam Check The state ID checker to use.
* @ingroup state
*/
template <class T, class Method, template <class> class Factory, class Check>
class sStateMgr_c : sStateMgrIf_c {
public:
sStateMgr_c(T &owner, const sStateIDIf_c &initialState) :
mFactory(owner),
mMethod(mCheck, mFactory, initialState) {}
virtual void initializeState() { mMethod.initializeStateMethod(); }
virtual void executeState() { mMethod.executeStateMethod(); }
virtual void finalizeState() { mMethod.finalizeStateMethod(); }
virtual void changeState(const sStateIDIf_c &newState) { mMethod.changeStateMethod(newState); }
virtual void refreshState() { mMethod.refreshStateMethod(); }
virtual sStateIf_c *getState() const { return mMethod.getState(); }
virtual const sStateIDIf_c *getNewStateID() const { return mMethod.getNewStateID(); }
virtual const sStateIDIf_c *getStateID() const { return mMethod.getStateID(); }
virtual const sStateIDIf_c *getOldStateID() const { return mMethod.getOldStateID(); }
// SS addition
bool isState(const sStateIDIf_c& other) {
return *getStateID() == other;
}
private:
Check mCheck;
Factory<T> mFactory;
Method mMethod;
};
#endif