1#include "Game/MapObj/PTimerSwitch.hpp"
2#include "Game/Map/CollisionParts.hpp"
4PTimerSwitch::PTimerSwitch(
const char *pName) :
LiveActor(pName) {
5 mSwitchCollision =
nullptr;
11void PTimerSwitch::reset() {
13 setNerve(&NrvPTimerSwitch::PTimerSwitchNrvOff::sInstance);
14 MR::validateCollisionParts(mSwitchCollision);
15 MR::startBck(
this,
"Wait", 0);
21 MR::initDefaultPos(
this, rIter);
22 initModelManagerWithAnm(
"PTimerSwitch",
nullptr,
false);
23 MR::connectToSceneMapObj(
this);
25 MR::addHitSensorMapObj(
this,
"body", 0x10, 0.0f, TVec3f(0.0f, 0.0f, 0.0f));
26 MR::addHitSensor(
this,
"hit", 0x4f, 0x10, 120.0f, TVec3f(0.0f, 50.0f, 0.0f));
27 MR::initCollisionParts(
this,
"PTimerSwitch",
getSensor(
"body"), 0);
28 mSwitchCollision = MR::createCollisionPartsFromLiveActor(
this,
"Move",
getSensor(
"hit"), (MR::CollisionScaleType)2);
30 MR::needStageSwitchWriteA(
this, rIter);
31 initNerve(&NrvPTimerSwitch::PTimerSwitchNrvOff::sInstance);
32 initEffectKeeper(0,
nullptr,
false);
33 MR::startBck(
this,
"Move", 0);
38void PTimerSwitch::initAfterPlacement() {
39 mConnector->attachToUnder();
42void PTimerSwitch::appear() {
46void PTimerSwitch::kill() {
48 MR::emitEffect(
this,
"Delete");
49 MR::invalidateCollisionParts(mSwitchCollision);
52void PTimerSwitch::calcAnim() {
53 LiveActor::calcAnim();
55 mtx.setInline(MR::getJointMtx(
this,
"Move"));
56 mSwitchCollision->setMtx(mtx);
59void PTimerSwitch::control() {
71 mConnector->connect();
78bool PTimerSwitch::receiveMsgPlayerAttack(u32 msg,
HitSensor *pSender,
HitSensor *pReceiver) {
79 if (!MR::isMsgPlayerTrample(msg)) {
83 if (pReceiver->mSensorType != 0x4f) {
87 if (!isNerve(&NrvPTimerSwitch::PTimerSwitchNrvOff::sInstance)) {
95bool PTimerSwitch::trySwitchDown() {
97 setNerve(&NrvPTimerSwitch::PTimerSwitchNrvSwitchDown::sInstance);
104bool PTimerSwitch::tryOn() {
105 if (MR::isBckStopped(
this)) {
106 setNerve(&NrvPTimerSwitch::PTimerSwitchNrvOn::sInstance);
113void PTimerSwitch::exeOff() {
114 if (MR::isFirstStep(
this)) {
115 MR::validateClipping(
this);
116 MR::offSwitchA(
this);
119 if (!trySwitchDown()) {
124void PTimerSwitch::exeSwitchDown() {
125 if (MR::isFirstStep(
this)) {
126 MR::startBck(
this,
"On",
nullptr);
127 MR::invalidateClipping(
this);
135void PTimerSwitch::exeOn() {
136 if (MR::isFirstStep(
this)) {
138 MR::shakeCameraNormal();
139 MR::startSound(
this,
"SE_OJ_SWITCH_1", -1, -1);
142 if (MR::isGreaterStep(
this, 25)) {
147namespace NrvPTimerSwitch {
148 INIT_NERVE(PTimerSwitchNrvOn);
149 INIT_NERVE(PTimerSwitchNrvSwitchDown);
150 INIT_NERVE(PTimerSwitchNrvOff);
152 void PTimerSwitchNrvOn::execute(
Spine *pSpine)
const {
157 void PTimerSwitchNrvSwitchDown::execute(
Spine *pSpine)
const {
159 actor->exeSwitchDown();
162 void PTimerSwitchNrvOff::execute(
Spine *pSpine)
const {
The basis of a drawable actor that can contain states (see: Nerve)
virtual void calcAndSetBaseMtx()
Calculates and sets the base matrix of the actor.
HitSensor * getSensor(const char *pSensorName) const
Gets a sensor.
virtual void calcAndSetBaseMtx()
Calculates and sets the base matrix of the actor.
virtual void init(const JMapInfoIter &rIter)
Intializes the NameObj and can set various settings and construct necessary classes.