NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
da_remo_door.cpp
1#include <game/bases/d_a_remo_door.hpp>
2#include <game/bases/d_a_player_manager.hpp>
3#include <game/bases/d_game_key.hpp>
6
7ACTOR_PROFILE(REMO_DOOR, daRemoDoor_c, 2);
8
9STATE_DEFINE(daRemoDoor_c, OpenReady);
12
14 mAllocator.createFrmHeap(-1, mHeap::g_gameHeaps[0], nullptr, 0x20);
15 const char *fileName = "g3d/obj_door.brres";
16 mRes = dResMng_c::m_instance->mRes.getRes("obj_door", fileName);
17 nw4r::g3d::ResMdl mdl = mRes.GetResMdl("obj_doorA");
18 mDoorModel.create(mdl, &mAllocator, 0x20, 1, nullptr);
20 mAllocator.adjustFrmHeap();
21}
22
24 init();
25 mScale.z = 1.0f;
26 mScale.x = 1.5f;
27 mScale.y = 5.0f / 3.0f;
28 mPos.z = 5500.0f;
29 mVisibleAreaOffset.x = 0.0f;
30 mVisibleAreaOffset.y = 40.0f;
31 mVisibleAreaSize.x = 96.0f;
32 mVisibleAreaSize.y = 80.0f;
33 mStateMgr.changeState(StateID_OpenReady);
34 return SUCCEEDED;
35}
36
39 return SUCCEEDED;
40 }
41 mStateMgr.executeState();
42 return SUCCEEDED;
43}
44
46 mMatrix.trans(mPos.x, mPos.y, mPos.z);
47 mMatrix.YrotM(mAngle.y);
48 mMtx_c transposeMtx;
49 transposeMtx.trans(-24.0f, 0.0f, 0.0f);
50 PSMTXConcat(mMatrix, transposeMtx, mMatrix);
51 mDoorModel.setLocalMtx(&mMatrix);
52 mDoorModel.setScale(mScale);
53 mDoorModel.entry();
54 return SUCCEEDED;
55}
56
57void daRemoDoor_c::initializeState_OpenReady() {}
58void daRemoDoor_c::finalizeState_OpenReady() {}
59void daRemoDoor_c::executeState_OpenReady() {
60 // [Oversight: the player number check never fails]
61 if (daPyMng_c::mCtrlPlrNo < 4 && dGameKey_c::m_instance->getAccVerticalAngleX(daPyMng_c::mCtrlPlrNo) >= 0x2000) {
62 mStateMgr.changeState(StateID_Open);
63 }
64}
65
66void daRemoDoor_c::initializeState_Open() {
67 dAudio::SoundEffectID_t(SOUND_OPEN).playMapSound(mPos, 0);
68}
69
70void daRemoDoor_c::finalizeState_Open() {}
71
72void daRemoDoor_c::executeState_Open() {
73 short newAngle = mAngle.y;
74 newAngle += 0x400;
75 if (newAngle < 0) {
76 newAngle = -0x8000;
77 }
78 mAngle.y = newAngle;
79
80 // [Oversight: the player number check never fails]
81 if (mAngle.y == mAng(-0x8000) && daPyMng_c::mCtrlPlrNo < 4 &&
82 dGameKey_c::m_instance->getAccVerticalAngleX(daPyMng_c::mCtrlPlrNo) <= 0x1000) {
83 mStateMgr.changeState(StateID_Close);
84 }
85}
86
87void daRemoDoor_c::initializeState_Close() {}
88
89void daRemoDoor_c::finalizeState_Close() {
90 dAudio::SoundEffectID_t(SOUND_CLOSE).playMapSound(mPos, 0);
91}
92
93void daRemoDoor_c::executeState_Close() {
94 short newAngle = mAngle.y;
95 newAngle -= 0x400;
96 if (newAngle < 0) {
97 newAngle = 0;
98 }
99 mAngle.y = newAngle;
100 if (mAngle.y == mAng(0)) {
101 mStateMgr.changeState(StateID_OpenReady);
102 }
103}
104
105const int daRemoDoor_c::SOUND_CLOSE = SE_OBJ_DOOR_CLOSE;
106const int daRemoDoor_c::SOUND_OPEN = SE_OBJ_DOOR_OPEN;
sFStateMgr_c< dActorState_c, sStateMethodUsr_FI_c > mStateMgr
The state manager.
static void setSoftLight_MapObj(m3d::bmdl_c &mdl)
Sets the soft light effect for map objects.
Definition d_actor.cpp:334
@ SKIP_NONE
No checks are skipped.
Definition d_actor.hpp:75
mVec2_c mVisibleAreaSize
The size of the area inside which the actor is visible.
Definition d_actor.hpp:348
bool ActorScrOutCheck(u16 flags)
Checks if the actor is out of gameplay and optionally deletes it.
Definition d_actor.cpp:412
mVec2_c mVisibleAreaOffset
The offset applied to the area size.
Definition d_actor.hpp:349
mMtx_c mMatrix
The actor's partial transformation matrix. See makeMtx for details.
mVec3_c mScale
The actor's scale (defaults to 1).
mVec3_c mPos
The actor's position.
mAng3_c mAngle
The actor's rotation (for 2D actors).
static dResMng_c * m_instance
The instance of this class.
Definition d_res_mng.hpp:47
A door that can be opened by tilting the Wii Remote.
static sFStateID_c< daRemoDoor_c > StateID_OpenReady
The door is ready to be opened.
static const int SOUND_OPEN
The sound effect played when the door is opened.
static sFStateID_c< daRemoDoor_c > StateID_Close
The door is closing.
nw4r::g3d::ResFile mRes
The resource file.
virtual int create()
do method for the create operation.
static sFStateID_c< daRemoDoor_c > StateID_Open
The door is opening or has been opened.
virtual int draw()
do method for the draw operation.
virtual int execute()
do method for the execute operation.
dHeapAllocator_c mAllocator
The allocator.
static const int SOUND_CLOSE
The sound effect played when the door is closed.
m3d::mdl_c mDoorModel
The door model.
void init()
Initializes the resources for the actor.
@ SUCCEEDED
The step was completed successfully.
Definition f_base.hpp:40
A 3x4 matrix.
Definition m_mtx.hpp:11
void PSMTXConcat(const Mtx *a, const Mtx *b, Mtx *out)
Concatenates two matrices.
#define ACTOR_PROFILE(profName, className, properties)
Creates an actor profile, using the profile number as the execute and draw order value.
Definition f_profile.hpp:29
#define STATE_DEFINE(class, name)
Defines a state.
Definition s_State.hpp:32