1#include "Game/MapObj/FlipPanel.hpp"
2#include "Game/LiveActor/ModelObj.hpp"
3#include "Game/LiveActor/LiveActorGroupArray.hpp"
4#include "JSystem/JMath/JMath.hpp"
5#include "Game/Util.hpp"
7FlipPanel::FlipPanel(
const char *pName) :
MapObjActor(pName) {
19 info.setupHioNode(
"地形オブジェ");
20 info.setupDefaultPos();
21 info.setupConnectToScene();
22 info.setupEffect(
"FlipPanel");
24 info.setupNerve(&NrvFlipPanel::FlipPanelNrvFront::sInstance);
25 initialize(rIter, info);
26 mIsReverse = isObjectName(
"FipPanelReverse");
27 mDelegator = MR::createJointDelegatorWithNullChildFunc(
this, &FlipPanel::calcJointMove,
"Panel");
28 mFlipPanelGroup = MR::joinToGroupArray(
this, rIter, 0, 0x20);
29 MR::invalidateClipping(
this);
30 MR::startBck(
this,
"PanelB", 0);
31 f32 frameMax = MR::getBckFrameMax(
this);
32 MR::setBckFrameAndStop(
this, frameMax);
35 MapObjActorUtil::appearBloomModel(
this);
38 MapObjActorUtil::killBloomModel(
this);
42void FlipPanel::exeFrontLand() {
43 if (MR::isFirstStep(
this)) {
44 MR::startBck(
this,
"PanelB", 0);
47 MapObjActorUtil::appearBloomModel(
this);
49 u32 frameMax = MR::getBrkFrameMax(bloomModel);
50 u32 val = sBloomSyncStep / frameMax;
51 frameMax = sBloomSyncStep - (val) * frameMax;
52 MR::setBrkFrame(bloomModel, frameMax);
55 MapObjActorUtil::killBloomModel(
this);
58 MR::tryRumblePadMiddle(
this, 0);
59 MR::startSound(
this,
"SE_OJ_FLIP_PANEL_CHANGE", -1, -1);
62 MR::sendMsgToGroupMember(0x67,
this,
getSensor(0),
"body");
67 if (MR::isOnGroundPlayer() && !MR::isOnPlayer(
this)) {
68 setNerve(&NrvFlipPanel::FlipPanelNrvFront::sInstance);
72void FlipPanel::exeBackLand() {
73 if (MR::isFirstStep(
this)) {
74 MR::startBck(
this,
"PanelA", 0);
77 MapObjActorUtil::killBloomModel(
this);
80 MapObjActorUtil::appearBloomModel(
this);
82 u32 frameMax = MR::getBrkFrameMax(bloomModel);
83 u32 val = sBloomSyncStep / frameMax;
84 frameMax = sBloomSyncStep - (val) * frameMax;
85 MR::setBrkFrame(bloomModel, frameMax);
88 MR::tryRumblePadMiddle(
this, 0);
89 MR::startSound(
this,
"SE_OJ_FLIP_PANEL_CHANGE", -1, -1);
92 MR::sendMsgToGroupMember(0x66,
this,
getSensor(0),
"body");
97 if (MR::isOnGroundPlayer() && !MR::isOnPlayer(
this)) {
98 setNerve(&NrvFlipPanel::FlipPanelNrvBack::sInstance);
102void FlipPanel::exeWait() {
103 if (MR::isFirstStep(
this)) {
104 MR::validateClipping(
this);
107 if (_CC && !MR::isOnPlayer(
this) && MR::isOnGroundPlayer()) {
112 if (checkPlayerOnTop()) {
113 if (isNerve(&NrvFlipPanel::FlipPanelNrvFront::sInstance)) {
114 setNerve(&NrvFlipPanel::FlipPanelNrvBackLand::sInstance);
117 setNerve(&NrvFlipPanel::FlipPanelNrvFrontLand::sInstance);
123void FlipPanel::exeEnd() {
124 if (MR::isFirstStep(
this)) {
125 MR::startSystemSE(
"SE_OJ_FLIP_PANEL_COMPLETE", -1, -1);
126 MR::startBck(
this,
"PanelEnd", 0);
127 MapObjActorUtil::killBloomModel(
this);
131 if (MR::isBckStopped(
this)) {
132 if (MR::isEffectValid(
this,
"FlipPanelGold")) {
133 MR::validateClipping(
this);
138void FlipPanel::appear() {
139 MapObjActor::appear();
141 MapObjActorUtil::appearBloomModel(
this);
144 MapObjActorUtil::killBloomModel(
this);
148void FlipPanel::endClipped() {
149 MapObjActor::endClipped();
151 if (MR::getBrkCtrl(mBloomModel)) {
153 u32 frameMax = MR::getBrkFrameMax(bloomModel);
154 u32 val = sBloomSyncStep / frameMax;
155 frameMax = sBloomSyncStep - (val) * frameMax;
156 MR::setBrkFrame(bloomModel, frameMax);
164 mDelegator->registerCallBack();
169 if (isNerve(&NrvFlipPanel::FlipPanelNrvEnd::sInstance)) {
173 if ((msg - 0x66) <= 1) {
174 _CC =
this == a2->mActor;
179 MR::invalidateClipping(
this);
180 setNerve(&NrvFlipPanel::FlipPanelNrvEndPrepare::sInstance);
195 MR::copyJointPos(
this,
"Panel", &jointPos);
197 MR::calcUpVec(&upVec,
this);
198 JMAVECScaleAdd((
const Vec*)&upVec, (
const Vec*)&jointPos, (Vec*)&jointPos, -25.0f);
199 pPos->mMtx[0][3] = jointPos.x;
200 pPos->mMtx[1][3] = jointPos.y;
201 pPos->mMtx[2][3] = jointPos.z;
205bool FlipPanel::checkPlayerOnTop() {
206 if (MR::isPlayerJumpRising() && _D0) {
211 if (!MR::isOnPlayer(
this)) {
217 MR::calcUpVec(&upVec,
this);
219 if (!MR::getPlayerGroundingPolygon()) {
223 TVec3f* groundNormal = MR::getPlayerGroundNormal();
225 bool ret = JGeometry::TUtil<f32>::epsilonEquals(upVec.x, groundNormal->x, 0.0000038146973f)
226 && JGeometry::TUtil<f32>::epsilonEquals(upVec.y, groundNormal->y, 0.0000038146973f)
227 && JGeometry::TUtil<f32>::epsilonEquals(upVec.z, groundNormal->z, 0.0000038146973f);
243FlipPanelObserver::FlipPanelObserver(
const char *pName) :
LiveActor(pName) {
253 MR::initDefaultPos(
this, rIter);
254 MR::connectToSceneMapObjMovement(
this);
256 MR::addBodyMessageSensorMapObj(
this);
257 MR::invalidateClipping(
this);
258 _8C = MR::joinToGroupArray(
this, rIter, 0, 0x20);
259 MR::useStageSwitchWriteA(
this, rIter);
261 MR::getJMapInfoArg7NoInit(rIter, &mPowerStarId);
263 if (mPowerStarId != -1) {
265 MR::declarePowerStar(
this);
268 MR::declarePowerStar(
this, mPowerStarId);
272 MR::getJMapInfoArg0NoInit(rIter, &mDemoDelay);
275 if (MR::isEqualStageName(
"HeavensDoorGalaxy")) {
282 initNerve(&NrvFlipPanelObserver::FlipPanelObserverNrvWait::sInstance);
283 bool ret = MR::useStageSwitchReadAppear(
this, rIter);
286 MR::syncStageSwitchAppear(
this);
294void FlipPanelObserver::exeWait() {
295 if (MR::isFirstStep(
this) && MR::isValidSwitchAppear(
this)) {
296 MR::callAppearAllGroupMember(
this);
297 MR::startSound(
this,
"SE_OJ_FLIP_PANEL_APPEAR", -1, -1);
300 if (_90 == _8C->mObjectCount - 1 && MR::tryStartDemo(
this,
"FlipPanelComplete")) {
301 setNerve(&NrvFlipPanelObserver::FlipPanelObserverNrvComplete::sInstance);
308void FlipPanelObserver::exeComplete() {
309 if (MR::isFirstStep(
this)) {
310 MR::callRequestMovementOnAllGroupMember(
this);
311 MR::requestMovementOn(_8C);
312 MR::sendMsgToGroupMember(0x69,
this,
getSensor(0),
"body");
315 if (MR::isGreaterStep(
this, mDemoDelay)) {
316 MR::endDemo(
this,
"FlipPanelComplete");
318 if (mPowerStarId != -1) {
320 MR::requestAppearPowerStar(
this,
mPosition);
323 MR::requestAppearPowerStar(
this, mPowerStarId,
mPosition);
327 setNerve(&NrvFlipPanelObserver::FlipPanelObserverNrvDemoWait::sInstance);
331void FlipPanelObserver::exeDemoWait() {
332 if (!MR::isDemoActive()) {
333 if (MR::isValidSwitchA(
this)) {
341void FlipPanelObserver::initAfterPlacement() {
342 if (MR::isValidSwitchAppear(
this)) {
343 MR::callMakeActorDeadAllGroupMember(
this);
351 MR::startSystemME(
"ME_FLIP_PANEL_INV_OFF_FIRST");
354 MR::startSystemME(
"ME_FLIP_PANEL_ON_FIRST");
359 MR::startSystemME(
"ME_FLIP_PANEL_INV_OFF");
362 MR::startSystemME(
"ME_FLIP_PANEL_ON");
369 else if (msg == 0x67) {
371 MR::startSystemME(
"ME_FLIP_PANEL_INV_ON");
374 MR::startSystemME(
"ME_FLIP_PANEL_OFF");
384namespace NrvFlipPanel {
385 FlipPanelNrvFrontLand FlipPanelNrvFrontLand::sInstance;
386 FlipPanelNrvBackLand FlipPanelNrvBackLand::sInstance;
387 FlipPanelNrvFront FlipPanelNrvFront::sInstance;
388 FlipPanelNrvBack FlipPanelNrvBack::sInstance;
389 FlipPanelNrvEndPrepare FlipPanelNrvEndPrepare::sInstance;
390 FlipPanelNrvEnd FlipPanelNrvEnd::sInstance;
393namespace NrvFlipPanelObserver {
394 FlipPanelObserverNrvWait FlipPanelObserverNrvWait::sInstance;
395 FlipPanelObserverNrvComplete FlipPanelObserverNrvComplete::sInstance;
396 FlipPanelObserverNrvDemoWait FlipPanelObserverNrvDemoWait::sInstance;
399void NrvFlipPanelObserver::FlipPanelObserverNrvDemoWait::execute(
Spine *pSpine)
const {
404void NrvFlipPanelObserver::FlipPanelObserverNrvComplete::execute(
Spine *pSpine)
const {
409void NrvFlipPanelObserver::FlipPanelObserverNrvWait::execute(
Spine *pSpine)
const {
414void NrvFlipPanel::FlipPanelNrvEnd::execute(
Spine *pSpine)
const {
419void NrvFlipPanel::FlipPanelNrvEndPrepare::execute(
Spine *pSpine)
const {
422 if (MR::isStep(panel, 0x14)) {
423 panel->setNerve(&NrvFlipPanel::FlipPanelNrvEnd::sInstance);
427void NrvFlipPanel::FlipPanelNrvBack::execute(
Spine *pSpine)
const {
432void NrvFlipPanel::FlipPanelNrvFront::execute(
Spine *pSpine)
const {
437void NrvFlipPanel::FlipPanelNrvBackLand::execute(
Spine *pSpine)
const {
439 panel->exeBackLand();
442void NrvFlipPanel::FlipPanelNrvFrontLand::execute(
Spine *pSpine)
const {
444 panel->exeFrontLand();
447FlipPanel::~FlipPanel() {
451FlipPanelObserver::~FlipPanelObserver() {
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.
The basis of a drawable actor that can contain states (see: Nerve)
TVec3f mPosition
3D vector of the actor's position.
HitSensor * getSensor(const char *pSensorName) const
Gets a sensor.
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.