1#include "Game/MapObj/SwitchBox.hpp"
2#include "Game/Util.hpp"
3#include "JSystem/JGeometry/TVec.hpp"
5SwitchBox::SwitchBox(
const char *pName) :
LiveActor(pName) {
10 MR::initDefaultPos(
this, rIter);
11 initModelManagerWithAnm(
"SwitchBox",
nullptr,
false);
12 MR::connectToSceneMapObjNoCalcAnim(
this);
14 initNerve(&NrvSwitchBox::SwitchBoxNrvWait::sInstance);
15 initEffectKeeper(3,
nullptr,
false);
16 f32 newScale =
mScale.x * 90.0f;
19 sensorOffset.setInline(0.0f, newScale, 0.0f);
20 MR::addHitSensorMapObj(
this,
"body", 8, newScale, sensorOffset);
24 if (MR::checkJMapDataEntries(rIter)) {
25 MR::getJMapInfoArg1NoInit(rIter, &local_38);
28 setNerve(&NrvSwitchBox::SwitchBoxNrvWait::sInstance);
29 MR::initCollisionParts(
this,
"SwitchBox",
getSensor(
"body"),
nullptr);
30 MR::validateClipping(
this);
39 MR::initShadowVolumeBox(
this, TVec3f(150.0f, 150.0f, 150.0f));
40 MR::setShadowVolumeStartDropOffset(
this,
nullptr, 77.0f);
41 MR::setShadowVolumeEndDropOffset(
this,
nullptr, 150.0f);
42 MR::excludeCalcShadowToMyCollision(
this,
nullptr);
43 MR::onShadowVolumeCutDropLength(
this,
nullptr);
44 MR::onCalcGravity(
this);
45 MR::onCalcShadowOneTime(
this,
nullptr);
48 MR::addToAttributeGroupSearchTurtle(
this);
50 if (MR::useStageSwitchReadAppear(
this, rIter)) {
51 MR::syncStageSwitchAppear(
this);
54 MR::needStageSwitchWriteDead(
this, rIter);
58void SwitchBox::initAfterPlacement() {
62void SwitchBox::exeWait() {
75 setNerve(&NrvSwitchBox::SwitchBoxNrvHit::sInstance);
79void SwitchBox::exeHit() {
80 if (getNerveStep() == 0) {
84 if (getNerveStep() == 5) {
88 if (getNerveStep() == 15) {
93void SwitchBox::appear() {
94 MR::offSwitchDead(
this);
102 setNerve(&NrvSwitchBox::SwitchBoxNrvWait::sInstance);
105void SwitchBox::kill() {
106 MR::onSwitchDead(
this);
116 MR::invalidateCollisionParts(
this);
121 if (MR::isInWater(
this, TVec3f(0.0f, 0.0f, 0.0f))) {
122 MR::startSound(
this,
"SE_OJ_S_BLOCK_BREAK_W", -1, -1);
123 MR::emitEffect(
this,
"BreakWater");
125 MR::startSound(
this,
"SE_OJ_S_BLOCK_BREAK", -1, -1);
126 MR::emitEffect(
this,
"Break");
130bool SwitchBox::receiveMsgPlayerAttack(u32 msg,
HitSensor *pSender,
HitSensor *pReceiver) {
131 if (MR::isMsgPlayerUpperPunch(msg) && _90 != 0) {
132 doHit(pSender, pReceiver);
133 pSender->receiveMessage(0x40, pReceiver);
137 if (MR::isMsgPlayerHitAll(msg) && _90 != 0) {
138 doHit(pSender, pReceiver);
142 if (MR::isMsgPlayerHipDrop(msg) || MR::isMsgPlayerHipDropFloor(msg)) {
144 doHit(pSender, pReceiver);
154bool SwitchBox::receiveMsgEnemyAttack(u32 msg,
HitSensor *pSender,
HitSensor *pReceiver) {
156 doHit(pSender, pReceiver);
172 if (MR::isMsgFloorTouch(msg)) {
179namespace NrvSwitchBox {
180 INIT_NERVE(SwitchBoxNrvWait);
181 INIT_NERVE(SwitchBoxNrvHit);
183 void SwitchBoxNrvHit::execute(
Spine *pSpine)
const {
188 void SwitchBoxNrvWait::execute(
Spine *pSpine)
const {
The basis of a drawable actor that can contain states (see: Nerve)
TVec3f mScale
3D vector of the actor's scale.
HitSensor * getSensor(const char *pSensorName) const
Gets a sensor.
virtual void init(const JMapInfoIter &rIter)
Intializes the NameObj and can set various settings and construct necessary classes.