NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
d_a_wm_peach_castle.cpp
1#include <game/bases/d_a_wm_peach_castle.hpp>
2#include <game/bases/d_a_wm_player.hpp>
3#include <game/bases/d_a_wm_map.hpp>
4#include <game/bases/d_cs_seq_manager.hpp>
5#include <game/bases/d_info.hpp>
7#include <game/bases/d_save_mng.hpp>
8#include <game/bases/d_unk_anim_class.hpp>
9#include <game/bases/d_wm_lib.hpp>
10#include <game/bases/d_wm_se_manager.hpp>
11
12ACTOR_PROFILE(WM_PEACH_CASTLE, daWmPeachCastle_c, 0);
13
16
19 calcModel();
20
21 initState();
22 mClipSphere.set(mPos, 200.0f);
23
24 return SUCCEEDED;
25}
26
28 dCsSeqMng_c *csSeqMng = dCsSeqMng_c::ms_instance;
29 processCutsceneCommand(csSeqMng->GetCutName(), csSeqMng->m_164);
30
31 daWmMap_c::m_instance->GetNodePos(mResNodeIdx, mPos);
32 calcModel();
33
34 for (int i = 0; i < ANIM_COUNT; i++) {
35 mChrAnim[i].play();
36 }
37
38 return SUCCEEDED;
39}
40
42 mModel.entry();
43 return SUCCEEDED;
44}
45
48 mModel.setAnm(mChrBlendAnim);
49 initUnk();
51 dCsSeqMng_c::ms_instance->FUN_801017c0(dCsSeqMng_c::SMC_DEMO_CASTLE_CLR, this, daWmPlayer_c::ms_instance, 200);
52 }
53}
54
58
62
64 mAllocator.createFrmHeap(-1, mHeap::g_gameHeaps[mHeap::GAME_HEAP_DEFAULT], nullptr, 0x20);
65 mResFile = dResMng_c::m_instance->getRes("cobPeachCastle", "g3d/model.brres");
66
67 nw4r::g3d::ResMdl resMdl = mResFile.GetResMdl("cobPeachCastle");
68 mModel.create(resMdl, &mAllocator, nw4r::g3d::ScnMdl::BUFFER_RESMATMISC);
69
70 static const char *resAnmNames[ANIM_COUNT] = {
71 "cobPeachCastleFlag",
72 "cobPeachCastleOpen",
73 "cobPeachCastleClose"
74 };
75
76 static const m3d::playMode_e playModes[ANIM_COUNT] = {
80 };
81
82 for (int i = 0; i < ANIM_COUNT; i++) {
83 nw4r::g3d::ResAnmChr resAnmChr = mResFile.GetResAnmChr(resAnmNames[i]);
84 mChrAnim[i].create(resMdl, resAnmChr, &mAllocator, nullptr);
85 mChrAnim[i].mPlayMode = playModes[i];
86 mChrAnim[i].setRate(0.0f);
87 mChrAnim[i].setFrame(0.0f);
88 }
89
90 mChrBlendAnim.create(resMdl, 8, &mAllocator, nullptr);
92 mAllocator.adjustFrmHeap();
93}
94
96 mVec3_c pos = mPos;
97 mAng3_c angle = mAngle;
98 mMatrix.trans(pos);
99 mMatrix.ZXYrotM(angle);
100 mModel.setLocalMtx(&mMatrix);
101 mModel.setScale(mScale);
102 mModel.calc(false);
103}
104
105void daWmPeachCastle_c::processCutsceneCommand(int cutsceneCommandId, bool isFirstFrame) {
106 if (cutsceneCommandId == dCsSeqMng_c::CUTSCENE_CMD_NONE) {
107 return;
108 }
109
110 if (!isStaff()) {
111 mIsCutEnd = true;
112 return;
113 }
114
115 if (isFirstFrame) {
116 switch (cutsceneCommandId) {
117 case dCsSeqMng_c::CUTSCENE_CMD_17:
118 case dCsSeqMng_c::CUTSCENE_CMD_19:
120 mChrAnim[cobPeachCastleOpen].setFrame(0.0f);
121 mChrAnim[cobPeachCastleOpen].setRate(2.4f);
122 dWmSeManager_c::m_pInstance->playSound(dWmSeManager_c::WM_SE_OBJ_CS_DOOR_OPEN_PEACH, mPos, 1);
123 break;
124
125 case dCsSeqMng_c::CUTSCENE_CMD_78:
127
128 case dCsSeqMng_c::CUTSCENE_CMD_20:
130 mChrAnim[cobPeachCastleClose].setFrame(0.0f);
131 mChrAnim[cobPeachCastleClose].setRate(1.0f);
132 dWmSeManager_c::m_pInstance->playSound(dWmSeManager_c::WM_SE_OBJ_CS_DOOR_CLOSE_PEACH, mPos, 1);
133 break;
134
135 default:
136 break;
137 }
138 }
139
140 switch (cutsceneCommandId) {
141 case dCsSeqMng_c::CUTSCENE_CMD_17:
142 case dCsSeqMng_c::CUTSCENE_CMD_19:
143 if (mChrAnim[cobPeachCastleOpen].isStop()) {
144 mIsCutEnd = true;
145 }
146 break;
147
148 case dCsSeqMng_c::CUTSCENE_CMD_78:
149 case dCsSeqMng_c::CUTSCENE_CMD_20:
150 if (mChrAnim[cobPeachCastleClose].isStop()) {
151 mIsCutEnd = true;
152 }
153 break;
154
155 default:
156 mIsCutEnd = true;
157 break;
158 }
159}
160
162 static const char *nodeNames[] = {
163 "FlagA0", "FlagA1", "FlagA2",
164 "FlagB0", "FlagB1", "FlagB2",
165 "FlagC0", "FlagC1", "FlagC2",
166 "FlagD0", "FlagD1", "FlagD2",
167 "FlagE0", "FlagE1", "FlagE2",
168 };
169
170 dUnkAnimClass_c::ReleaseAnim(mChrAnim[cobPeachCastleFlag]);
171 dUnkAnimClass_c::BindNodesByName(mModel, mChrAnim[cobPeachCastleFlag], ARRAY_SIZE(nodeNames), nodeNames, nw4r::g3d::AnmObjChr::BIND_ONE);
172 mChrAnim[cobPeachCastleFlag].setRate(1.0f);
173 mChrBlendAnim.attach(0, &mChrAnim[cobPeachCastleFlag], 1.0f);
174}
175
177 "LeftDoor",
178 "RightDoor"
179};
180
182 dUnkAnimClass_c::ReleaseAnim(mChrAnim[cobPeachCastleOpen]);
183 dUnkAnimClass_c::BindNodesByName(mModel, mChrAnim[cobPeachCastleOpen], ARRAY_SIZE(smc_doorNodeNames), smc_doorNodeNames, nw4r::g3d::AnmObjChr::BIND_ONE);
184 mChrAnim[cobPeachCastleOpen].setRate(0.0f);
185 mChrAnim[cobPeachCastleOpen].setFrame(0.0f);
186 mChrBlendAnim.attach(1, &mChrAnim[cobPeachCastleOpen], 1.0f);
187}
188
190 dUnkAnimClass_c::ReleaseAnim(mChrAnim[cobPeachCastleClose]);
191 dUnkAnimClass_c::BindNodesByName(mModel, mChrAnim[cobPeachCastleClose], ARRAY_SIZE(smc_doorNodeNames), smc_doorNodeNames, nw4r::g3d::AnmObjChr::BIND_ONE);
192 mChrAnim[cobPeachCastleClose].setRate(0.0f);
193 mChrAnim[cobPeachCastleClose].setFrame(0.0f);
194 mChrBlendAnim.attach(1, &mChrAnim[cobPeachCastleClose], 1.0f);
195}
196
198 if (!IsCourseClear()) {
199 dMj2dGame_c *save = dSaveMng_c::m_instance->getSaveGame(-1);
200 save->onCourseDataFlag(WORLD_1, STAGE_PEACH_CASTLE, dMj2dGame_c::GOAL_NORMAL);
201 dInfo_c::m_instance->m_60 = 2;
202 }
203}
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).
Represents the slot-specific save data for the game.
void onCourseDataFlag(int world, int level, ulong flag)
Sets the completion flag(s) for the given world/level. See COURSE_COMPLETION_e.
@ GOAL_NORMAL
The regular exit was cleared.
static dResMng_c * m_instance
The instance of this class.
Definition d_res_mng.hpp:61
static void setSoftLight_MapObj(m3d::bmdl_c &mdl)
Sets the soft light effect for map objects.
mSphere_c mClipSphere
A sphere representing the actor's visible area.
int mResNodeIdx
The index of the model's root resource node.
int GetCurrentPlayResultStatus()
The actor for Peach's Castle found on the World Map.
dHeapAllocator_c mAllocator
The allocator.
@ cobPeachCastleOpen
The door open animation.
@ cobPeachCastleFlag
The flag animation.
@ cobPeachCastleClose
The door close animation.
void ensureCourseClear()
Ensures the course associated to the actor is cleared.
daWmPeachCastle_c()
Constructs a new object.
virtual int execute()
do method for the execute operation.
nw4r::g3d::ResFile mResFile
The resource file.
void initState()
Sets up the actor's initial state.
void calcModel()
Updates the model's transformation matrix.
virtual void processCutsceneCommand(int cutsceneCommandId, bool isFirstFrame)
Contains the actor-specific logic for processing the current world map cutscene.
~daWmPeachCastle_c()
Destroys the object.
void initDoorCloseAnim()
Initializes the door close animation.
static const char * smc_doorNodeNames[]
The node names for the door open/close animations.
m3d::anmChrBlend_c mChrBlendAnim
The blended animation.
void initDoorOpenAnim()
Initializes the door open animation.
virtual int doDelete()
do method for the delete operation.
void initUnk()
Initializes mUnk2B8.
virtual int create()
do method for the create operation.
virtual int draw()
do method for the draw operation.
void initFlagAnim()
Initializes the flag animation.
m3d::anmChr_c mChrAnim[ANIM_COUNT]
The model animations.
m3d::mdl_c mModel
The model.
void createModel()
Initializes the resources for the actor.
@ SUCCEEDED
The step was completed successfully.
Definition f_base.hpp:46
A three-dimensional short angle vector.
Definition m_angle.hpp:68
A three-dimensional floating point vector.
Definition m_vec.hpp:122
#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
playMode_e
Definition banm.hpp:7
@ FORWARD_ONCE
Play the animation forward once.
Definition banm.hpp:9
@ FORWARD_LOOP
Play the animation forward in a loop.
Definition banm.hpp:8
@ GAME_HEAP_DEFAULT
The default game heap (alias of MEM1 or MEM2).
Definition m_heap.hpp:38
EGG::ExpHeap * g_gameHeaps[GAME_HEAP_COUNT]
The game heaps.
Definition m_heap.cpp:13