SMG-Decomp
A decompilation of Super Mario Galaxy 1
Loading...
Searching...
No Matches
CoinSpot.cpp
1#include "Game/MapObj/CoinSpot.hpp"
2
3CoinSpot::CoinSpot(const char *pName) : LiveActor(pName) {
4 _8C = 8;
5 _90 = 0;
6 _94 = 4;
7 _98 = 0;
8}
9
10void CoinSpot::init(const JMapInfoIter &rIter) {
11 MR::connectToSceneMapObjMovementCalcAnim(this);
12 MR::initDefaultPos(this, rIter);
13 s32 arg = 0;
14 MR::getJMapInfoArg0NoInit(rIter, &arg);
15
16 if (arg <= 0) {
17 _8C = arg;
18 }
19 else {
20 _8C = 8;
21 }
22
23 initSound(4, false);
24 initSensor();
25 initNerve(&NrvCoinSpot::CoinSpotNrvWait::sInstance);
26 appear();
27}
28
29void CoinSpot::initSensor() {
30 f32 scale_y = mScale.y;
31 initHitSensor(1);
32 TVec3f offs;
33 offs.x = 0.0f;
34 offs.y = 60.0f * scale_y;
35 offs.z = 0.0f;
36 MR::addHitSensorMapObj(this, "body", 32, offs.y, offs);
37}
38
39void CoinSpot::exeWait() {
40 if (MR::isFirstStep(this)) {
41 _94 = 0;
42 _98 = 0;
43 _90 = 0;
44 }
45
46 if (_90 == 1) {
47 setNerve(&NrvCoinSpot::CoinSpotNrvIsInTornado::sInstance);
48 }
49}
50
51void CoinSpot::exeIsInTornado() {
52 if (MR::isFirstStep(this)) {
53 _94 = 0;
54 _98 = 0;
55 }
56
57 if (_90) {
58 s32 v2 = _94;
59 _94 = v2 - 1;
60
61 if (v2 - 1 <= 0) {
62 MR::appearCoinFix(this, mPosition, 1);
63 _94 = 4;
64 _98 = _98 + 1;
65 }
66
67 _90 = 0;
68 }
69 else {
70 _94 = 0;
71 }
72
73 if (_98 >= _8C || MR::isGreaterStep(this, 180)) {
74 MR::deleteEffect(this, "光");
75 kill();
76 }
77}
78
79void CoinSpot::attackSensor(HitSensor *, HitSensor *) {
80
81}
82
83CoinSpot::~CoinSpot() {
84
85}
86
87namespace NrvCoinSpot {
88 INIT_NERVE(CoinSpotNrvWait);
89 INIT_NERVE(CoinSpotNrvIsInTornado);
90
91 void CoinSpotNrvIsInTornado::execute(Spine *pSpine) const {
92 CoinSpot* spot = reinterpret_cast<CoinSpot*>(pSpine->mExecutor);
93 spot->exeIsInTornado();
94 }
95
96 void CoinSpotNrvWait::execute(Spine *pSpine) const {
97 CoinSpot* spot = reinterpret_cast<CoinSpot*>(pSpine->mExecutor);
98 spot->exeWait();
99 }
100};
virtual void init(const JMapInfoIter &)
Intializes the NameObj and can set various settings and construct necessary classes.
Definition CoinSpot.cpp:10
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
TVec3f mScale
3D vector of the actor's scale.
Definition LiveActor.hpp:97
Definition Spine.hpp:9