SMG-Decomp
A decompilation of Super Mario Galaxy 1
Loading...
Searching...
No Matches
TreasureSpot.cpp
1#include "Game/MapObj/TreasureSpot.hpp"
2#include "Game/Util.hpp"
3
4TreasureSpot::TreasureSpot(const char *pName) : MapObjActor(pName) {
5 mIsCoinFlower = false;
6}
7
8void TreasureSpot::init(const JMapInfoIter &rIter) {
11 MapObjActorUtil::setupInitInfoSimpleMapObj(&info);
12 info.setupHitSensor();
13 info.setupHitSensorParam(4, 80.0f, TVec3f(0.0f, 3.0f, 0.0f));
14 info.setupNerve(&NrvTreasureSpot::TreasureSpotNrvWait::sInstance);
15 info.setupSound(4);
16 MapObjActor::initialize(rIter, info);
17 mIsCoinFlower = isObjectName("CoinFlower");
18 MR::initStarPointerTarget(this, 100.0f, TVec3f(0.0f, 50.0f, 0.0f));
19 MR::declareCoin(this, 1);
20}
21
22void TreasureSpot::exeSpout() {
23 if (MR::isFirstStep(this)) {
24 MR::forceDeleteEffectAll(this);
25 TVec3f upVec;
26 MR::calcUpVec(&upVec, this);
27 MR::appearCoinPopToDirection(this, mPosition, upVec, 1);
28
29 if (mIsCoinFlower) {
30 MR::startBck(this, "Bloom", 0);
31 MR::startSound(this, "SE_OJ_COIN_FLOWER_BLOOM", -1, -1);
32 }
33 else {
34 setNerve(&NrvTreasureSpot::TreasureSpotNrvEnd::sInstance);
35 kill();
36 return;
37 }
38 }
39
40 if (mIsCoinFlower) {
41 if (MR::isBckStopped(this)) {
42 setNerve(&NrvTreasureSpot::TreasureSpotNrvEnd::sInstance);
43 }
44 }
45}
46
47void TreasureSpot::control() {
48 if (!isNerve(&NrvTreasureSpot::TreasureSpotNrvSpout::sInstance) && !isNerve(&NrvTreasureSpot::TreasureSpotNrvEnd::sInstance)) {
49 switchEmitGlow();
50 }
51}
52
53bool TreasureSpot::receiveMsgPlayerAttack(u32 msg, HitSensor *a2, HitSensor *a3) {
54 if (isNerve(&NrvTreasureSpot::TreasureSpotNrvSpout::sInstance)) {
55 return 0;
56 }
57
58 if (isNerve(&NrvTreasureSpot::TreasureSpotNrvEnd::sInstance)) {
59 return 0;
60 }
61
62 if (!MR::isNearPlayerAnyTime(this, 2000.0f)) {
63 return 0;
64 }
65
66 if (MR::isMsgLockOnStarPieceShoot(msg)) {
67 return 1;
68 }
69
70 if (MR::isMsgStarPieceAttack(msg)) {
71 setNerve(&NrvTreasureSpot::TreasureSpotNrvSpout::sInstance);
72 return 1;
73 }
74
75 return 0;
76}
77
78void TreasureSpot::switchEmitGlow() {
79 if (!MR::isNearPlayerAnyTime(this, 2000.0f)) {
80 MR::deleteEffect(this, "Glow");
81 }
82 else {
83 if (MR::isNearPlayerAnyTime(this, 2000.0f)) {
84 if (!MR::isEffectValid(this, "Glow")) {
85 MR::emitEffect(this, "Glow");
86 }
87 }
88 }
89}
90
91TreasureSpot::~TreasureSpot() {
92
93}
94
95namespace NrvTreasureSpot {
96 INIT_NERVE(TreasureSpotNrvWait);
97 INIT_NERVE(TreasureSpotNrvEnd);
98 INIT_NERVE(TreasureSpotNrvSpout);
99
100 void TreasureSpotNrvSpout::execute(Spine *pSpine) const {
101 TreasureSpot* spot = reinterpret_cast<TreasureSpot*>(pSpine->mExecutor);
102 spot->exeSpout();
103 }
104
105 void TreasureSpotNrvEnd::execute(Spine *pSpine) const {
106
107 }
108
109 void TreasureSpotNrvWait::execute(Spine *pSpine) const {
110
111 }
112};
TVec3f mPosition
3D vector of the actor's position.
Definition LiveActor.hpp:95
virtual void init(const JMapInfoIter &)
Intializes the NameObj and can set various settings and construct necessary classes.
Definition Spine.hpp:9
virtual void init(const JMapInfoIter &)
Intializes the NameObj and can set various settings and construct necessary classes.