1#include "Game/MapObj/GreenCaterpillarBig.hpp"
3GreenCaterpillarBigBody::GreenCaterpillarBigBody(
LiveActor *pCaterpillar, MtxPtr mtx) :
4 ModelObj(
"オオムイムイ体",
"GreenCaterpillarBigBody", mtx, -2, -2, -2, false) {
5 mCaterpillar = pCaterpillar;
13 MR::invalidateClipping(
this);
14 mPlanetLOD = MR::createLodCtrlPlanet(
this, rIter, -1.0f, -1);
15 mPlanetLOD->validate();
16 MR::calcFrontVec(&mFrontVec, mCaterpillar);
17 MR::startBck(
this,
"Wait",
nullptr);
21void GreenCaterpillarBigBody::setPosAndDirection(
LiveActor *pActor) {
23 MR::copyJointPos(mCaterpillar,
"FollowPoint", &jointPos);
25 calcBodyDir(pActor, &mFrontVec);
32void GreenCaterpillarBigBody::control() {
37 if (MR::isNearZero(mFrontVec, 0.001f)) {
41 MtxPtr jointMtx = MR::getJointMtx(mCaterpillar,
"FollowPoint");
43 pos.set(jointMtx[0][1], jointMtx[1][1], jointMtx[2][1]);
45 MR::makeMtxFrontUpPos(&frontUpPos, mFrontVec, pos,
mPosition);
46 MR::setBaseTRMtx(
this, frontUpPos);
50void GreenCaterpillarBigBody::calcBodyDir(
LiveActor *pActor, TVec3f *pOutDir) {
51 f32 nearRailCoord = MR::calcNearestRailCoord(pActor,
mPosition);
52 f32 coord = nearRailCoord - 300.0f;
54 MR::calcRailDirectionAtCoord(pOutDir, pActor, nearRailCoord);
58 MR::calcRailPosAtCoord(&railPos, pActor, coord);
61 MR::normalize(&stack_8);
62 MR::blendVec(pOutDir->toVec(), *pOutDir->toCVec(), *stack_8.toCVec(), 0.1f);
66GreenCaterpillarBig::GreenCaterpillarBig(
const char *pName) :
LiveActor(pName) {
77 MR::initDefaultPos(
this, rIter);
78 initModelManagerWithAnm(
"GreenCaterpillarBigFace",
nullptr,
false);
79 MR::connectToSceneMapObj(
this);
81 MR::addBodyMessageSensorMapObj(
this);
82 initEffectKeeper(0,
nullptr,
false);
87 MR::invalidateClipping(
this);
88 mPlanetLOD = MR::createLodCtrlPlanet(
this, rIter, -1.0f, -1);
89 mPlanetLOD->validate();
90 initNerve(&NrvGreenCaterpillarBig::GreenCaterpillarBigNrvHide::sInstance);
94void GreenCaterpillarBig::startWriggle() {
95 setNerve(&NrvGreenCaterpillarBig::GreenCaterpillarBigNrvWriggle::sInstance);
98void GreenCaterpillarBig::exeWriggle() {
99 if (MR::isFirstStep(
this)) {
100 if (MR::isHiddenModel(
this)) {
104 MR::startBck(
this,
"Eat",
nullptr);
107 MR::moveCoordAndFollowTrans(
this, 50.0f);
108 MR::startLevelSound(
this,
"SE_OJ_LV_GRN_CATERP_MOVE", -1, -1, -1);
110 if (MR::isRailReachedGoal(
this)) {
111 setNerve(&NrvGreenCaterpillarBig::GreenCaterpillarBigNrvEndAdjust::sInstance);
117 bool isNotEqual = MR::getCurrentRailPointNo(
this) != _98;
120 _98 = MR::getCurrentRailPointNo(
this);
121 f32 point_arg = -1.0f;
122 MR::getRailPointArg0NoInit(
this, _98, &point_arg);
124 if (point_arg == 0.0f) {
126 MR::tryRumblePadStrong(
this, 0);
127 MR::shakeCameraNormal();
128 MR::startSound(
this,
"SE_OJ_GRN_CATERP_IN", -1, -1);
130 else if (point_arg == 1.0f) {
131 setNerve(&NrvGreenCaterpillarBig::GreenCaterpillarBigNrvRest::sInstance);
133 else if (point_arg == 2.0f) {
140void GreenCaterpillarBig::initBodyParts(
const JMapInfoIter &rIter) {
141 s32 count = MR::getRailTotalLength(
this) / 300.0f;
142 mBodyArrayLength = count;
146 for (s32 i = 0; i < mBodyArrayLength; i++) {
147 MtxPtr jointMtx = MR::getJointMtx(caterpillar,
"FollowPoint");
149 mBodyArray[i]->
init(rIter);
154bool GreenCaterpillarBig::tryGenerateBodyParts() {
155 if (mCurBodyParts >= mBodyArrayLength) {
159 f32 coord = !mCurBodyParts ? MR::getRailCoord(
this) : MR::calcNearestRailCoord(this, mBodyArray[mCurBodyParts - 1]->
mPosition);
161 if (coord < 300.0f) {
165 mBodyArray[mCurBodyParts]->appear();
170void GreenCaterpillarBig::control() {
171 if (!isNerve(&NrvGreenCaterpillarBig::GreenCaterpillarBigNrvHide::sInstance)) {
172 if (!isNerve(&NrvGreenCaterpillarBig::GreenCaterpillarBigNrvEnd::sInstance)) {
173 tryGenerateBodyParts();
176 fixBodyPartsOnRail();
177 mPlanetLOD->update();
183 MR::calcMtxFromGravityAndZAxis(&mtx,
this,
mGravity, MR::getRailDirection(
this));
184 MR::setBaseTRMtx(
this, mtx);
187void GreenCaterpillarBig::startClipped() {
188 for (s32 i = 0; i < mCurBodyParts; i++) {
189 MR::validateClipping(mBodyArray[i]);
192 LiveActor::startClipped();
195void GreenCaterpillarBig::endClipped() {
196 for (s32 i = 0; i < mCurBodyParts; i++) {
197 MR::invalidateClipping(mBodyArray[i]);
200 LiveActor::endClipped();
203void GreenCaterpillarBig::fixBodyPartsOnRail() {
204 for (s32 i = 0; i < mCurBodyParts; i++) {
205 mBodyArray[i]->setPosAndDirection(
this);
209void GreenCaterpillarBig::leaveApple() {
211 MR::tryRumblePadStrong(
this, 0);
212 MR::shakeCameraNormal();
213 MR::startSound(
this,
"SE_OJ_GRN_CATERP_DAMAGE", -1, -1);
214 MR::startSound(
this,
"SE_OJ_GRN_CATERP_OUT", -1, -1);
217GreenCaterpillarBigBody::~GreenCaterpillarBigBody() {
221GreenCaterpillarBig::~GreenCaterpillarBig() {
225namespace NrvGreenCaterpillarBig {
226 INIT_NERVE(GreenCaterpillarBigNrvHide);
227 INIT_NERVE(GreenCaterpillarBigNrvWriggle);
228 INIT_NERVE(GreenCaterpillarBigNrvRest);
229 INIT_NERVE(GreenCaterpillarBigNrvEndAdjust);
230 INIT_NERVE(GreenCaterpillarBigNrvEnd);
232 void GreenCaterpillarBigNrvEnd::execute(
Spine *pSpine)
const {
234 if (MR::isFirstStep(caterpillar)) {
235 MR::startBck(caterpillar,
"Wait",
nullptr);
239 void GreenCaterpillarBigNrvEndAdjust::execute(
Spine *pSpine)
const {
241 if (MR::isStep(caterpillar, 0x78)) {
242 caterpillar->setNerve(&NrvGreenCaterpillarBig::GreenCaterpillarBigNrvEnd::sInstance);
246 void GreenCaterpillarBigNrvRest::execute(
Spine *pSpine)
const {
248 MR::startLevelSound(caterpillar,
"SE_OJ_LV_GRN_CATERP_EAT", -1, -1, -1);
251 void GreenCaterpillarBigNrvWriggle::execute(
Spine *pSpine)
const {
253 caterpillar->exeWriggle();
256 void GreenCaterpillarBigNrvHide::execute(
Spine *pSpine)
const {
258 MR::startLevelSound(caterpillar,
"SE_OJ_LV_GRN_CATERP_EAT", -1, -1, -1);
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.
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.
The basis of a drawable actor that can contain states (see: Nerve)
TVec3f mPosition
3D vector of the actor's position.
TVec3f mScale
3D vector of the actor's scale.
virtual void calcAndSetBaseMtx()
Calculates and sets the base matrix of the actor.
TVec3f mGravity
3D vector of the actor's gravity.