1#include "Game/MapObj/GeneralMapParts.hpp"
2#include "Game/LiveActor/LiveActor.hpp"
3#include "Game/Util/BaseMatrixFollowTargetHolder.hpp"
5GeneralMapParts::GeneralMapParts(
const char *pName) :
MapParts(pName) {
7 mMoveConditionType = 0;
10 mFunctionArray.mCount = 0;
11 mAppearController =
nullptr;
12 mRailRotator =
nullptr;
15 mGuideDrawer =
nullptr;
16 mRailPosture =
nullptr;
23 MR::getMapPartsArgShadowType(&mShadowType, rIter);
24 MR::initMapPartsShadow(
this, rIter);
25 MR::getMapPartsArgMoveConditionType(&mMoveConditionType, rIter);
26 MR::getMapPartsArgSignMotionType(&mSignMotionType, rIter);
27 initMapPartsFunction(rIter);
28 MR::initActorCamera(
this, rIter, &mCameraInfo);
29 initNerve(&NrvGeneralMapParts::HostTypeWait::sInstance);
30 initSensorType(rIter);
32 MR::useStageSwitchWriteDead(
this, rIter);
34 if (MR::useStageSwitchReadB(
this, rIter)) {
35 void (
GeneralMapParts::*switchOff)(
void) = &GeneralMapParts::receiveMsgSwitchBOff;
36 void (
GeneralMapParts::*switchOn)(
void) = &GeneralMapParts::receiveMsgSwitchBOn;
37 MR::listenStageSwitchOnOffB(
this, MR::Functor(
this, switchOff), MR::Functor(
this, switchOn));
40 if (MR::useStageSwitchReadAppear(
this, rIter)) {
41 MR::syncStageSwitchAppear(
this);
48 MR::useStageSwitchSleep(
this, rIter);
51void GeneralMapParts::initAfterPlacement() {
53 if (!MR::isExistAnim(
this, MR::getModelResName(
this)) && !MR::isExistEffectTexMtx(
this)) {
54 MR::offCalcAnim(
this);
57 if (MR::hasMapPartsShadow(mShadowType)) {
58 MR::onCalcShadowOneTime(
this,
nullptr);
63void GeneralMapParts::appear() {
67 mGuideDrawer->start();
70 if (MR::isValidSwitchB(
this)) {
71 setNerve(&NrvGeneralMapParts::HostTypeWait::sInstance);
73 else if (!MR::isMoveStartTypeUnconditional(mMoveConditionType)) {
74 setNerve(&NrvGeneralMapParts::HostTypeWaitForPlayerOn::sInstance);
84 if (mAppearController->receiveMsg(msg)) {
89 broadcastMsgToAllFunctions(207);
93 return MR::receiveMapPartsRotateMsg(
this, msg, mRailMover, mRailRotator);
96void GeneralMapParts::control() {
98 if (mAppearController) {
99 mAppearController->movement();
103 mRailMover->movement();
104 if (MR::isValidSwitchDead(
this) && mRailMover->isReachedEnd()) {
105 MR::onSwitchDead(
this);
110 mRailPosture->movement();
114 mRotator->movement();
118 mRailRotator->movement();
122 mGuideDrawer->movement();
126 if (mRailMover && mRailMover->isWorking()) {
138 if (mRotator && mRotator->isWorking()) {
143 if (mRailRotator && mRailRotator->isWorking()) {
148 if (mRailPosture && mRailPosture->isWorking()) {
152 if (!(v5 || v3 || v7)) {
160 mtx.concat(mRailPosture->_18);
164 mtx.concat(mRailRotator->_5C);
168 mtx.concat(mRotator->getRotateMtx());
174 MR::setBaseTRMtx(
this, mtx);
178void GeneralMapParts::initMapPartsFunction(
const JMapInfoIter &rIter) {
180 mAppearController->
init(rIter);
181 mFunctionArray.push_back(mAppearController);
182 f32 rotate_speed = 0.0f;
183 MR::getMapPartsArgRotateSpeed(&rotate_speed, rIter);
184 bool hasRotateSpeed = 0.0f != rotate_speed;
186 if (hasRotateSpeed) {
188 mRotator->
init(rIter);
189 mFunctionArray.push_back(mRotator);
192 if (MR::isConnectedWithRail(rIter)) {
194 mRailMover->
init(rIter);
195 mFunctionArray.push_back(mRailMover);
197 mRailRotator->
init(rIter);
198 mFunctionArray.push_back(mRailRotator);
199 mGuideDrawer = MR::createMapPartsRailGuideDrawer(
this,
"RailPoint", rIter);
200 mFunctionArray.push_back(mGuideDrawer);
202 mRailPosture->
init(rIter);
203 mFunctionArray.push_back(mRailPosture);
207void GeneralMapParts::initSensorType(
const JMapInfoIter &rIter) {
208 if (MR::isMapPartsPressOn(rIter)) {
209 MR::setBodySensorTypePress(
this);
211 else if (!isFixed()) {
212 MR::setBodySensorTypeMoveCollision(
this);
215 MR::setBodySensorTypeMapObj(
this);
219void GeneralMapParts::initGravity(
const JMapInfoIter &rIter) {
220 MR::addBaseMatrixFollowTarget(
this, rIter,
nullptr,
nullptr);
222 if (!MR::isMapPartsShadowTypeNone(mShadowType)) {
224 MR::calcGravity(
this);
227 MR::onCalcGravity(
this);
256void GeneralMapParts::receiveMsgSwitchBOff() {
257 if (MR::isValidSwitchB(
this)) {
264bool GeneralMapParts::isFixed()
const {
265 if (!mRailMover && !mRotator) {
272void GeneralMapParts::startMove() {
273 if (!MR::hasMapPartsMoveStartSignMotion(mSignMotionType)) {
274 setNerve(&NrvGeneralMapParts::HostTypeMoveStart::sInstance);
278 mRailPosture->start();
290 mRailRotator->start();
293 setNerve(&NrvGeneralMapParts::HostTypeMove::sInstance);
297void GeneralMapParts::exeWait() {
298 if (isNerve(&NrvGeneralMapParts::HostTypeMove::sInstance) && MR::isExistActorCamera(mCameraInfo) && !_E4) {
299 if (MR::isStep(
this, MR::getActorCameraFrames(
this, mCameraInfo))) {
300 MR::endActorCamera(
this, mCameraInfo,
false, -1);
306void GeneralMapParts::exeMoveStart() {
307 if (MR::isFirstStep(
this)) {
309 mRotator->startWithSignalMotion();
313 mRailMover->startWithSignalMotion();
317 if (MR::isMapPartsSignMotionTypeMoveWait(mSignMotionType) && MR::isOnPlayer(MR::getBodySensor(
this))) {
319 mRotator->cancelSignalMotion();
323 mRailMover->cancelSignalMotion();
326 setNerve(&NrvGeneralMapParts::HostTypeWaitForPlayerOn::sInstance);
329 if (MR::isStep(
this, MapParts::getMoveStartSignalTime())) {
335 mRailRotator->start();
338 setNerve(&NrvGeneralMapParts::HostTypeMove::sInstance);
343namespace NrvGeneralMapParts {
344 INIT_NERVE(HostTypeWait);
345 INIT_NERVE(HostTypeWaitForPlayerOn);
346 INIT_NERVE(HostTypeMoveStart);
347 INIT_NERVE(HostTypeMove);
349 void HostTypeMove::execute(
Spine *pSpine)
const {
354 void HostTypeMoveStart::execute(
Spine *pSpine)
const {
356 part->exeMoveStart();
359 void HostTypeWaitForPlayerOn::execute(
Spine *pSpine)
const {
361 if (MR::isOnPlayer(MR::getBodySensor(part))) {
362 part->broadcastMsgToAllFunctions(0xCA);
367 void HostTypeWait::execute(
Spine *pSpine)
const {
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.
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 init(const JMapInfoIter &)
Intializes the NameObj and can set various settings and construct necessary classes.
virtual void init(const JMapInfoIter &)
Intializes the NameObj and can set various settings and construct necessary classes.
virtual void init(const JMapInfoIter &)
Intializes the NameObj and can set various settings and construct necessary classes.
virtual void init(const JMapInfoIter &)
Intializes the NameObj and can set various settings and construct necessary classes.
virtual void init(const JMapInfoIter &)
Intializes the NameObj and can set various settings and construct necessary classes.