A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
StateManager.hh
1#pragma once
2
3#include "game/field/obj/ObjectBase.hh"
4
5#include <type_traits>
6
7namespace Field {
8
9template <typename T>
11 using StateEnterFunc = void (T::*)();
12 using StateCalcFunc = void (T::*)();
13
14 u16 id;
15 StateEnterFunc onEnter;
16 StateCalcFunc onCalc;
17};
18
19template <typename T>
21public:
22 StateManagerBase() : m_currentStateId(0), m_nextStateId(-1), m_currentFrame(0), m_obj(nullptr) {
23 // Concepts don't work here due to CRTP causing incomplete class type use.
24 STATIC_ASSERT((std::is_base_of_v<ObjectBase, T>));
25 }
26
27 virtual ~StateManagerBase() {}
28
29protected:
30 u16 m_currentStateId;
31 s32 m_nextStateId;
32 u32 m_currentFrame;
33 std::span<u16> m_entryIds;
34 std::span<const StateManagerEntry<T>> m_entries;
35 const T *m_obj;
36};
37
38// Keep the constructor from above
39template <typename T>
40class StateManager : public StateManagerBase<T> {
41public:
42 StateManager() = default;
43 ~StateManager() = default;
44};
45
46} // namespace Field
Pertains to collision.