SMG-Decomp
A decompilation of Super Mario Galaxy 1
Loading...
Searching...
No Matches
HipDropMoveObj.cpp
1#include "Game/MapObj/HipDropMoveObj.hpp"
2#include "Game/MapObj/StageEffectDataTable.hpp"
3#include "Game/Util.hpp"
4
5HipDropDemoMoveObj::~HipDropDemoMoveObj() {
6
7}
8
9HipDropMoveObj::HipDropMoveObj(const char *pName) : LiveActor(pName) {
10 mObjectName = 0;
11}
12
14 MR::initDefaultPos(this, rIter);
15 MR::getObjectName(&mObjectName, rIter);
16 initModelManagerWithAnm(mObjectName, 0, false);
17 MR::connectToSceneMapObj(this);
18 initEffectKeeper(0, 0, false);
19 initSound(4, false);
20 initHitSensor(1);
21 TVec3f sensor;
22 sensor.x = 0.0f;
23 sensor.y = 0.0f;
24 sensor.z = 0.0f;
25 HitSensor* jointSensor = MR::addHitSensorAtJointMapObj(this, "body", cSwitchJointName, 0, 225.0f, sensor);
26 MtxPtr mtx = MR::getJointMtx(this, cMoveJointName);
27 MR::initCollisionParts(this, mObjectName, jointSensor, mtx);
28 MR::setClippingTypeSphereContainsModelBoundingBox(this, 100.0f);
29 MR::setGroupClipping(this, rIter, 8);
30 MR::useStageSwitchWriteA(this, rIter);
31 initNerve(&NrvHipDropMoveObj::HostTypeWait::sInstance);
32 MR::tryRegisterDemoCast(this, rIter);
33 makeActorAppeared();
34}
35
36bool HipDropMoveObj::receiveMsgPlayerAttack(u32 msg, HitSensor *a2, HitSensor *a3) {
37 if (MR::isMsgPlayerHipDropFloor(msg)) {
38 if (!isNerve(&NrvHipDropMoveObj::HostTypeWait::sInstance)) {
39 return 0;
40 }
41 else {
42 f32 radius = a3->mRadius;
43 f32 dist = MR::calcDistanceToPlayer(a3->mPosition);
44 if (radius < dist) {
45 return 0;
46 }
47
48 setNerve(&NrvHipDropMoveObj::HostTypeMove::sInstance);
49 return 1;
50 }
51 }
52
53 return 0;
54}
55
56bool HipDropMoveObj::isEndMove() const {
57 return MR::isBckStopped(this);
58}
59
60void HipDropMoveObj::exeMove() {
61 if (MR::isFirstStep(this)) {
62 MR::startAllAnim(this, cMoveAnimName);
63 const char* startSe = MR::StageEffect::getStartSe(mObjectName);
64
65 if (startSe) {
66 MR::startSound(this, startSe, -1, -1);
67 }
68
69 MR::StageEffect::rumblePadStart(this, mObjectName);
70 MR::StageEffect::shakeCameraMoving(this, mObjectName);
71 MR::tryStartDemoRegistered(this, 0);
72 moveStart();
73 }
74
75 s32 steps = MR::StageEffect::getStopSeSteps(mObjectName);
76 const char* movingSe = MR::StageEffect::getMovingSe(mObjectName);
77
78 if (movingSe) {
79 if (steps >= 0) {
80 if (MR::isLessStep(this, steps)) {
81 MR::startLevelSound(this, movingSe, -1, -1, -1);
82 }
83 }
84 else {
85 MR::startLevelSound(this, movingSe, -1, -1, -1);
86 }
87 }
88
89 if (steps >= 0) {
90 if (MR::isStep(this, steps)) {
91 const char* stopSe = MR::StageEffect::getStopSe(mObjectName);
92
93 if (stopSe) {
94 MR::startSound(this, stopSe, -1, -1);
95 }
96
97 if (MR::StageEffect::isRiddleSeTypeStop(mObjectName)) {
98 MR::startSystemSE("SE_SY_READ_RIDDLE_S", -1, -1);
99 }
100 }
101 }
102
103 moving();
104
105 if (isEndMove()) {
106 if (MR::isValidSwitchA(this)) {
107 MR::onSwitchA(this);
108 }
109
110 MR::StageEffect::rumblePadStop(this, mObjectName);
111 MR::StageEffect::stopShakingCameraMoving(this, mObjectName);
112
113 if (steps < 0) {
114 const char* stopSe = MR::StageEffect::getStopSe(mObjectName);
115
116 if (stopSe) {
117 MR::startSound(this, stopSe, -1, -1);
118 }
119 }
120
121 moveEnd();
122 setNerve(&NrvHipDropMoveObj::HostTypeDone::sInstance);
123 }
124}
125
126HipDropDemoMoveObj::HipDropDemoMoveObj(const char *pName) : HipDropMoveObj(pName) {
127 mMtx.identity();
128}
129
130HipDropMoveObj::~HipDropMoveObj() {
131
132}
133
134void HipDropDemoMoveObj::moveStart() {
135 MR::startBckPlayer("Wait", (char*)nullptr);
136 MtxPtr mtx = MR::getPlayerDemoActor()->getBaseMtx();
137 TMtx34f stack_38;
138 stack_38.set(mtx);
139 MtxPtr jointMtx = MR::getJointMtx(this, cMoveJointName);
140 TMtx34f stack_8;
141 stack_8.set(jointMtx);
142 stack_8.invert(stack_8);
143 mMtx.concat(stack_8, stack_38);
144}
145
146void HipDropDemoMoveObj::moving() {
147 if (MR::isDemoActive()) {
148 MtxPtr jointMtx = MR::getJointMtx(this, cMoveJointName);
149 TMtx34f stack_8;
150 stack_8.set(jointMtx);
151 stack_8.concat(stack_8, mMtx);
152 TVec3f vec;
153 LiveActor* demoActor = MR::getPlayerDemoActor();
154 f32 z = stack_8.mMtx[2][3];
155 f32 y = stack_8.mMtx[1][3];
156 f32 x = stack_8.mMtx[0][3];
157 demoActor->mPosition.set(x, y, z);
158 MR::setPlayerBaseMtx((MtxPtr)&stack_8);
159 }
160}
161
162namespace NrvHipDropMoveObj {
163 HostTypeWait HostTypeWait::sInstance;
164 HostTypeMove HostTypeMove::sInstance;
165 HostTypeDone HostTypeDone::sInstance;
166
167 void HostTypeDone::execute(Spine* pSpine) const {
168
169 }
170
171 void HostTypeMove::execute(Spine *pSpine) const {
172 HipDropMoveObj* obj = reinterpret_cast<HipDropMoveObj*>(pSpine->mExecutor);
173 obj->exeMove();
174 }
175
176 void HostTypeWait::execute(Spine* pSpine) const {
177
178 }
179};
180
181void HipDropMoveObj::moveStart() {
182
183}
184
185void HipDropMoveObj::moving() {
186
187}
188
189void HipDropMoveObj::moveEnd() {
190
191}
virtual void init(const JMapInfoIter &)
Intializes the NameObj and can set various settings and construct necessary classes.
The basis of a drawable actor that can contain states (see: Nerve)
Definition LiveActor.hpp:24
TVec3f mPosition
3D vector of the actor's position.
Definition LiveActor.hpp:95
virtual MtxPtr getBaseMtx() const
Gets the base matrix of the model used for the actor.
Definition Spine.hpp:9