SMG-Decomp
A decompilation of Super Mario Galaxy 1
Loading...
Searching...
No Matches
CollapsePlane.cpp
1#include "Game/MapObj/CollapsePlane.hpp"
2
3CollapsePlane::CollapsePlane(const char *pName) : MapObjActor(pName) {
4 mScaleController = nullptr;
5 mStarPointerBind = nullptr;
6 mJointController = nullptr;
7 _D0 = -1;
8 mTimer = 140;
9}
10
12 MapObjActor::init(rIter);
14 info.setupHioNode("地形オブジェ");
15 info.setupDefaultPos();
16 info.setupConnectToScene();
17 info.setupHitSensor();
18 info.setupSound(4);
19 info.setupProjmapMtx(false);
20 info.setupNerve(&NrvCollapsePlane::CollapsePlaneNrvWait::sInstance);
21 initialize(rIter, info);
22 initEffectKeeper(1, nullptr, false);
23 TVec3f offs;
24 offs.x = 0.0f;
25 offs.y = 0.0f;
26 offs.z = 0.0f;
27 MR::initStarPointerTarget(this, (200.0f * mScale.x), offs);
28 mScaleController = new AnimScaleController(nullptr);
29 mScaleController->setParamTight();
30 mStarPointerBind = new WalkerStateBindStarPointer(this, mScaleController);
31 mJointController = MR::createJointDelegatorWithNullChildFunc(this, &CollapsePlane::calcJointPlane, "Plane");
32 MR::initCollisionPartsAutoEqualScale(this, "Move", getSensor(nullptr), MR::getJointMtx(this, "Plane"));
33 MR::validateCollisionParts(this);
34 MR::getJMapInfoArg0NoInit(rIter, &mTimer);
35}
36
37void CollapsePlane::exeWait() {
38 if (MR::isOnPlayer(this)) {
39 _D0 = 0;
40 setNerve(&NrvCollapsePlane::CollapsePlaneNrvCollapse::sInstance);
41 }
42}
43
44void CollapsePlane::exeCollapse() {
45 if (_D0 == 1) {
46 MR::startSound(this, "SE_OJ_COLLAPSE_PLANE_SHRINK", -1, -1);
47 }
48
49 if (_D0 >= mTimer) {
50 MR::hideMaterial(this, "PlaneMat_v");
51 MR::invalidateCollisionParts(this);
52 MR::emitEffect(this, "Vanish");
53 MR::startSound(this, "SE_OJ_COLLAPSE_PLANE_VANISH", -1, -1);
54 _D0 = -1;
55 setNerve(&NrvCollapsePlane::CollapsePlaneNrvEnd::sInstance);
56 }
57 else {
58 _D0 += 1;
59 }
60}
61
62void CollapsePlane::exeDPDStop() {
63 if (_D0 == -1 && MR::isOnPlayer(this)) {
64 _D0 = 0;
65 }
66
67 if (MR::updateActorState(this, mStarPointerBind)) {
68 if (_D0 == -1) {
69 setNerve(&NrvCollapsePlane::CollapsePlaneNrvWait::sInstance);
70 }
71 else {
72 setNerve(&NrvCollapsePlane::CollapsePlaneNrvCollapse::sInstance);
73 }
74 }
75}
76
79
80 if (_D0 != -1) {
81 mJointController->registerCallBack();
82 }
83
84 if (MR::isInitializeStateEnd()) {
85 TVec3f new_scale;
86 new_scale.multPS(mScaleController->_C, mScale);
87 MR::setBaseScale(this, new_scale);
88 }
89}
90
91void CollapsePlane::control() {
92 mScaleController->updateNerve();
93 tryDPDStop();
94}
95
96bool CollapsePlane::calcJointPlane(TPos3f *pPos, const JointControllerInfo &) {
97 f32 new_scale = (1.0f - ((0.69999999f * _D0)) / mTimer);
98 TMtx34f mtx;
99 mtx.identity();
100 MR::preScaleMtx(mtx.toMtxPtr(), new_scale, 1.0f, new_scale);
101 pPos->concat(mtx);
102 pPos->mMtx[0][3] = mPosition.x;
103 pPos->mMtx[1][3] = mPosition.y;
104 pPos->mMtx[2][3] = mPosition.z;
105 return true;
106}
107
108bool CollapsePlane::tryDPDStop() {
109 if (isNerve(&NrvCollapsePlane::CollapsePlaneNrvDPDStop::sInstance)) {
110 return false;
111 }
112
113 if (isNerve(&NrvCollapsePlane::CollapsePlaneNrvEnd::sInstance)) {
114 return false;
115 }
116
117 if (!mStarPointerBind->tryStartPointBind()) {
118 return false;
119 }
120
121 setNerve(&NrvCollapsePlane::CollapsePlaneNrvDPDStop::sInstance);
122 return true;
123}
124
125namespace NrvCollapsePlane {
126 INIT_NERVE(CollapsePlaneNrvWait);
127 INIT_NERVE(CollapsePlaneNrvCollapse);
128 INIT_NERVE(CollapsePlaneNrvDPDStop);
129 INIT_NERVE(CollapsePlaneNrvEnd);
130};
131
132CollapsePlane::~CollapsePlane() {
133
134}
virtual void calcAndSetBaseMtx()
Calculates and sets the base matrix of the actor.
virtual void init(const JMapInfoIter &)
Intializes the NameObj and can set various settings and construct necessary classes.
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
HitSensor * getSensor(const char *pSensorName) const
Gets a sensor.
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.