SMG-Decomp
A decompilation of Super Mario Galaxy 1
Loading...
Searching...
No Matches
WatchTowerRotateStep.cpp
1#include "Game/MapObj/WatchTowerRotateStep.hpp"
2#include "Game/Util.hpp"
3#include "Inline.hpp"
4
5NrvWatchTowerRotateStep::WatchTowerRotateStepNrvWait NrvWatchTowerRotateStep::WatchTowerRotateStepNrvWait::sInstance;
6NrvWatchTowerRotateStep::WatchTowerRotateStepNrvMoveStart NrvWatchTowerRotateStep::WatchTowerRotateStepNrvMoveStart::sInstance;
7NrvWatchTowerRotateStep::WatchTowerRotateStepNrvMove NrvWatchTowerRotateStep::WatchTowerRotateStepNrvMove::sInstance;
8
9WatchTowerRotateStep::WatchTowerRotateStep(const char *pName) : LiveActor(pName) {
10 mRotDeg.x = 0.0f;
11 mRotDeg.y = 0.0f;
12 mRotDeg.z = 0.0f;
13 mLifts = nullptr;
14}
15
17 MR::initDefaultPos(this, rIter);
18 initModelManagerWithAnm("WatchTowerRotateStep", nullptr, false);
19 MR::connectToSceneMapObj(this);
20
21 initHitSensor(1);
22 MR::addBodyMessageSensorMapObj(this);
23 MR::initCollisionParts(this, "WatchTowerRotateStep", getSensor(nullptr), nullptr);
24 initEffectKeeper(0, nullptr, false);
25 initSound(4, false);
26 MR::setClippingTypeSphereContainsModelBoundingBox(this, 1500.0f);
27
28 bool demoCast = MR::tryRegisterDemoCast(this, rIter);
29
30 if (demoCast) {
31 MR::registerDemoActionNerve(this, &NrvWatchTowerRotateStep::WatchTowerRotateStepNrvWait::sInstance, nullptr);
32 }
33
34 MR::calcUpVec(&mRotDeg, this);
35 initLift(rIter);
36
37 if (demoCast) {
38 initNerve(&NrvWatchTowerRotateStep::WatchTowerRotateStepNrvWait::sInstance);
39 }
40 else {
41 initNerve(&NrvWatchTowerRotateStep::WatchTowerRotateStepNrvMove::sInstance);
42 }
43
44 makeActorAppeared();
45}
46
48 TVec3f frontVec;
49 TPos3f baseMtx;
50
51 MR::calcFrontVec(&frontVec, this);
52 MR::makeMtxFrontUpPos(&baseMtx, frontVec, mRotDeg, mPosition);
53 MR::setBaseTRMtx(this, baseMtx);
54}
55
56void WatchTowerRotateStep::initLift(const JMapInfoIter &rIter) {
57 mLifts = new PartsModel*[4];
58
59 for (s32 i = 0; i < 4; i++) {
60 MtxPtr mtx = MR::getJointMtx(this, i + 1);
61 mLifts[i] = new PartsModel(this, "物見の塔リフト", "WatchTowerRotateStepLift", mtx, -1, false);
62 mLifts[i]->mCalcOwnMtx = false;
63
64 MR::initCollisionParts(mLifts[i], "WatchTowerRotateStepLift", getSensor(nullptr), nullptr);
65 TVec3f local68 = CALL_INLINE_FUNC(TVec3f, 600.0f, 200.0f, 400.0f);
66 MR::initShadowVolumeBox(mLifts[i], local68, mLifts[i]->getBaseMtx());
67 MR::setShadowVolumeStartDropOffset(mLifts[i], "WatchTowerRotateStepLift", 300.0f);
68 MR::setShadowDropLength(mLifts[i], "WatchTowerRotateStepLift", 370.0f);
69
70 if (MR::isDemoCast(this, nullptr)) {
71 MR::tryRegisterDemoCast(mLifts[i], rIter);
72 }
73
74 mLifts[i]->initWithoutIter();
75 }
76}
77
78// WatchTowerRotateStep::attachLift();
79
80void WatchTowerRotateStep::exeMoveStart() {
81 TVec3f upVec;
82
83 if (MR::isFirstStep(this)) {
84 MR::startSystemSE("SE_SY_READ_RIDDLE_S", -1, -1);
85 MR::startSound(this, "SE_OJ_WATCH_TOWER_START", -1, -1);
86 }
87
88 MR::startLevelSound(this, "SE_OJ_LV_WATCH_TOWER_ROTATE", -1, -1, -1);
89 f32 easeIn = MR::getEaseInValue((s32)getNerveStep(), 0.0f, 0.3f, 180.0f);
90 MR::calcFrontVec(&upVec, this);
91 MR::rotateVecDegree(&mRotDeg, upVec, easeIn);
92 attachLift();
93
94 if (MR::isStep(this, 180)) {
95 setNerve(&NrvWatchTowerRotateStep::WatchTowerRotateStepNrvMove::sInstance);
96 }
97}
98
99namespace NrvWatchTowerRotateStep {
100 void WatchTowerRotateStepNrvMove::execute(Spine *pSpine) const {
101 WatchTowerRotateStep* pActor = reinterpret_cast<WatchTowerRotateStep*>(pSpine->mExecutor);
102 TVec3f frontVec;
103
104 MR::calcFrontVec(&frontVec, pActor);
105 MR::rotateVecDegree(&pActor->mRotDeg, frontVec, 0.3f);
106 pActor->attachLift();
107 MR::startLevelSound(pActor, "SE_OJ_LV_WATCH_TOWER_ROTATE", -1, -1, -1);
108 }
109
110 void WatchTowerRotateStepNrvMoveStart::execute(Spine *pSpine) const {
111 reinterpret_cast<WatchTowerRotateStep*>(pSpine->mExecutor)->exeMoveStart();
112 }
113
114 void WatchTowerRotateStepNrvWait::execute(Spine *pSpine) const {}
115};
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
virtual MtxPtr getBaseMtx() const
Gets the base matrix of the model used for the actor.
HitSensor * getSensor(const char *pSensorName) const
Gets a sensor.
void initWithoutIter()
Initializes a NameObj without a JMapInfoIter instance.
Definition NameObj.cpp:41
Definition Spine.hpp:9
virtual void init(const JMapInfoIter &)
Intializes the NameObj and can set various settings and construct necessary classes.
virtual void calcAndSetBaseMtx()
Calculates and sets the base matrix of the actor.