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 mAng ang(mAngle.y);
48 mMatrix.YrotM(ang);
49 mMtx_c transposeMtx;
50 transposeMtx.trans(-24.0f, 0.0f, 0.0f);
51 PSMTXConcat(mMatrix, transposeMtx, mMatrix);
52 mDoorModel.setLocalMtx(&mMatrix);
53 mDoorModel.setScale(mScale);
54 mDoorModel.entry();
55 return SUCCEEDED;
56}
57
61 // [Oversight: the player number check never fails]
62 if (daPyMng_c::mCtrlPlrNo < 4 && dGameKey_c::m_instance->getAccVerticalAngleX(daPyMng_c::mCtrlPlrNo) >= 0x2000) {
63 mStateMgr.changeState(StateID_Open);
64 }
65}
66
70
72
74 short newAngle = mAngle.y;
75 newAngle += 0x400;
76 if (newAngle < 0) {
77 newAngle = -0x8000;
78 }
79 mAngle.y = newAngle;
80
81 // [Oversight: the player number check never fails]
82 if (mAngle.y == -0x8000 && daPyMng_c::mCtrlPlrNo < 4 &&
83 dGameKey_c::m_instance->getAccVerticalAngleX(daPyMng_c::mCtrlPlrNo) <= 0x1000) {
84 mStateMgr.changeState(StateID_Close);
85 }
86}
87
89
93
95 short newAngle = mAngle.y;
96 newAngle -= 0x400;
97 if (newAngle < 0) {
98 newAngle = 0;
99 }
100 mAngle.y = newAngle;
101 if (mAngle.y == 0) {
102 mStateMgr.changeState(StateID_OpenReady);
103 }
104}
105
106const int daRemoDoor_c::SOUND_CLOSE = SE_OBJ_DOOR_CLOSE;
107const 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 state ID for the OpenReady state.
void initializeState_Close()
Initialization function for the Close state.
static const int SOUND_OPEN
The sound effect played when the door is opened.
void finalizeState_Close()
Finalization function for the Close state.
static sFStateID_c< daRemoDoor_c > StateID_Close
The state ID for the Close state.
nw4r::g3d::ResFile mRes
The resource file.
virtual int create()
do method for the create operation.
void executeState_Open()
Execution function for the Open state.
void finalizeState_OpenReady()
Finalization function for the OpenReady state.
void executeState_Close()
Execution function for the Close state.
void initializeState_Open()
Initialization function for the Open state.
void executeState_OpenReady()
Execution function for the OpenReady state.
static sFStateID_c< daRemoDoor_c > StateID_Open
The state ID for the Open state.
virtual int draw()
do method for the draw operation.
virtual int execute()
do method for the execute operation.
dHeapAllocator_c mAllocator
The allocator.
void initializeState_OpenReady()
Initialization function for the OpenReady state.
void finalizeState_Open()
Finalization function for the Open state.
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
A one-dimensional short angle vector.
Definition m_angle.hpp:8