MapObj: Implement TreasureBoxKey (#642)

This commit is contained in:
Naii-the-Baf 2025-06-15 04:34:29 -06:00 committed by GitHub
parent 18ef362b76
commit c6db0991df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 315 additions and 21 deletions

View file

@ -20253,25 +20253,25 @@ Address,Quality,Size,Name
0x000000710033dd34,U,000008,_ZNK12_GLOBAL__N_120TreasureBoxNrvBounce7executeEPN2al11NerveKeeperE
0x000000710033dd3c,U,000008,_ZNK12_GLOBAL__N_126TreasureBoxNrvSenobiBounce7executeEPN2al11NerveKeeperE
0x000000710033dd44,U,000008,_ZNK12_GLOBAL__N_129TreasureBoxNrvTrampleReaction7executeEPN2al11NerveKeeperE
0x000000710033dd4c,U,000140,_ZN14TreasureBoxKeyC2EPKc
0x000000710033ddd8,U,000152,_ZN14TreasureBoxKeyC1EPKc
0x000000710033de70,U,000420,_ZN14TreasureBoxKey4initERKN2al13ActorInitInfoE
0x000000710033e014,U,000116,_ZN14TreasureBoxKey13makeActorDeadEv
0x000000710033e088,U,000060,_ZN14TreasureBoxKey14makeActorAliveEv
0x000000710033e0c4,U,000372,_ZN14TreasureBoxKey10receiveMsgEPKN2al9SensorMsgEPNS0_9HitSensorES5_
0x000000710033e238,U,000144,_ZN14TreasureBoxKey7restartEv
0x000000710033e2c8,U,000140,_ZN14TreasureBoxKey12exeCloseWaitEv
0x000000710033e354,U,000080,_ZN14TreasureBoxKey16exeWaitStartDemoEv
0x000000710033e3a4,U,000084,_ZN14TreasureBoxKey22exeWaitCameraInterpoleEv
0x000000710033e3f8,U,000368,_ZN14TreasureBoxKey7exeOpenEv
0x000000710033e568,U,000084,_ZN14TreasureBoxKey25exeWaitEndCameraInterpoleEv
0x000000710033e5bc,U,000144,_ZN14TreasureBoxKey11exeOpenWaitEv
0x000000710033e64c,U,000008,_ZNK12_GLOBAL__N_126TreasureBoxKeyNrvCloseWait7executeEPN2al11NerveKeeperE
0x000000710033e654,U,000008,_ZNK12_GLOBAL__N_125TreasureBoxKeyNrvOpenWait7executeEPN2al11NerveKeeperE
0x000000710033e65c,U,000008,_ZNK12_GLOBAL__N_121TreasureBoxKeyNrvOpen7executeEPN2al11NerveKeeperE
0x000000710033e664,U,000084,_ZNK12_GLOBAL__N_130TreasureBoxKeyNrvWaitStartDemo7executeEPN2al11NerveKeeperE
0x000000710033e6b8,U,000088,_ZNK12_GLOBAL__N_136TreasureBoxKeyNrvWaitCameraInterpole7executeEPN2al11NerveKeeperE
0x000000710033e710,U,000088,_ZNK12_GLOBAL__N_139TreasureBoxKeyNrvWaitEndCameraInterpole7executeEPN2al11NerveKeeperE
0x000000710033dd4c,O,000140,_ZN14TreasureBoxKeyC2EPKc
0x000000710033ddd8,O,000152,_ZN14TreasureBoxKeyC1EPKc
0x000000710033de70,O,000420,_ZN14TreasureBoxKey4initERKN2al13ActorInitInfoE
0x000000710033e014,O,000116,_ZN14TreasureBoxKey13makeActorDeadEv
0x000000710033e088,O,000060,_ZN14TreasureBoxKey14makeActorAliveEv
0x000000710033e0c4,O,000372,_ZN14TreasureBoxKey10receiveMsgEPKN2al9SensorMsgEPNS0_9HitSensorES5_
0x000000710033e238,O,000144,_ZN14TreasureBoxKey7restartEv
0x000000710033e2c8,O,000140,_ZN14TreasureBoxKey12exeCloseWaitEv
0x000000710033e354,O,000080,_ZN14TreasureBoxKey16exeWaitStartDemoEv
0x000000710033e3a4,O,000084,_ZN14TreasureBoxKey22exeWaitCameraInterpoleEv
0x000000710033e3f8,O,000368,_ZN14TreasureBoxKey7exeOpenEv
0x000000710033e568,O,000084,_ZN14TreasureBoxKey25exeWaitEndCameraInterpoleEv
0x000000710033e5bc,O,000144,_ZN14TreasureBoxKey11exeOpenWaitEv
0x000000710033e64c,O,000008,_ZNK12_GLOBAL__N_126TreasureBoxKeyNrvCloseWait7executeEPN2al11NerveKeeperE
0x000000710033e654,O,000008,_ZNK12_GLOBAL__N_125TreasureBoxKeyNrvOpenWait7executeEPN2al11NerveKeeperE
0x000000710033e65c,O,000008,_ZNK12_GLOBAL__N_121TreasureBoxKeyNrvOpen7executeEPN2al11NerveKeeperE
0x000000710033e664,O,000084,_ZNK12_GLOBAL__N_130TreasureBoxKeyNrvWaitStartDemo7executeEPN2al11NerveKeeperE
0x000000710033e6b8,O,000088,_ZNK12_GLOBAL__N_136TreasureBoxKeyNrvWaitCameraInterpole7executeEPN2al11NerveKeeperE
0x000000710033e710,O,000088,_ZNK12_GLOBAL__N_139TreasureBoxKeyNrvWaitEndCameraInterpole7executeEPN2al11NerveKeeperE
0x000000710033e768,U,000144,_ZN20TreasureBoxKeyOpenerC2EPKc
0x000000710033e7f8,U,000156,_ZN20TreasureBoxKeyOpenerC1EPKc
0x000000710033e894,U,000208,_ZN20TreasureBoxKeyOpener4initERKN2al13ActorInitInfoE
@ -30423,7 +30423,7 @@ Address,Quality,Size,Name
0x00000071004bc720,O,000052,_ZN2al19createActorFunctionI18TrampleSwitchTimerEEPNS_9LiveActorEPKc
0x00000071004bc754,O,000052,_ZN2al19createActorFunctionI15TransparentWallEEPNS_9LiveActorEPKc
0x00000071004bc788,U,000052,_ZN2al19createActorFunctionI11TreasureBoxEEPNS_9LiveActorEPKc
0x00000071004bc7bc,U,000052,_ZN2al19createActorFunctionI14TreasureBoxKeyEEPNS_9LiveActorEPKc
0x00000071004bc7bc,O,000052,_ZN2al19createActorFunctionI14TreasureBoxKeyEEPNS_9LiveActorEPKc
0x00000071004bc7f0,U,000052,_ZN2al19createActorFunctionI29TreasureBoxSequentialDirectorEEPNS_9LiveActorEPKc
0x00000071004bc824,U,000052,_ZN2al19createActorFunctionI4TRexEEPNS_9LiveActorEPKc
0x00000071004bc858,U,000052,_ZN2al19createActorFunctionI23TRexScrollBreakMapPartsEEPNS_9LiveActorEPKc

Can't render this file because it is too large.

View file

@ -0,0 +1,220 @@
#include "MapObj/TreasureBoxKey.h"
#include <math/seadVector.h>
#include "Library/Camera/CameraUtil.h"
#include "Library/LiveActor/ActorActionFunction.h"
#include "Library/LiveActor/ActorAnimFunction.h"
#include "Library/LiveActor/ActorClippingFunction.h"
#include "Library/LiveActor/ActorCollisionFunction.h"
#include "Library/LiveActor/ActorInitUtil.h"
#include "Library/LiveActor/ActorModelFunction.h"
#include "Library/LiveActor/ActorPoseUtil.h"
#include "Library/LiveActor/ActorSceneFunction.h"
#include "Library/LiveActor/ActorSensorUtil.h"
#include "Library/Nerve/NerveSetupUtil.h"
#include "Library/Nerve/NerveUtil.h"
#include "Library/Placement/PlacementFunction.h"
#include "Library/Stage/StageSwitchUtil.h"
#include "Item/Shine.h"
#include "MapObj/TreasureBoxKeyOpener.h"
#include "Util/DemoUtil.h"
#include "Util/ItemUtil.h"
#include "Util/SensorMsgFunction.h"
namespace {
NERVE_IMPL(TreasureBoxKey, CloseWait);
NERVE_IMPL(TreasureBoxKey, WaitStartDemo);
NERVE_IMPL(TreasureBoxKey, WaitCameraInterpole);
NERVE_IMPL(TreasureBoxKey, Open);
NERVE_IMPL(TreasureBoxKey, WaitEndCameraInterpole);
NERVE_IMPL(TreasureBoxKey, OpenWait);
NERVES_MAKE_NOSTRUCT(TreasureBoxKey, WaitCameraInterpole);
NERVES_MAKE_STRUCT(TreasureBoxKey, CloseWait, OpenWait, Open, WaitStartDemo,
WaitEndCameraInterpole);
} // namespace
TreasureBoxKey::TreasureBoxKey(const char* name) : al::LiveActor(name) {}
void TreasureBoxKey::init(const al::ActorInitInfo& info) {
al::initActor(this, info);
al::initNerve(this, &NrvTreasureBoxKey.CloseWait, 0);
if (al::isExistLinkChild(info, "BoxOpener", 0)) {
mTreasureBoxKeyOpener = new TreasureBoxKeyOpener("鍵付宝箱の鍵");
al::initLinksActor(mTreasureBoxKeyOpener, info, "BoxOpener", 0);
mTreasureBoxKeyOpener->setHostForClipping(this);
}
mShine = rs::initLinkShine(info, "ShineActor", 0);
if (mShine != nullptr) {
al::updatePoseRotate(mShine, sead::Vector3f::zero);
sead::Vector3f trans = al::getTrans(this);
trans.y = al::getTrans(mShine).y;
al::setTrans(mShine, trans);
if (mShine != nullptr)
rs::updateHintTrans(mShine, al::getTrans(mTreasureBoxKeyOpener));
}
bool isValidObjectCamera = false;
al::tryGetArg(&isValidObjectCamera, info, "IsValidObjectCamera");
if (isValidObjectCamera)
mCameraTicket = al::initDemoObjectCamera(this, info, nullptr, "固定");
al::tryGetArg(&mIsStopUpdateWhileCameraMoving, info, "IsStopUpdateWhileCameraMoving");
al::tryGetArg(&mCameraStartInterpFrame, info, "CameraStartInterpFrame");
al::tryOffStageSwitch(this, "GetOpenerOn");
makeActorAlive();
}
void TreasureBoxKey::makeActorDead() {
al::LiveActor::makeActorDead();
if (mTreasureBoxKeyOpener != nullptr)
mTreasureBoxKeyOpener->makeActorDead();
if (mShine != nullptr)
mShine->makeActorDead();
if (mCameraTicket != nullptr && al::isActiveCamera(mCameraTicket))
al::endCamera(this, mCameraTicket, -1, false);
}
void TreasureBoxKey::makeActorAlive() {
al::LiveActor::makeActorAlive();
al::validateClipping(this);
if (mShine != nullptr)
al::validateClipping(mShine);
}
bool TreasureBoxKey::receiveMsg(const al::SensorMsg* msg, al::HitSensor* other,
al::HitSensor* self) {
if (al::isSensorName(self, "PlayerRegard")) {
if (al::isMsgPlayerDisregard(msg) && al::isNerve(this, &NrvTreasureBoxKey.OpenWait))
return true;
return rs::isMsgPlayerDisregardHomingAttack(msg);
}
if (al::isMsgRestart(msg)) {
restart();
return true;
}
if (al::isMsgChangeAlpha(msg)) {
f32 alpha = al::getChangeAlphaValue(msg);
al::setModelAlphaMask(this, alpha);
al::setModelAlphaMask(mTreasureBoxKeyOpener, alpha);
if (!al::sendMsgChangeAlpha(mShine, alpha))
al::setModelAlphaMask(mShine, alpha);
return true;
}
if (rs::isMsgTimerAthleticDemoStart(msg)) {
al::addDemoActor(this);
al::addDemoActor(mTreasureBoxKeyOpener);
return true;
}
return false;
}
void TreasureBoxKey::restart() {
al::startVisAnim(this, "CloseWait");
al::startAction(this, "Wait");
appear();
al::sendMsgRestart(mTreasureBoxKeyOpener);
al::sendMsgRestart(mShine);
al::stopDitherAnimAutoCtrl(mTreasureBoxKeyOpener);
mShine->makeActorDead();
rs::updateHintTrans(mShine, al::getTrans(mTreasureBoxKeyOpener));
al::setNerve(this, &NrvTreasureBoxKey.CloseWait);
}
void TreasureBoxKey::exeCloseWait() {
if (al::isFirstStep(this)) {
al::tryStartVisAnimIfNotPlaying(this, "CloseWait");
al::tryStartActionIfNotPlaying(this, "Wait");
}
if (mTreasureBoxKeyOpener->isGot()) {
al::invalidateClipping(this);
if (mCameraTicket)
al::setNerve(this, &NrvTreasureBoxKey.WaitStartDemo);
else
al::setNerve(this, &NrvTreasureBoxKey.Open);
}
}
void TreasureBoxKey::exeWaitStartDemo() {
if (rs::requestStartDemoNormal(this, false)) {
al::startCamera(this, mCameraTicket, mCameraStartInterpFrame);
al::setNerve(this, &WaitCameraInterpole);
}
}
void TreasureBoxKey::exeWaitCameraInterpole() {
if (al::isGreaterEqualStep(this, 5) && !al::isActiveCameraInterpole(this, 0))
al::setNerve(this, &NrvTreasureBoxKey.Open);
}
void TreasureBoxKey::exeOpen() {
if (al::isFirstStep(this)) {
al::invalidateHitSensors(this);
al::invalidateCollisionParts(this);
al::startAction(this, "Open");
al::tryOnStageSwitch(this, "GetOpenerOn");
rs::updateHintTrans(mShine, al::getTrans(mShine));
}
if (al::isStep(this, 3)) {
al::invalidateClipping(mShine);
mShine->appearPopupWithoutDemo();
al::sendMsgShowModel(mShine);
if (mCameraTicket != nullptr)
al::startHitReaction(this, "シャイン出現デモ演出");
}
if (al::isStep(this, al::getActionFrameMax(this, "Open"))) {
al::startHitReaction(this, "DisappearOpenedDoor");
al::startVisAnim(this, "OpenWait");
al::startAction(this, "Wait");
}
if (mCameraTicket != nullptr) {
if (!al::isGreaterEqualStep(this, 150))
return;
al::endCamera(this, mCameraTicket, 30, false);
if (mIsStopUpdateWhileCameraMoving) {
al::setNerve(this, &NrvTreasureBoxKey.WaitEndCameraInterpole);
return;
}
rs::requestEndDemoNormal(this);
al::setNerve(this, &NrvTreasureBoxKey.OpenWait);
return;
}
if (al::isActionEnd(this))
al::setNerve(this, &NrvTreasureBoxKey.OpenWait);
}
void TreasureBoxKey::exeWaitEndCameraInterpole() {
if (al::isGreaterEqualStep(this, 5) && !al::isActiveCameraInterpole(this, 0))
al::setNerve(this, &NrvTreasureBoxKey.OpenWait);
}
void TreasureBoxKey::exeOpenWait() {
if (al::isFirstStep(this)) {
al::tryStartVisAnimIfNotPlaying(this, "OpenWait");
al::tryStartActionIfNotPlaying(this, "Wait");
if (!mIsStopUpdateWhileCameraMoving)
al::validateClipping(this);
}
if (mIsStopUpdateWhileCameraMoving && al::isStep(this, 30)) {
rs::requestEndDemoNormal(this);
al::validateClipping(this);
}
}

View file

@ -0,0 +1,41 @@
#pragma once
#include <basis/seadTypes.h>
#include "Library/LiveActor/LiveActor.h"
namespace al {
struct ActorInitInfo;
class CameraTicket;
class HitSensor;
class SensorMsg;
} // namespace al
class Shine;
class TreasureBoxKeyOpener;
class TreasureBoxKey : public al::LiveActor {
public:
TreasureBoxKey(const char* name);
void init(const al::ActorInitInfo& info) override;
void makeActorDead() override;
void makeActorAlive() override;
bool receiveMsg(const al::SensorMsg* msg, al::HitSensor* other, al::HitSensor* self) override;
void restart();
void exeCloseWait();
void exeWaitStartDemo();
void exeWaitCameraInterpole();
void exeOpen();
void exeWaitEndCameraInterpole();
void exeOpenWait();
Shine* getShine() const { return mShine; }
private:
bool mIsStopUpdateWhileCameraMoving = false;
s32 mCameraStartInterpFrame = 45;
Shine* mShine = nullptr;
TreasureBoxKeyOpener* mTreasureBoxKeyOpener = nullptr;
al::CameraTicket* mCameraTicket = nullptr;
};
static_assert(sizeof(TreasureBoxKey) == 0x128);

View file

@ -0,0 +1,32 @@
#pragma once
#include <basis/seadTypes.h>
#include "Library/LiveActor/LiveActor.h"
namespace al {
struct ActorInitInfo;
class HitSensor;
class SensorMsg;
} // namespace al
class TreasureBoxKeyOpener : public al::LiveActor {
public:
TreasureBoxKeyOpener(const char*);
void init(const al::ActorInitInfo&) override;
void initAfterPlacement() override;
void appear() override;
void makeActorAlive() override;
bool receiveMsg(const al::SensorMsg* msg, al::HitSensor* other, al::HitSensor* self) override;
void control() override;
bool isGot();
void exeAppear();
void exeWait();
void exeGot();
virtual void setHostForClipping(al::LiveActor*);
private:
void* filler[4];
};
static_assert(sizeof(TreasureBoxKeyOpener) == 0x128);

View file

@ -72,6 +72,7 @@
#include "MapObj/TrampleSwitch.h"
#include "MapObj/TrampleSwitchTimer.h"
#include "MapObj/TransparentWall.h"
#include "MapObj/TreasureBoxKey.h"
#include "MapObj/VolleyballNet.h"
#include "MapObj/WeightSwitch.h"
#include "MapObj/WorldMapEarth.h"
@ -577,7 +578,7 @@ const al::NameToCreator<al::ActorCreatorFunction> sProjectActorFactoryEntries[]
{"TrampleSwitchTimer", al::createActorFunction<TrampleSwitchTimer>},
{"TransparentWall", al::createActorFunction<TransparentWall>},
{"TreasureBox", nullptr},
{"TreasureBoxKey", nullptr},
{"TreasureBoxKey", al::createActorFunction<TreasureBoxKey>},
{"TreasureBoxSequentialDirector", nullptr},
{"TRex", nullptr},
{"TRexForceScroll", nullptr},