SMG-Decomp
A decompilation of Super Mario Galaxy 1
Loading...
Searching...
No Matches
Note.cpp
1#include "Game/MapObj/Note.hpp"
2#include "Game/MapObj/NoteFairy.hpp"
3#include "Game/Scene/SceneObjHolder.hpp"
4#include "Game/Screen/NoteCounter.hpp"
5
6Note::Note(const char *pName, const TVec3f &rRailDirection, NoteFairy *pParent) : LiveActor(pName) {
7 mParentFairy = pParent;
8 _90.setInline(0.0f);
9 mRailDirection.setInlinePS_2(rRailDirection);
10 mCounter = 0;
11 _AC = 0.0f;
12 mIsCountdown = false;
13 mFlashCtrl = nullptr;
14}
15
16void Note::init(const JMapInfoIter &rIter) {
17 MR::createSceneObj(SceneObj_NoteGroup);
18 _90.set(mPosition);
19 initModelManagerWithAnm("Note", nullptr, false);
20 MR::connectToSceneNoSilhouettedMapObjStrongLight(this);
21 initHitSensor(1);
22 TVec3f offs;
23 offs.x = 0.0f;
24 offs.y = 0.0f;
25 offs.z = 0.0f;
26 MR::addHitSensorMapObj(this, "body", 8, 80.0f, offs);
27 initEffectKeeper(0, nullptr, false);
28 initSound(4, false);
29 initNerve(&NrvNote::NoteNrvWait::sInstance);
30 mFlashCtrl = new FlashingCtrl(this, true);
31 MR::calcGravityAndDropShadowVector(this, &mGravity, nullptr, 0);
32 if (MR::isNearZero(mGravity, 0.001f)) {
33 mGravity.x = 0.0f;
34 mGravity.y = -1.0f;
35 mGravity.z = 0.0f;
36 }
37
38 MR::initShadowVolumeSphere(this, 30.0f);
39 MR::turnVecToPlane(&mRailDirection, mRailDirection, mGravity);
40 MR::invalidateClipping(this);
41 makeActorDead();
42}
43
44void Note::startCountDown() {
45 mIsCountdown = true;
46}
47
49 if (MR::isFirstStep(this)) {
50 MR::startBrk(this, "Note");
51 f32 framemax = MR::getBrkFrameMax(this, "Note");
52 f32 rpt = MR::repeat(_AC, 0.0f, framemax);
53 MR::setBrkFrame(this, rpt);
54 }
55
56 if (mIsCountdown) {
57 setNerve(&NrvNote::NoteNrvCountDown::sInstance);
58 }
59}
60
62 if (MR::isFirstStep(this)) {
63 mFlashCtrl->start(mCounter);
64 }
65
66 if (MR::isStep(this, mCounter)) {
67 MR::emitEffect(this, "Vanish");
68 MR::startSound(this, "SE_OJ_MUSICAL_NOTE_BREAK", -1, -1);
69 MR::failureNoteCollection();
70 kill();
71 }
72}
73
75 if (MR::isFirstStep(this)) {
77 mVelocity.scaleInline(-30.0f);
78 MR::invalidateHitSensors(this);
79 mFlashCtrl->end();
80 }
81
82 if (MR::isStep(this, 10)) {
83 kill();
84 }
85}
86
87void Note::control() {
88 mRotation.y = MR::getSceneObj<NoteGroup*>(SceneObj_NoteGroup)->mRotation;
89}
90
92 TVec3f stack_8;
93 stack_8.negateInline_2(mGravity);
94 TPos3f stack_44;
95 MR::makeMtxUpFront(&stack_44, stack_8, mRailDirection);
96 Mtx mtxRotateY;
97 f32 val = MR::getSceneObj<NoteGroup*>(SceneObj_NoteGroup)->mRotation;
98 MR::makeMtxRotateY(mtxRotateY, val);
99 PSMTXConcat(stack_44.toMtxPtr(), mtxRotateY, stack_44.toMtxPtr());
100 stack_44.mMtx[0][3] = mPosition.x;
101 stack_44.mMtx[1][3] = mPosition.y;
102 stack_44.mMtx[2][3] = mPosition.z;
103 MR::setBaseTRMtx(this, stack_44);
104}
105
107 if (MR::isSensorPlayerOrRide(a2)) {
108 if (!isNerve(&NrvNote::NoteNrvFlyUp::sInstance)) {
109 MR::emitEffect(this, "Get");
110 MR::addNoteToCounter();
111 mParentFairy->setLastGotNote(this);
112 setNerve(&NrvNote::NoteNrvFlyUp::sInstance);
113 }
114 }
115}
116
117NoteGroup::NoteGroup() : LiveActorGroup("音符グループ", 0x100) {
118 mRotation = 0.0f;
119}
120
121void NoteGroup::init(const JMapInfoIter &rIter) {
122 MR::connectToSceneMapObjMovement(this);
123}
124
125void NoteGroup::movement() {
126 f32 v1 = MR::subtractFromSum(8.0f, mRotation, 0.0f);
127 mRotation = mRotation + 8.0f;
128 mRotation = MR::modAndAdd(0.0f, v1);
129}
130
131Note::~Note() {
132
133}
134
135NoteGroup::~NoteGroup() {
136
137}
138
139namespace NrvNote {
140 INIT_NERVE(NoteNrvWait);
141 INIT_NERVE(NoteNrvCountDown);
142 INIT_NERVE(NoteNrvFlyUp);
143};
The basis of a drawable actor that can contain states (see: Nerve)
Definition LiveActor.hpp:24
TVec3f mRotation
3D vector of the actor's rotation.
Definition LiveActor.hpp:96
TVec3f mPosition
3D vector of the actor's position.
Definition LiveActor.hpp:95
TVec3f mVelocity
3D vector of the actor's velocity.
Definition LiveActor.hpp:98
TVec3f mGravity
3D vector of the actor's gravity.
Definition LiveActor.hpp:99
virtual void init(const JMapInfoIter &)
Intializes the NameObj and can set various settings and construct necessary classes.
Definition Note.cpp:121
void exeFlyUp()
Scales the note's velocity by -30.0 and then invalidates all hit sensors, and after 10 steps,...
Definition Note.cpp:74
virtual void init(const JMapInfoIter &)
Intializes the NameObj and can set various settings and construct necessary classes.
Definition Note.cpp:16
virtual void calcAndSetBaseMtx()
Calculates and sets the base matrix of the actor.
Definition Note.cpp:91
int mCounter
The amount of steps it takes for the note to disappear.
Definition Note.hpp:45
void exeCountDown()
Begins the flashing sequence and if the current step reaches Note::mCounter's value,...
Definition Note.cpp:61
NoteFairy * mParentFairy
The parent NoteFairy that this note was spawned from.
Definition Note.hpp:42
virtual void attackSensor(HitSensor *, HitSensor *)
Checks if the sensor is either a player or a rideable entity and if it is, it will "collect" the note...
Definition Note.cpp:106
void exeWait()
Begins the countdown sequence that plays the "waiting" animation, and is switched to the countdown ne...
Definition Note.cpp:48