NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
d_center_save_mng.hpp
1#pragma once
2#include <game/cLib/c_line.hpp>
3#include <game/mLib/m_vec.hpp>
4
5/// @brief A manager for saving and restoring rotation state of daObjCenter2_c actors.
6/// @ingroup bases
8private:
9 /// @brief An entry in the rotation state manager.
10 /// @unofficial
11 class Entry_c : public cLineNd_c {
12 public:
13 Entry_c() {
14 mpSelf = this;
15 ms_linkManager.addLastLineNode(this);
16 }
17
18 ~Entry_c() {
19 ms_linkManager.removeLineNode(this);
20 }
21
22 float getX() const { return mPos.x; }
23 float getY() const { return mPos.y; }
24
25 Entry_c *mpSelf; ///< A pointer to this entry. [Not sure why this is needed, always points to itself.]
26 mVec3_c mPos; ///< The position of the related rotation controller.
27 short mRotation; ///< The saved target rotation of the related rotation controller.
28 u8 mRotationID; ///< The rotation ID of the related rotation controller.
29 };
30
31public:
32 dCenterSaveMng_c(); ///< Constructs a new manager.
33 ~dCenterSaveMng_c(); ///< Destroys the manager.
34
35 /// @brief Tries to restore the rotation from a given position and ID.
36 /// @param pos The position to check.
37 /// @param id The ID to check.
38 /// @param outRotation The output rotation value if a match is found.
39 /// @return Whether a rotation was found and restored.
40 bool center_check(const mVec3_c* pos, u8 id, short *outRotation);
41
42 /// @brief Saves the rotation state for a given position and ID.
43 /// @param pos The position to save.
44 /// @param id The ID to save.
45 /// @param rotation The rotation value to save.
46 void center_entry(const mVec3_c* pos, u8 id, short rotation);
47
48private:
49 static void allDoDelete(); ///< Clears all saved rotation states.
50
51public:
52 static dCenterSaveMng_c *m_instance; ///< The singleton instance of the manager.
53 static cLineMg_c ms_linkManager; ///< The linked list manager for the saved rotation states.
54};
A doubly-linked list container. See cLineNd_c.
Definition c_line.hpp:23
cLineNd_c()
Constructs a new list node.
Definition c_line.hpp:9
mVec3_c mPos
The position of the related rotation controller.
short mRotation
The saved target rotation of the related rotation controller.
Entry_c * mpSelf
A pointer to this entry. [Not sure why this is needed, always points to itself.].
u8 mRotationID
The rotation ID of the related rotation controller.
bool center_check(const mVec3_c *pos, u8 id, short *outRotation)
Tries to restore the rotation from a given position and ID.
dCenterSaveMng_c()
Constructs a new manager.
void center_entry(const mVec3_c *pos, u8 id, short rotation)
Saves the rotation state for a given position and ID.
~dCenterSaveMng_c()
Destroys the manager.
static void allDoDelete()
Clears all saved rotation states.
static cLineMg_c ms_linkManager
The linked list manager for the saved rotation states.
static dCenterSaveMng_c * m_instance
The singleton instance of the manager.
A three-dimensional floating point vector.
Definition m_vec.hpp:122