1#include "Game/MapObj/ArrowSwitch.hpp"
5 const f32 sRotYTargetList[4] = { 0.0f, 90.0f, 180.0f, -90.0f };
8ArrowSwitch::ArrowSwitch(
const char *pName) :
LiveActor(pName) {
20 MR::initDefaultPos(
this, rIter);
24 initModelManagerWithAnm(
"ArrowSwitch",
nullptr,
false);
25 MR::connectToSceneNoShadowedMapObjStrongLight(
this);
27 MR::calcUpVec(&up_vec,
this);
29 neg_up_vec.negateInlineAndStore(up_vec,
mGravity);
30 MR::initShadowFromCSV(
this,
"Shadow");
31 MR::onCalcShadow(
this,
nullptr);
32 MR::onCalcGravity(
this);
33 if (MR::isInAreaObj(
"PlaneModeCube",
mPosition)) {
35 MR::addHitSensorMapObj(
this,
"body", 8, 100.0f, TVec3f(0.0f, 50.0f, 250.0f));
39 MR::addHitSensorMapObj(
this,
"body", 8, 100.0f, TVec3f(0.0f, 50.0f, 250.0f));
40 MR::addHitSensorMapObjMoveCollision(
this,
"collision", 8, 0.0f, TVec3f(0.0f, 0.0f, 0.0f));
41 MR::initCollisionParts(
this,
"ArrowSwitch",
getSensor(
"collision"),
nullptr);
45 initNerve(&NrvArrowSwitch::ArrowSwitchNrvWait::sInstance);
46 MR::getJMapInfoArg0WithInit(rIter, &_98);
47 MR::getJMapInfoArg1WithInit(rIter, &_9C);
49 MR::getJMapInfoArg2WithInit(rIter, &arg);
52 MR::setShadowDropLength(
this,
nullptr, arg);
55 MR::needStageSwitchWriteA(
this, rIter);
58 void (
ArrowSwitch::*switchOff)(
void) = &ArrowSwitch::listenOffSwitch;
59 void (
ArrowSwitch::*switchOn)(
void) = &ArrowSwitch::listenOnSwitch;
60 MR::listenStageSwitchOnOffB(
this, MR::Functor(
this, switchOff), MR::Functor(
this, switchOn));
66void ArrowSwitch::control() {
74 pos.setInline(baseMtx);
81 tr_mtx.mMtx[0][2] = v12;
82 tr_mtx.mMtx[1][1] = 1.0f;
83 tr_mtx.mMtx[0][0] = v13;
84 tr_mtx.mMtx[2][0] = -v12;
85 tr_mtx.mMtx[2][2] = v13;
86 tr_mtx.mMtx[2][1] = 0.0f;
87 tr_mtx.mMtx[1][2] = 0.0f;
88 tr_mtx.mMtx[1][0] = 0.0f;
89 tr_mtx.mMtx[0][1] = 0.0f;
90 pos.concat(pos, tr_mtx);
91 MR::setBaseTRMtx(
this, pos);
95 if (MR::isSensorPlayer(a2)) {
96 MR::sendMsgPush(a2, a1);
101 if (MR::isMsgPlayerHitAll(msg)) {
102 return requestPunch(a2, a3);
117 if (!isNerve(&NrvArrowSwitch::ArrowSwitchNrvWait::sInstance)) {
123 MR::calcSideVec(&side,
this);
124 MR::calcSensorDirection(&direction, a1, a2);
129 else if (isMinusLimit()) {
133 f32 dot = side.dot(direction);
143 s32 step = _9D ? getOneStep() : -getOneStep();
144 mRotationIdx += step;
145 mRotationIdx = (mRotationIdx + 4) % 4;
146 _94 = _9D ? -6.0f : 6.0f;
148 MR::invalidateClipping(
this);
149 setNerve(&NrvArrowSwitch::ArrowSwitchNrvRotate::sInstance);
153void ArrowSwitch::listenOnSwitch() {
154 if (mRotationIdx == 0) {
181 MR::invalidateClipping(
this);
182 setNerve(&NrvArrowSwitch::ArrowSwitchNrvRotate::sInstance);
186void ArrowSwitch::listenOffSwitch() {
187 if (mRotationIdx != 0) {
206 MR::invalidateClipping(
this);
207 setNerve(&NrvArrowSwitch::ArrowSwitchNrvRotate::sInstance);
211void ArrowSwitch::exeWait() {
212 if (MR::isFirstStep(
this)) {
213 if (mRotationIdx != 0) {
214 MR::startBtk(
this,
"On");
217 MR::startBtk(
this,
"Off");
220 MR::validateClipping(
this);
221 MR::onCalcShadow(
this,
nullptr);
226void ArrowSwitch::exeRotate() {
227 if (MR::isFirstStep(
this)) {
228 MR::startSound(
this,
"SE_OJ_ARROW_SWITCH_ON", -1, -1);
229 MR::onCalcShadow(
this,
nullptr);
232 MR::invalidateHitSensors(
this);
233 if (MR::isExistCollisionParts(
this)) {
234 MR::invalidateCollisionParts(
this);
239 MR::startLevelSound(
this,
"SE_OJ_LV_ARROW_SWITCH_MOVE", -1, -1, -1);
240 f32 v2 = (_8C + _94) - -180.0f;
242 f32 v3 = fmod(360.0 + v2, 360.0);
243 f32 v4 = (-180.0f + v3);
244 f32 v5 = (sRotYTargetList[mRotationIdx] - (-180.0f + v3));
246 f32 v6 = (-180.0 + fmod((360.0 + (v5 - -180.0)), 360.0));
248 if (_9D && v6 < 0.0f || !_9D && v6 > 0.0f) {
249 f32 rot = sRotYTargetList[mRotationIdx];
252 if (MR::isValidSwitchA(
this) && _9F) {
253 if (mRotationIdx != 0) {
257 MR::offSwitchA(
this);
260 MR::startSystemSE(
"SE_SY_GRAVITY_SWITCHED", -1, -1);
263 MR::startSound(
this,
"SE_OJ_ARROW_SWITCH_STOP", -1, -1);
266 setNerve(&NrvArrowSwitch::ArrowSwitchNrvLock::sInstance);
269 setNerve(&NrvArrowSwitch::ArrowSwitchNrvWait::sInstance);
275void ArrowSwitch::exeLock() {
276 if (MR::isFirstStep(
this)) {
277 if (mRotationIdx == 0) {
278 MR::startBtk(
this,
"Off");
281 MR::startBtk(
this,
"On");
284 MR::validateClipping(
this);
285 MR::onCalcShadow(
this,
nullptr);
289bool ArrowSwitch::isPlusLimit()
const {
292 return mRotationIdx == 2;
294 return mRotationIdx == 1;
296 return mRotationIdx == 0;
298 return mRotationIdx == 0;
304bool ArrowSwitch::isMinusLimit()
const {
307 return mRotationIdx == 0;
309 return mRotationIdx == 0;
311 return mRotationIdx == 3;
313 return mRotationIdx == 2;
333namespace NrvArrowSwitch {
334 INIT_NERVE(ArrowSwitchNrvWait);
335 INIT_NERVE(ArrowSwitchNrvRotate);
336 INIT_NERVE(ArrowSwitchNrvLock);
338 void ArrowSwitchNrvLock::execute(
Spine *pSpine)
const {
343 void ArrowSwitchNrvRotate::execute(
Spine *pSpine)
const {
348 void ArrowSwitchNrvWait::execute(
Spine *pSpine)
const {
354ArrowSwitch::~ArrowSwitch() {
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.
virtual MtxPtr getBaseMtx() const
Gets the base matrix of the model used for the actor.
HitSensor * getSensor(const char *pSensorName) const
Gets a sensor.