NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
d_wm_actor.hpp
1#pragma once
2
3#include <game/bases/d_base_actor.hpp>
5#include <game/mLib/m_sphere.hpp>
6/**
7 * @brief The minimum required implementation for a world map actor.
8 * @ingroup bases
9 * @details
10 * ## Overview
11 * dWmActor_c serves as the base for all map actors (Wm stands for World Map). It is typically not used
12 * directly, unless the actor's sole purpose is for background tasks or unconditional 3D model rendering.
13 * For more complex behaviors, it is recommended to use dWmDemoActor_c and its sub-implementations, which
14 * enable the actor to respond to world map events and more.
15 *
16 * ## Creating Map Actors
17 * Map actors can be created by calling one of the two ::construct methods, which define two
18 * additional arguments to provide the starting position and rotation. A parent base can optionally
19 * be provided.
20 *
21 * ## Notable Operation Changes
22 * The following operation changes have been made:
23 * - The execute operation is not performed if the game @ref dGameCom::isGameStop "is stopped" for
24 * @ref dGameCom::GAME_STOP_e::GAME_STOP_ANY "any reason".
25 * - The draw operation is not performed if the actor is outside the camera view. See [here](#bounding-sphere)
26 * for details.
27 * - The execute and draw operations are also skipped if the World Select Menu is open.
28 * - This is done to ensure the blurring effect behind the menu works as intended: the game captures a screenshot of
29 * the map, displaying it instead of the active world, while all animations are paused to avoid abrupt transitions upon
30 * exiting the menu.
31 * - @p WM_CS_SEQ_MNG , @p WM_ISLAND and @p WM_DIRECTOR are the only actors allowed to keep running while the menu is
32 * open.
33 *
34 * ## Bounding Sphere
35 * The game uses a @ref mCullSphere "bounding sphere" to perform
36 * @xlink{https://bruop.github.io/frustum_culling/,frustum culling} on the actor.
37 *
38 * If the actor's bounding sphere is not within the camera view, it will not be rendered. This behaviour can
39 * be controlled by setting the sphere's @ref mSphere_c::mRadius "radius" (which must be done manually).
40 * If the radius is set to @p 0.0f (the default value), the check is bypassed and the actor is always
41 * drawn. The sphere's @ref mSphere_c::mPos "position" is updated automatically.
42 *
43 * @hint{It is recommended to set the sphere radius in the ::create method.}
44 *
45 * ## Lighting Adjustments
46 * Wrappers to adjust the model lighting are provided for convenience. See dGameCom for details.
47 *
48 * @todo Use proper class names for the mentioned actors once decompiled.
49 */
50class dWmActor_c : public dBaseActor_c {
51 dWmActor_c(); ///< @copydoc dBaseActor_c::dBaseActor_c
52
53 virtual int preCreate();
54 virtual void postCreate(fBase_c::MAIN_STATE_e status);
55
56 virtual int preDelete();
57 virtual void postDelete(fBase_c::MAIN_STATE_e status);
58
59 virtual int preExecute();
60 virtual void postExecute(fBase_c::MAIN_STATE_e status);
61
62 virtual int preDraw();
63 virtual void postDraw(fBase_c::MAIN_STATE_e status);
64
65 virtual ~dWmActor_c(); ///< @copydoc dBaseActor_c::~dBaseActor_c
66
67 virtual int GetActorType();
68
69 /// @brief Creates a world map actor without a parent. See dBaseActor_c::construct.
70 static dWmActor_c *construct(ProfileName profName, unsigned long param, const mVec3_c *position, const mAng3_c *rotation);
71
72 /// @brief Creates a child world map actor with the given parent. See
73 /// @ref dBaseActor_c::construct(ProfileName, dBase_c*, unsigned long, const mVec3_c*, const mAng3_c*)
74 /// "dBaseActor_c::construct".
75 static dWmActor_c *construct(ProfileName profName, dBase_c *base, unsigned long param, const mVec3_c *position, const mAng3_c *rotation);
76
77 static void setSoftLight_Map(m3d::bmdl_c &mdl); ///< @copydoc dGameCom::SetSoftLight_Map
78 static void setSoftLight_MapObj(m3d::bmdl_c &mdl); ///< @copydoc dGameCom::SetSoftLight_MapObj
79 static void setSoftLight_Enemy(m3d::bmdl_c &mdl); ///< @copydoc dGameCom::SetSoftLight_Enemy
80 static void setSoftLight_Boss(m3d::bmdl_c &mdl); ///< @copydoc dGameCom::SetSoftLight_Boss
81
82private:
83 mSphere_c mCullSphere; ///< @brief A sphere representing the actor's visible area.
84};
dBaseActor_c()
Constructs a new actor.
dBase_c()
Constructs a new base.
Definition d_base.cpp:12
static void setSoftLight_Boss(m3d::bmdl_c &mdl)
Sets the soft light effect for bosses.
static void setSoftLight_Map(m3d::bmdl_c &mdl)
Sets the soft light effect for map actors.
virtual int preCreate()
pre method for the create operation.
virtual int preExecute()
pre method for the execute operation.
virtual int preDelete()
pre method for the delete operation.
mSphere_c mCullSphere
A sphere representing the actor's visible area.
virtual void postExecute(fBase_c::MAIN_STATE_e status)
post method for the execute operation.
virtual void postCreate(fBase_c::MAIN_STATE_e status)
post method for the create operation.
static void setSoftLight_MapObj(m3d::bmdl_c &mdl)
Sets the soft light effect for map objects.
virtual void postDraw(fBase_c::MAIN_STATE_e status)
post method for the draw operation.
virtual void postDelete(fBase_c::MAIN_STATE_e status)
post method for the delete operation.
static void setSoftLight_Enemy(m3d::bmdl_c &mdl)
Sets the soft light effect for enemies.
virtual ~dWmActor_c()
Destroys the actor.
Definition d_wm_actor.cpp:8
virtual int preDraw()
pre method for the draw operation.
static dWmActor_c * construct(ProfileName profName, unsigned long param, const mVec3_c *position, const mAng3_c *rotation)
Creates a world map actor without a parent. See dBaseActor_c::construct.
dWmActor_c()
Constructs a new actor.
Definition d_wm_actor.cpp:6
virtual int GetActorType()
Gets the actor kind. See ACTOR_KIND_e.
MAIN_STATE_e
The possible operation results.
Definition f_base.hpp:137
A three-dimensional short angle vector.
Definition m_angle.hpp:60
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