NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
d_base_actor.hpp
1#pragma once
2#include <types.h>
3#include <game/bases/d_base.hpp>
4#include <game/cLib/c_list.hpp>
5#include <game/framework/f_list_mg.hpp>
6#include <game/mLib/m_angle.hpp>
7#include <game/mLib/m_mtx.hpp>
8#include <game/mLib/m_vec.hpp>
9
10/// @brief The minimum required implementation for an actor base.
11/// @ingroup bases
12class dBaseActor_c : public dBase_c {
13public:
14
15 /// @brief An identifier that represents the actor's kind.
16 /// @details [This is only used in worldmaps].
18 ACTOR_MAP_GENERIC, ///< A generic map actor (dWmActor_c).
19 ACTOR_MAP_DEMO, ///< A map actor affected by cutscenes (dWmDemoActor_c).
20 ACTOR_MAP_OBJECT, ///< A map object (dWmObjActor_c).
21 ACTOR_MAP_ENEMY, ///< A map enemy (dWmEnemy_c).
22 ACTOR_MAP_PLAYER, ///< The worldmap player actor (dWmPlayer_c).
23 ACTOR_MAP_STOP, ///< The unused map stop actor (daWmStop_c). @unused
24 ACTOR_UNK_6, ///< @unused
25 ACTOR_MENU_PLAYER, ///< The menu player actor (da2DPlayer_c).
26 ACTOR_GENERIC, ///< A generic non-map actor.
27 };
28
29 dBaseActor_c(); ///< Constructs a new actor.
30
31protected:
32 virtual int preCreate();
33 virtual void postCreate(fBase_c::MAIN_STATE_e status);
34
35 virtual int preDelete();
36 virtual void postDelete(fBase_c::MAIN_STATE_e status);
37
38 virtual int preExecute();
39 virtual void postExecute(fBase_c::MAIN_STATE_e status);
40
41 virtual int preDraw();
42 virtual void postDraw(fBase_c::MAIN_STATE_e status);
43
44 virtual ~dBaseActor_c(); ///< Destroys the actor.
45
46 /// @brief Alternate drawing function used to draw 3D models in front of 2D graphics (first draw pass).
47 /// @details This feature is not used in stages. See [here](#drawing-models-over-2d-layouts)
48 /// for details.
49 virtual void draw2D();
50
51 /// @brief Alternate drawing function used to draw 3D models in front of 2D graphics (second draw pass).
52 /// @details This feature is not used in stages. See [here](#drawing-models-over-2d-layouts)
53 /// for details.
54 virtual void draw2D_lyt2();
55
56 virtual int GetActorType(); ///< Gets the actor kind. See ::ACTOR_KIND_e.
57
58 virtual void finalUpdate(); ///< Code to be executed after all actors' @p execute operation has run.
59
60public:
61 /// @brief Updates the actor's speed (3D actors). See [here](#speed-and-acceleration) for details.
62 void calcSpeed();
63
64 /// @brief Updates the actor's speed (2D actors). See [here](#speed-and-acceleration) for details.
65 void calcSpeedXY();
66
67 void calcSpeedX(); ///< Updates the actor's X speed. See [here](#speed-and-acceleration) for details.
68 void calcFallSpeed(); ///< Updates the actor's falling speed. See [here](#speed-and-acceleration) for details.
69 void calcSpeedY(); ///< Updates the actor's Y speed. See [here](#speed-and-acceleration) for details.
70 void calcSpeedF(); ///< Updates the actor's forward speed. See [here](#speed-and-acceleration) for details.
71
72 /// @brief Generates a partial transformation matrix for the actor and stores it in ::mMatrix.
73 /// @details The transformation matrix only contains the translation and the rotation on the Y axis.
74 void makeMtx();
75
76 mVec3_c getCenterPos() const; ///< Gets the actor's centered position.
77 void posMove(mVec3_c &delta); ///< Moves the actor by the given delta.
78 void posMove(); ///< Moves the actor by its @ref mSpeed "speed".
79
80 // [why is this not static?]
81 int GetProfNameActorNum(ProfileName profile); ///< Counts the instances of the given actor profile.
82
83 static void draw2DActorOnLyt1(); ///< Calls ::draw2D on every actor.
84 static void draw2DActorOnLyt2(); ///< Calls ::draw2D_lyt2 on every actor.
85
86 /**
87 * @brief Creates an actor without a parent.
88 *
89 * @details The actor is created as a child of the current scene actor, so that all actors can be
90 * deleted on a scene change, acting as a garbage collection mechanism.
91 * @param profName The actor's profile name.
92 * @param param The actor's parameters.
93 * @param position The actor's position.
94 * @param rotation The actor's rotation.
95 * @return A pointer to the instantiated actor, or @p nullptr .
96 */
97 static dBaseActor_c *construct(ProfileName profName, unsigned long param, const mVec3_c *position, const mAng3_c *rotation);
98
99 /**
100 * @brief Creates a child actor with the given parent.
101 *
102 * @param profName The actor's profile name.
103 * @param parent The actor's parent. Must not be @p nullptr .
104 * @param param The actor's parameters.
105 * @param position The actor's position.
106 * @param rotation The actor's rotation.
107 * @return A pointer to the instantiated actor, or @p nullptr .
108 */
109 static dBaseActor_c *construct(ProfileName profName, dBase_c *parent, unsigned long param, const mVec3_c *position, const mAng3_c *rotation);
110
111private:
112 /**
113 * @brief Sets temporary data to be used for the next actor's construction.
114 *
115 * @param position The actor's position.
116 * @param rotation The actor's rotation.
117 */
118 static void setTmpCtData(const mVec3_c *position, const mAng3_c *rotation);
119
120 fLiNdBa_c mLinkActor; ///< The node in ::m_actorManage.
121
122public:
123 mMtx_c mMatrix; ///< The actor's partial transformation matrix. See ::makeMtx for details.
124
125 mVec3_c mPos; ///< The actor's position.
126 mVec3_c mLastPos; ///< The actor's position in the previous frame.
127 mVec3_c mPosDelta; ///< The actor's position delta since the previous frame.
128
129 mVec3_c mCenterOffs; ///< The offset from the position to the center of the actor (defaults to 0).
130 mVec3_c mScale; ///< The actor's scale (defaults to 1).
131 mVec3_c mSpeed; ///< The actor's speed.
132 mVec3_c mSpeedMax; ///< The actor's maximum speed.
133
134 mAng3_c mAngle; ///< The actor's rotation (for 2D actors).
135 mAng3_c mAngle3D; ///< The actor's rotation (for 3D actors).
136
137 float mSpeedF; ///< The actor's horizontal speed.
138 float mMaxSpeedF; ///< The actor's maximum horizontal speed.
139 float mAccelY; ///< The actor's vertical acceleration.
140 float mMaxFallSpeed; ///< The actor's maximum fall speed.
141 float mAccelF; ///< The actor's horizontal acceleration.
142
143 u32 mActorProperties; ///< The actor's properties. See fProfile::fActorProfile_c::mActorProperties.
144 bool mVisible; ///< Whether the actor should be visible or not. Defaults to @p true .
145
146private:
147 static const mVec3_c *m_tmpCtPosP; ///< Temporary storage for the next constructed actor's position. See ::mPos.
148 static const mAng3_c *m_tmpCtAngleP; ///< Temporary storage for the next constructed actor's rotation. See ::mAngle.
149 static fLiMgBa_c m_actorManage; ///< A list of all actor bases.
150};
bool mVisible
Whether the actor should be visible or not. Defaults to true .
mAng3_c mAngle3D
The actor's rotation (for 3D actors).
void calcSpeedXY()
Updates the actor's speed (2D actors). See here for details.
int GetProfNameActorNum(ProfileName profile)
Counts the instances of the given actor profile.
mMtx_c mMatrix
The actor's partial transformation matrix. See makeMtx for details.
virtual int preDraw()
pre method for the draw operation.
mVec3_c mScale
The actor's scale (defaults to 1).
float mAccelF
The actor's horizontal acceleration.
mVec3_c mSpeed
The actor's speed.
mVec3_c mLastPos
The actor's position in the previous frame.
mVec3_c mPos
The actor's position.
virtual void draw2D_lyt2()
Alternate drawing function used to draw 3D models in front of 2D graphics (second draw pass).
mVec3_c mSpeedMax
The actor's maximum speed.
void makeMtx()
Generates a partial transformation matrix for the actor and stores it in mMatrix.
virtual void postExecute(fBase_c::MAIN_STATE_e status)
post method for the execute operation.
virtual void postDraw(fBase_c::MAIN_STATE_e status)
post method for the draw operation.
static const mVec3_c * m_tmpCtPosP
Temporary storage for the next constructed actor's position. See mPos.
virtual void finalUpdate()
Code to be executed after all actors' execute operation has run.
void calcSpeedX()
Updates the actor's X speed. See here for details.
mVec3_c mPosDelta
The actor's position delta since the previous frame.
mVec3_c mCenterOffs
The offset from the position to the center of the actor (defaults to 0).
void calcFallSpeed()
Updates the actor's falling speed. See here for details.
fLiNdBa_c mLinkActor
The node in m_actorManage.
static void setTmpCtData(const mVec3_c *position, const mAng3_c *rotation)
Sets temporary data to be used for the next actor's construction.
static dBaseActor_c * construct(ProfileName profName, unsigned long param, const mVec3_c *position, const mAng3_c *rotation)
Creates an actor without a parent.
virtual int preDelete()
pre method for the delete operation.
float mSpeedF
The actor's horizontal speed.
virtual void postDelete(fBase_c::MAIN_STATE_e status)
post method for the delete operation.
void posMove()
Moves the actor by its speed.
virtual void draw2D()
Alternate drawing function used to draw 3D models in front of 2D graphics (first draw pass).
virtual int GetActorType()
Gets the actor kind. See ACTOR_KIND_e.
float mMaxFallSpeed
The actor's maximum fall speed.
void calcSpeed()
Updates the actor's speed (3D actors). See here for details.
mVec3_c getCenterPos() const
Gets the actor's centered position.
static const mAng3_c * m_tmpCtAngleP
Temporary storage for the next constructed actor's rotation. See mAngle.
void calcSpeedF()
Updates the actor's forward speed. See here for details.
static fLiMgBa_c m_actorManage
A list of all actor bases.
mAng3_c mAngle
The actor's rotation (for 2D actors).
static void draw2DActorOnLyt2()
Calls draw2D_lyt2 on every actor.
virtual ~dBaseActor_c()
Destroys the actor.
virtual void postCreate(fBase_c::MAIN_STATE_e status)
post method for the create operation.
u32 mActorProperties
The actor's properties. See fProfile::fActorProfile_c::mActorProperties.
float mAccelY
The actor's vertical acceleration.
float mMaxSpeedF
The actor's maximum horizontal speed.
void calcSpeedY()
Updates the actor's Y speed. See here for details.
virtual int preExecute()
pre method for the execute operation.
virtual int preCreate()
pre method for the create operation.
static void draw2DActorOnLyt1()
Calls draw2D on every actor.
ACTOR_KIND_e
An identifier that represents the actor's kind.
@ ACTOR_MAP_STOP
The unused map stop actor (daWmStop_c).
@ ACTOR_MAP_ENEMY
A map enemy (dWmEnemy_c).
@ ACTOR_MAP_GENERIC
A generic map actor (dWmActor_c).
@ ACTOR_MAP_OBJECT
A map object (dWmObjActor_c).
@ ACTOR_MAP_DEMO
A map actor affected by cutscenes (dWmDemoActor_c).
@ ACTOR_MAP_PLAYER
The worldmap player actor (dWmPlayer_c).
@ ACTOR_GENERIC
A generic non-map actor.
@ ACTOR_MENU_PLAYER
The menu player actor (da2DPlayer_c).
dBaseActor_c()
Constructs a new actor.
dBase_c()
Constructs a new base.
Definition d_base.cpp:13
MAIN_STATE_e
The possible operation results.
Definition f_base.hpp:30
A base list, made of fLiNdBa_c nodes.
Definition f_list_mg.hpp:13
A three-dimensional short angle vector.
Definition m_angle.hpp:60
A 3x4 matrix.
Definition m_mtx.hpp:11
A three-dimensional floating point vector.
Definition m_vec.hpp:100
u16 ProfileName
The name of a profile. Value is a fProfile::PROFILE_NAME_e.
Definition f_profile.hpp:32