NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
d_awa.cpp
1#include <game/bases/d_awa.hpp>
2#include <game/bases/d_bg.hpp>
4#include <game/mLib/m_allocator_dummy_heap.hpp>
5
6ACTOR_PROFILE(AWA, dAwa_c, 2);
7
9
10 // [There are a few float constants that must appear here.]
11 static const float DUMMY_ORDERING[] = { 0.1f, 2.0f };
12 static const dAwa_c::CalcSpeed Proc_tbl[] = {
17 };
18
20 setAnim();
21
22 mScale.set(1.0f, 1.0f, 1.0f);
23 mSpeed.set(0.0f, 0.0f, 0.0f);
24 mCalcSpeedFn = Proc_tbl[ACTOR_PARAM(Direction)];
25
26 return SUCCEEDED;
27}
28
30 mAllocator.createFrmHeap(0x80000, mHeap::g_gameHeaps[0], nullptr, 0x20);
31 mResFile = dResMng_c::m_instance->getRes("waterbubble", "g3d/waterbubble.brres");
32
33 nw4r::g3d::ResMdl model = mResFile.GetResMdl("waterbubble");
34 mBubbleModel.create(model, &mAllocator, nw4r::g3d::ScnMdl::BUFFER_RESMATMISC, 1, nullptr);
36
37 nw4r::g3d::ResAnmChr anim = mResFile.GetResAnmChr("waterbubble");
38 mBubbleAnim.create(model, anim, &mAllocator, nullptr);
39 mAllocator.adjustFrmHeap();
40}
41
43 mLifeTimer--;
44
45 if (mLifeTimer == 0 || mPos.y >= dBg_c::m_bg_p->getLiquidHeight()) {
47 } else {
48 calc();
49 }
50
51 return SUCCEEDED;
52}
53
55 mVec3_c pos = mPos;
56 changePosAngle(&pos, nullptr, 1);
57
58 mMatrix.trans(pos.x, pos.y, pos.z);
59 mBubbleModel.setLocalMtx(&mMatrix);
60
61 mBubbleModel.setScale(mScale);
62 mBubbleModel.calc(false);
63 mBubbleModel.entry();
64 return SUCCEEDED;
65}
66
68
70 if (mAllocator.mpHeap != mAllocatorDummyHeap_c::getInstance()) {
71 mBubbleAnim.remove();
72 mBubbleModel.remove();
73 }
74
75 return SUCCEEDED;
76}
77
79 nw4r::g3d::ResAnmChr anim = mResFile.GetResAnmChr("waterbubble");
81 mBubbleModel.setAnm(mBubbleAnim, 0.0f);
82 mBubbleAnim.setRate(1.0f);
83}
84
86 mBubbleModel.play();
87 (this->*mCalcSpeedFn)();
88 posMove();
89}
90
92 mSpeed.y += 0.1f;
93 if (mSpeed.y > 2.0f) {
94 mSpeed.y = 2.0f;
95 }
96}
97
99 mSpeed.y -= 0.1f;
100 if (mSpeed.y < -2.0f) {
101 mSpeed.y = -2.0f;
102 }
103}
104
106 mSpeed.x += 0.1f;
107 if (mSpeed.x > 2.0f) {
108 mSpeed.x = 2.0f;
109 }
110}
111
113 mSpeed.x -= 0.1f;
114 if (mSpeed.x > -2.0f) {
115 mSpeed.x = -2.0f;
116 }
117}
static void setSoftLight_MapObj(m3d::bmdl_c &mdl)
Sets the soft light effect for map objects.
Definition d_actor.cpp:333
static void changePosAngle(mVec3_c *pos, mAng3_c *ang, int param3)
Adjusts the actor's position to account for looping stages.
Definition d_actor.cpp:297
An early version of the unused water bubble, without collision.
Definition d_awa.hpp:12
nw4r::g3d::ResFile mResFile
The resource file.
Definition d_awa.hpp:35
void createModel()
Initializes the resources for the actor.
Definition d_awa.cpp:29
void(dAwa_c::* CalcSpeed)()
The speed update function.
Definition d_awa.hpp:14
m3d::anmChr_c mBubbleAnim
The bubble animation.
Definition d_awa.hpp:37
virtual void deleteReady()
Informs the base that it's about to be deleted.
Definition d_awa.cpp:67
void setAnim()
Initializes the model animation.
Definition d_awa.cpp:78
dHeapAllocator_c mAllocator
The allocator.
Definition d_awa.hpp:34
int mLifeTimer
The amount of frames left before the bubble is deleted.
Definition d_awa.hpp:39
virtual int execute()
do method for the execute operation.
Definition d_awa.cpp:42
void calcSpeedDown()
Updates the bubble's speed (downwards direction).
Definition d_awa.cpp:98
virtual int draw()
do method for the draw operation.
Definition d_awa.cpp:54
void calcSpeedRight()
Updates the bubble's speed (rightwards direction).
Definition d_awa.cpp:105
void calc()
Updates the bubble's position and speed.
Definition d_awa.cpp:85
m3d::mdl_c mBubbleModel
The bubble model.
Definition d_awa.hpp:36
void calcSpeedUp()
Updates the bubble's speed (upwards direction).
Definition d_awa.cpp:91
void calcSpeedLeft()
Updates the bubble's speed (leftwards direction).
Definition d_awa.cpp:112
CalcSpeed mCalcSpeedFn
The speed update function.
Definition d_awa.hpp:38
virtual int doDelete()
do method for the delete operation.
Definition d_awa.cpp:69
virtual int create()
do method for the create operation.
Definition d_awa.cpp:8
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 mSpeed
The actor's speed.
mVec3_c mPos
The actor's position.
void posMove()
Moves the actor by its speed.
static dResMng_c * m_instance
The instance of this class.
Definition d_res_mng.hpp:61
void deleteRequest()
Requests deletion of the base.
Definition f_base.cpp:289
@ SUCCEEDED
The step was completed successfully.
Definition f_base.hpp:44
A three-dimensional floating point vector.
Definition m_vec.hpp:107
#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
@ FORWARD_LOOP
Play the animation forward in a loop.
Definition banm.hpp:8