SMG-Decomp
A decompilation of Super Mario Galaxy 1
Loading...
Searching...
No Matches
SpaceMine.cpp
1#include "Game/MapObj/SpaceMine.hpp"
2
3SpaceMine::SpaceMine(const char *pName) : MapObjActor(pName), mClippingRange(gZeroVec) {
4 _C4 = 1.0f;
5 _D4 = -1;
6 _D8 = 0;
7}
8
9void SpaceMine::init(const JMapInfoIter &rIter) {
10 MapObjActor::init(rIter);
12 info.setupHioNode("地形オブジェ");
13 info.setupDefaultPos();
14 info.setupConnectToScene();
15 info.setupEffect(nullptr);
16 info.setupSound(2);
17 info.setupNerve(&NrvSpaceMine::HostTypeWait::sInstance);
18 info.setupRailMover();
19 info.setupHitSensor();
20 TVec3f sensorOffs;
21 sensorOffs.x = 0.0f;
22 sensorOffs.y = 0.0f;
23 sensorOffs.z = 0.0f;
24 info.setupHitSensorParam(8, 100.0f, sensorOffs);
25 info.setupGroupClipping(0x10);
26 MR::getJMapInfoArg0NoInit(rIter, &_D4);
27
28 bool isValid = isShadowValid(_D4);
29
30 if (isValid) {
31 info.setupShadow(nullptr);
32 }
33
34 s32 arg1 = -1;
35 MR::getJMapInfoArg1NoInit(rIter, &arg1);
36
37 if (arg1 != -1) {
38 info.setupBinder(100.0f, 0.0f);
39 }
40
41 initialize(rIter, info);
42 if (isCalcShadowAlways()) {
43 MR::onCalcShadow(this, nullptr);
44 MR::onCalcShadowDropGravity(this, nullptr);
45 }
46}
47
48/*
49bool SpaceMine::isCalcShadowAlways() const {
50
51 return isShadowValid()
52
53 s32 v1 = _D4;
54 bool v2 = true;
55
56 if (v1 != 1) {
57 v2 = isShadowValid(v1) && hasRail() == false ? false : true;
58 }
59
60 return v2;
61}
62*/
63
64void SpaceMine::kill() {
65 MR::emitEffect(this, "Explosion");
66 MR::startSound(this, "SE_OJ_SPACEMINE_EXPLOSION", -1, -1);
67 MR::tryRumblePad(this, "中", 0);
68 MapObjActor::kill();
69}
70
71void SpaceMine::initAfterPlacement() {
72 bool isShadow = isShadowValid(_D4);
73
74 if (isShadow) {
75 MR::setClippingRangeIncludeShadow(this, &mClippingRange, 100.0f);
76 }
77}
78
79void SpaceMine::attackSensor(HitSensor *a1, HitSensor *a2) {
80 if (MR::sendMsgEnemyAttackExplosion(a2, a1)) {
81 kill();
82 }
83 else {
84 MR::sendMsgPush(a2, a1);
85 }
86}
87
88bool SpaceMine::receiveMsgPlayerAttack(u32 msg, HitSensor *, HitSensor *) {
89 if (MR::isMsgInvincibleAttack(msg)) {
90 kill();
91 return true;
92 }
93
94 if (MR::isMsgStarPieceAttack(msg)) {
95 kill();
96 return true;
97 }
98
99 return false;
100}
101
102void SpaceMine::exeWait() {
103 if (isCalcShadowAlways()) {
104 MR::setClippingRangeIncludeShadow(this, &mClippingRange, 100.0f);
105 }
106
107 f32 playerDist = MR::calcDistanceToPlayer(this);
108 if (_D8) {
109 if (1450.0f < playerDist) {
110 _D8 = 0;
111 _C4 = 1.0f;
112 }
113 }
114 else if (playerDist < 1500.0f) {
115 _D8 = 1;
116 _C4 = 1.0f;
117 }
118
119 if (MR::isBinded(this)) {
120 if (MR::isBindedGround(this)) {
121 MR::sendMsgEnemyAttackExplosionToBindedSensor(this, MR::getGroundSensor(this));
122 }
123
124 if (MR::isBindedWall(this)) {
125 MR::sendMsgEnemyAttackExplosionToBindedSensor(this, MR::getWallSensor(this));
126 }
127
128 if (MR::isBindedRoof(this)) {
129 MR::sendMsgEnemyAttackExplosionToBindedSensor(this, MR::getWallSensor(this));
130 }
131
132 MR::offBind(this);
133 kill();
134 }
135 else {
136 f32 v6 = MR::subtractFromSum(_C4, mRotation.y, 0.0f);
137 mRotation.y += _C4;
138 mRotation.y = MR::modAndAdd(0.0f, v6);
139 }
140}
141
142void SpaceMine::exeAppear() {
143 if (MR::isFirstStep(this)) {
144 MR::emitEffect(this, "Appear");
145 MR::setClippingRangeIncludeShadow(this, &mClippingRange, 100.0f);
146 }
147
148 MR::startLevelSound(this, "SE_OJ_LV_SPACEMINE_APPEAR", -1, -1, -1);
149
150 if (MR::isStep(this, 120)) {
151 MR::startBck(this, "Appear", nullptr);
152 MR::showModel(this);
153 MR::startSound(this, "SE_OJ_SPACEMINE_APPEAR", -1, -1);
154 }
155
156 if (MR::isGreaterStep(this, 120)) {
157 if (MR::isBckStopped(this)) {
158 setNerve(&NrvSpaceMine::HostTypeWait::sInstance);
159 }
160 }
161}
162
163SpaceMine::~SpaceMine() {
164
165}
166
167namespace NrvSpaceMine {
168 void HostTypeAppear::execute(Spine *pSpine) const {
169 SpaceMine* mine = reinterpret_cast<SpaceMine*>(pSpine->mExecutor);
170 mine->exeAppear();
171 }
172
173 void HostTypeWait::execute(Spine *pSpine) const {
174 SpaceMine* mine = reinterpret_cast<SpaceMine*>(pSpine->mExecutor);
175 mine->exeWait();
176 }
177
178 INIT_NERVE(HostTypeWait);
179 INIT_NERVE(HostTypeAppear);
180};
TVec3f mRotation
3D vector of the actor's rotation.
Definition LiveActor.hpp:96
virtual void init(const JMapInfoIter &)
Intializes the NameObj and can set various settings and construct necessary classes.
virtual void init(const JMapInfoIter &)
Intializes the NameObj and can set various settings and construct necessary classes.
Definition SpaceMine.cpp:9
Definition Spine.hpp:9