SMG-Decomp
A decompilation of Super Mario Galaxy 1
Loading...
Searching...
No Matches
CoinBox.cpp
1#include "Game/MapObj/CoinBox.hpp"
2
3CoinBox::CoinBox(const char *pName) : LiveActor(pName) {
4
5}
6
7CoinBox::~CoinBox() {
8
9}
10
11void CoinBox::init(const JMapInfoIter &rIter) {
12 MR::initDefaultPos(this, rIter);
13 MR::connectToSceneMapObjMovement(this);
14 initSound(6, false);
15 initNerve(&NrvCoinBox::CoinBoxNrvWait::sInstance);
16 initHitSensor(1);
17 TVec3f box;
18 box.x = 0.0f;
19 box.y = 0.0f;
20 box.z = 0.0f;
21 MR::addHitSensorMapObj(this, "body", 8, 5.0f, box);
22 makeActorAppeared();
23 setNerve(&NrvCoinBox::CoinBoxNrvWait::sInstance);
24 MR::declareCoin(this, 1);
25 MR::setClippingFar50m(this);
26 initEffectKeeper(1, "Coin", false);
27}
28
29#ifdef NON_MATCHING
30void CoinBox::exeHit() {
31 if (!getNerveStep()) {
32 getSensor("body")->invalidate();
33 MR::emitEffect(this, "CoinGet");
34 }
35
36 if (getNerveStep() == 0xF) {
37 TVec3f axis_y;
38 MR::getRotatedAxisY(&axis_y, mRotation);
39 MR::calcGravityOrZero(this);
40 TVec3f stack_38;
41 f32 val = MR::vecKillElement(axis_y, mGravity, &stack_38);
42 TVec3f stack_8 = stack_38 * 10.0f;
43 TVec3f stack_2C((mGravity * val) * 30.0f);
44
45 //TVec3f stack_2C(stack_20);
46 stack_2C.addInline(stack_8);
47 MR::appearCoinToVelocity(this, mPosition, axis_y, 1);
48 kill();
49 }
50}
51#endif
52
53bool CoinBox::receiveOtherMsg(u32 msg, HitSensor *, HitSensor *) {
54 if (msg - 0x31 < 2) {
55 setNerve(&NrvCoinBox::CoinBoxNrvHit::sInstance);
56 return 1;
57 }
58
59 return 0;
60}
61
62namespace NrvCoinBox {
63 INIT_NERVE(CoinBoxNrvWait);
64 INIT_NERVE(CoinBoxNrvHit);
65
66 void CoinBoxNrvHit::execute(Spine *pSpine) const {
67 CoinBox* box = reinterpret_cast<CoinBox*>(pSpine->mExecutor);
68 box->exeHit();
69 }
70
71 void CoinBoxNrvWait::execute(Spine *pSpine) const {
72
73 }
74};
virtual void init(const JMapInfoIter &)
Intializes the NameObj and can set various settings and construct necessary classes.
Definition CoinBox.cpp:11
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 mGravity
3D vector of the actor's gravity.
Definition LiveActor.hpp:99
HitSensor * getSensor(const char *pSensorName) const
Gets a sensor.
Definition Spine.hpp:9