NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
d_a_en_door.hpp
1#pragma once
2
3#include <game/bases/d_enemy.hpp>
4#include <game/bases/d_heap_allocator.hpp>
5#include <game/bases/d_a_obj_center.hpp>
6#include <game/bases/d_a_obj_center2.hpp>
7
8/// @brief The base class for door actors.
9/// @statetable
10/// @paramtable
11/// @ingroup bases
12class daEnDoor_c : public dEn_c {
13public:
14 daEnDoor_c() : mIsOpen(false) {}
15
16 /// @brief The possible door states.
17 /// @unofficial
19 DOOR_STATUS_WAIT, ///< The door is ready to be opened.
20 DOOR_STATUS_OPEN_OUT, ///< The door must open for players to enter it.
21 DOOR_STATUS_OPEN_IN, ///< The door must open for players to exit it.
22 DOOR_STATUS_CLOSED ///< The door must close.
23 };
24
25 virtual ~daEnDoor_c() override {}
26 virtual int create() override;
27 virtual int doDelete() override;
28 virtual int execute() override;
29 virtual int draw() override;
30 virtual bool ActorDrawCullCheck() override { return false; }
31
32 virtual bool isClosed() { return isState(StateID_Wait); } ///< Checks whether the door is closed.
33 virtual bool isDummyOpen() { return false; } ///< Returns whether the door must act like fake Ghost House Doors.
34 virtual void createMdl() {} ///< Creates the model and animation for the door.
35 virtual void initAnm() {} ///< Initializes the animation for the door.
36 virtual void initCcData() {} ///< Initializes collision data for the door.
37 virtual void initialize() { mCc.entry(); } ///< Initializes other elements, called by create().
38 virtual void waitProc() {} ///< Executed every frame during the Wait state.
39 virtual void setOpenAnm() {} ///< Sets up the door open animation.
40 virtual void setOpenSE() {} ///< Plays the door opening SFX.
41 virtual void setCloseAnm() {} ///< Sets up the door close animation.
42 virtual void setCloseSE() {} ///< Plays the door closed SFX.
43 virtual void setCloseMoveSE() {} ///< Plays the door closing SFX.
44 virtual void setWaitAnm() {} ///< Stops all animations for the door.
45
46 /// @brief Moves the door along its parent's Z angle.
47 /// @return The parent actor, or @p nullptr if the door is not parent controlled.
49 void rotation_move(dActor_c *parent); ///< Moves the door along the given parent's Z angle.
50
51 /// @brief Links the door to its parent.
52 /// @return The parent actor, or @p nullptr if the door is not parent controlled.
53 dActor_c *setParentInfo(u32 rotationID);
54 void setParentInfo(dActor_c *parent); ///< Links the door to the given parent.
55
56 void allocate(); ///< Wraps createMdl to allocate memory for the door's assets.
57 void calcMdl(); ///< Updates mMatrix and mModel.
58 bool checkOpenOk(); ///< Checks if the door is opening for players to enter it.
59
60 STATE_FUNC_DECLARE(daEnDoor_c, Search); ///< Searching for the parent controller actor.
61 STATE_FUNC_DECLARE(daEnDoor_c, Open); ///< Playing the open animation.
62 STATE_FUNC_DECLARE(daEnDoor_c, Close); ///< Playing the close animation.
63 STATE_FUNC_DECLARE(daEnDoor_c, Wait); ///< Waiting for players to interact with the door.
64 STATE_FUNC_DECLARE(daEnDoor_c, Dummy); ///< Acting as a fake Ghost House door.
65
66 static daObjCenter_c *searchParent_centerA(u32 rotationID); ///< Searches for a daObjCenter_c with the given Rotation ID.
67 static daObjCenter2_c *searchParent_centerB(u32 rotationID); ///< Searches for a daObjCenter2_c with the given Rotation ID.
68 static dActor_c *searchParent(u32 rotationID); ///< Searches for a daObjCenter_c or daObjCenter2_c with the given Rotation ID.
69 static void ccCallback(dCc_c *self, dCc_c *other); ///< Collision callback for the door.
70
71 dHeapAllocator_c mAllocator; ///< The allocator.
72 nw4r::g3d::ResFile mResFile; ///< The resource file.
73 m3d::mdl_c mModel; ///< The door model.
74 m3d::anmChr_c mAnim; ///< The door model animation.
75 fBaseID_e mParentUniqueID; ///< The unique ID of the parent actor if linked (daObjCenter_c or daObjCenter2_c).
76 mVec3_c mDistanceToParent; ///< The distance between the parent controller's position and the door when it spawned.
77 DoorStatus_e mDoorStatus; ///< The current status of the door.
78 BOOL mIsOpen; ///< Whether the door finished opening or not.
79 BOOL mMayOpen; ///< Whether the door may open.
80 mAng mOrientation; ///< The orientation of the door.
81 u8 mHasParent; ///< Whether the door is controlled by a parent actor.
82 u8 mRotationID; ///< The rotation ID that links the door to the corresponding controller. @see daObjCenter_c::mRotationID, daObjCenter2_c::mRotationID
83
84 ACTOR_PARAM_CONFIG(Orientation, 12, 2); ///< @copydoc mOrientation
85 ACTOR_PARAM_CONFIG(HasParent, 8, 1); ///< @copydoc mHasParent
86 ACTOR_PARAM_CONFIG(RotationID, 0, 8); ///< @copydoc mRotationID
87};
bool isState(const sStateIDIf_c &other) const
Checks if the actor is currently in the given state.
The minimum required implementation for a stage actor.
Definition d_actor.hpp:18
dCc_c mCc
The actor-to-actor collision sensor.
Definition d_actor.hpp:344
dActor_c()
Constructs a new actor.
Definition d_actor.cpp:46
Collider ("Collision Check") class - handles collisions between actors.
Definition d_cc.hpp:134
dEn_c()
Constructs a new enemy actor.
Definition d_enemy.cpp:28
The base class for door actors.
virtual int execute() override
do method for the execute operation.
virtual void setWaitAnm()
Stops all animations for the door.
void calcMdl()
Updates mMatrix and mModel.
void allocate()
Wraps createMdl to allocate memory for the door's assets.
dActor_c * setParentInfo(u32 rotationID)
Links the door to its parent.
virtual bool ActorDrawCullCheck() override
Checks if the actor is out of view.
fBaseID_e mParentUniqueID
The unique ID of the parent actor if linked (daObjCenter_c or daObjCenter2_c).
DoorStatus_e mDoorStatus
The current status of the door.
virtual void setCloseMoveSE()
Plays the door closing SFX.
dActor_c * rotation_move()
Moves the door along its parent's Z angle.
virtual void setOpenAnm()
Sets up the door open animation.
m3d::mdl_c mModel
The door model.
virtual void initAnm()
Initializes the animation for the door.
virtual int doDelete() override
do method for the delete operation.
mAng mOrientation
The orientation of the door.
DoorStatus_e
The possible door states.
@ DOOR_STATUS_WAIT
The door is ready to be opened.
@ DOOR_STATUS_OPEN_IN
The door must open for players to exit it.
@ DOOR_STATUS_CLOSED
The door must close.
@ DOOR_STATUS_OPEN_OUT
The door must open for players to enter it.
virtual bool isClosed()
Checks whether the door is closed.
virtual int draw() override
do method for the draw operation.
static sFStateID_c< daEnDoor_c > StateID_Wait
Waiting for players to interact with the door.
nw4r::g3d::ResFile mResFile
The resource file.
virtual void setOpenSE()
Plays the door opening SFX.
virtual bool isDummyOpen()
Returns whether the door must act like fake Ghost House Doors.
ACTOR_PARAM_CONFIG(RotationID, 0, 8)
The rotation ID that links the door to the corresponding controller.
BOOL mMayOpen
Whether the door may open.
virtual void initialize()
Initializes other elements, called by create().
u8 mRotationID
The rotation ID that links the door to the corresponding controller.
BOOL mIsOpen
Whether the door finished opening or not.
virtual void setCloseAnm()
Sets up the door close animation.
dHeapAllocator_c mAllocator
The allocator.
ACTOR_PARAM_CONFIG(HasParent, 8, 1)
Whether the door is controlled by a parent actor.
virtual void createMdl()
Creates the model and animation for the door.
virtual int create() override
do method for the create operation.
static daObjCenter2_c * searchParent_centerB(u32 rotationID)
Searches for a daObjCenter2_c with the given Rotation ID.
mVec3_c mDistanceToParent
The distance between the parent controller's position and the door when it spawned.
m3d::anmChr_c mAnim
The door model animation.
virtual void initCcData()
Initializes collision data for the door.
static daObjCenter_c * searchParent_centerA(u32 rotationID)
Searches for a daObjCenter_c with the given Rotation ID.
virtual void waitProc()
Executed every frame during the Wait state.
u8 mHasParent
Whether the door is controlled by a parent actor.
static dActor_c * searchParent(u32 rotationID)
Searches for a daObjCenter_c or daObjCenter2_c with the given Rotation ID.
bool checkOpenOk()
Checks if the door is opening for players to enter it.
ACTOR_PARAM_CONFIG(Orientation, 12, 2)
The orientation of the door.
virtual void setCloseSE()
Plays the door closed SFX.
static void ccCallback(dCc_c *self, dCc_c *other)
Collision callback for the door.
A controller for rotating objects around a center point.
A controller for swaying objects around a center point.
A three-dimensional floating point vector.
Definition m_vec.hpp:122
fBaseID_e
A unique identifier for each base.
Definition f_base_id.hpp:6
#define STATE_FUNC_DECLARE(class, name)
Declares a state.
Definition s_State.hpp:12
A one-dimensional short angle vector.
Definition m_angle.hpp:12