Skip to content

Commit

Permalink
add:RailMoveMapParts implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuzzy2319 committed Dec 10, 2024
1 parent 0a80ba3 commit e4e8883
Show file tree
Hide file tree
Showing 6 changed files with 169 additions and 23 deletions.
44 changes: 22 additions & 22 deletions data/odyssey_functions.csv
Original file line number Diff line number Diff line change
Expand Up @@ -30467,7 +30467,7 @@ Address,Quality,Size,Name
0x00000071004bd014,U,000052,_ZN2al19createActorFunctionI8PukupukuEEPNS_9LiveActorEPKc
0x00000071004bd048,U,000052,_ZN2al19createActorFunctionI11PulseSwitchEEPNS_9LiveActorEPKc
0x00000071004bd07c,U,000052,_ZN2al19createActorFunctionI13RailCollisionEEPNS_9LiveActorEPKc
0x00000071004bd0b0,U,000052,_ZN2al19createActorFunctionINS_16RailMoveMapPartsEEEPNS_9LiveActorEPKc
0x00000071004bd0b0,O,000052,_ZN2al19createActorFunctionINS_16RailMoveMapPartsEEEPNS_9LiveActorEPKc
0x00000071004bd0e4,U,000052,_ZN2al19createActorFunctionI12RiseMapPartsEEPNS_9LiveActorEPKc
0x00000071004bd118,U,000052,_ZN2al19createActorFunctionI16ReactionMapPartsEEPNS_9LiveActorEPKc
0x00000071004bd14c,U,000052,_ZN2al19createActorFunctionI18RiseMapPartsHolderEEPNS_9LiveActorEPKc
Expand Down Expand Up @@ -58344,27 +58344,27 @@ Address,Quality,Size,Name
0x00000071009164b4,O,000120,_ZN2al18OneMeshFixMapPartsC2EPKc
0x000000710091652c,O,000132,_ZN2al18OneMeshFixMapPartsC1EPKc
0x00000071009165b0,O,000088,_ZN2al18OneMeshFixMapParts4initERKNS_13ActorInitInfoE
0x0000007100916608,U,000128,_ZN2al16RailMoveMapPartsC2EPKc
0x0000007100916688,U,000140,_ZN2al16RailMoveMapPartsC1EPKc
0x0000007100916714,U,000456,_ZN2al16RailMoveMapParts4initERKNS_13ActorInitInfoE
0x00000071009168dc,U,000068,_ZN2al16RailMoveMapParts5startEv
0x0000007100916920,U,000072,_ZN2al16RailMoveMapParts4stopEv
0x0000007100916968,U,000088,_ZN2al16RailMoveMapParts10receiveMsgEPKNS_9SensorMsgEPNS_9HitSensorES5_
0x00000071009169c0,U,000092,_ZN2al16RailMoveMapParts7controlEv
0x0000007100916a1c,U,000048,_ZN2al16RailMoveMapParts17appearAndSetStartEv
0x0000007100916a4c,U,000004,_ZN2al16RailMoveMapParts10exeStandByEv
0x0000007100916a50,U,000092,_ZN2al16RailMoveMapParts11exeMoveSignEv
0x0000007100916aac,U,000004,_ZN2al16RailMoveMapParts7exeMoveEv
0x0000007100916ab0,U,000004,
0x0000007100916ab4,U,000012,
0x0000007100916ac0,U,000096,
0x0000007100916b20,U,000012,
0x0000007100916b2c,U,000008,
0x0000007100916b34,U,000012,
0x0000007100916b40,U,000028,_ZNK2al10FunctorV0MIPNS_16RailMoveMapPartsEMS1_FvvEEclEv
0x0000007100916b5c,U,000076,_ZNK2al10FunctorV0MIPNS_16RailMoveMapPartsEMS1_FvvEE5cloneEv
0x0000007100916ba8,U,000004,_ZN2al10FunctorV0MIPNS_16RailMoveMapPartsEMS1_FvvEED0Ev
0x0000007100916bac,U,000116,
0x0000007100916608,O,000128,_ZN2al16RailMoveMapPartsC2EPKc
0x0000007100916688,O,000140,_ZN2al16RailMoveMapPartsC1EPKc
0x0000007100916714,O,000456,_ZN2al16RailMoveMapParts4initERKNS_13ActorInitInfoE
0x00000071009168dc,O,000068,_ZN2al16RailMoveMapParts5startEv
0x0000007100916920,O,000072,_ZN2al16RailMoveMapParts4stopEv
0x0000007100916968,O,000088,_ZN2al16RailMoveMapParts10receiveMsgEPKNS_9SensorMsgEPNS_9HitSensorES5_
0x00000071009169c0,O,000092,_ZN2al16RailMoveMapParts7controlEv
0x0000007100916a1c,O,000048,_ZN2al16RailMoveMapParts17appearAndSetStartEv
0x0000007100916a4c,O,000004,_ZN2al16RailMoveMapParts10exeStandByEv
0x0000007100916a50,O,000092,_ZN2al16RailMoveMapParts11exeMoveSignEv
0x0000007100916aac,O,000004,_ZN2al16RailMoveMapParts7exeMoveEv
0x0000007100916ab0,O,000004,_ZNK2al12_GLOBAL__N_126RailMoveMapPartsNrvStandBy7executeEPNS_11NerveKeeperE
0x0000007100916ab4,O,000012,_ZNK2al12_GLOBAL__N_126RailMoveMapPartsNrvStandBy13getActionNameEv
0x0000007100916ac0,O,000096,_ZNK2al12_GLOBAL__N_127RailMoveMapPartsNrvMoveSign7executeEPNS_11NerveKeeperE
0x0000007100916b20,O,000012,_ZNK2al12_GLOBAL__N_127RailMoveMapPartsNrvMoveSign13getActionNameEv
0x0000007100916b2c,O,000008,_ZNK2al12_GLOBAL__N_123RailMoveMapPartsNrvMove7executeEPNS_11NerveKeeperE
0x0000007100916b34,O,000012,_ZNK2al12_GLOBAL__N_123RailMoveMapPartsNrvMove13getActionNameEv
0x0000007100916b40,O,000028,_ZNK2al10FunctorV0MIPNS_16RailMoveMapPartsEMS1_FvvEEclEv
0x0000007100916b5c,O,000076,_ZNK2al10FunctorV0MIPNS_16RailMoveMapPartsEMS1_FvvEE5cloneEv
0x0000007100916ba8,O,000004,_ZN2al10FunctorV0MIPNS_16RailMoveMapPartsEMS1_FvvEED0Ev
0x0000007100916bac,O,000116,_GLOBAL__sub_I_RailMoveMapParts.cpp
0x0000007100916c20,O,000264,_ZN2al19RollingCubeMapPartsC2EPKc
0x0000007100916d28,O,000276,_ZN2al19RollingCubeMapPartsC1EPKc
0x0000007100916e3c,O,000896,_ZN2al19RollingCubeMapParts4initERKNS_13ActorInitInfoE
Expand Down
110 changes: 110 additions & 0 deletions lib/al/Library/MapObj/RailMoveMapParts.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#include "Library/MapObj/RailMoveMapParts.h"

#include "Library/Area/SwitchKeepOnAreaGroup.h"
#include "Library/Area/SwitchOnAreaGroup.h"
#include "Library/LiveActor/ActorActionFunction.h"
#include "Library/LiveActor/ActorAreaFunction.h"
#include "Library/LiveActor/ActorClippingFunction.h"
#include "Library/LiveActor/ActorInitFunction.h"
#include "Library/LiveActor/ActorModelFunction.h"
#include "Library/LiveActor/ActorPoseKeeper.h"
#include "Library/LiveActor/ActorSensorMsgFunction.h"
#include "Library/Movement/RailMoveMovement.h"
#include "Library/Nerve/NerveSetupUtil.h"
#include "Library/Nerve/NerveStateCtrl.h"
#include "Library/Rail/RailUtil.h"
#include "Library/Stage/StageSwitchKeeper.h"
#include "Library/Thread/FunctorV0M.h"

namespace al {
namespace {
NERVE_ACTION_IMPL(RailMoveMapParts, StandBy)
NERVE_ACTION_IMPL(RailMoveMapParts, MoveSign)
NERVE_ACTION_IMPL(RailMoveMapParts, Move)

NERVE_ACTIONS_MAKE_STRUCT(RailMoveMapParts, StandBy, MoveSign, Move)
} // namespace

RailMoveMapParts::RailMoveMapParts(const char* name) : LiveActor(name) {}

void RailMoveMapParts::init(const ActorInitInfo& info) {
using RailMoveMapPartsFunctor = FunctorV0M<RailMoveMapParts*, void (RailMoveMapParts::*)()>;

initNerveAction(this, "StandBy", &NrvRailMoveMapParts.mCollector, 1);
initMapPartsActor(this, info, nullptr);
registerAreaHostMtx(this, info);

if (isExistRail(this)) {
f32 radius = getClippingRadius(this);
setSyncRailToNearestPos(this);
mRailCoord = getRailCoord(this);
setRailClippingInfo(&mRailPos, this, 100.0f, radius);
}

RailMoveMovement* railMoveMovement = new RailMoveMovement(this, info);
initNerveState(this, railMoveMovement, NrvRailMoveMapParts.Move.data(), "レール移動");
initMaterialCode(this, info);

if (!listenStageSwitchOnStart(this, RailMoveMapPartsFunctor(this, &RailMoveMapParts::start)))
start();

if (listenStageSwitchOnStop(this, RailMoveMapPartsFunctor(this, &RailMoveMapParts::stop)))
stop();

mSwitchKeepOnAreaGroup = tryCreateSwitchKeepOnAreaGroup(this, info);
mSwitchOnAreaGroup = tryCreateSwitchOnAreaGroup(this, info);

trySyncStageSwitchAppear(this);
tryListenStageSwitchKill(this);
}

void RailMoveMapParts::start() {
if (isNerve(this, NrvRailMoveMapParts.StandBy.data()))
startNerveAction(this, "MoveSign");
}

void RailMoveMapParts::stop() {
if (isNerve(this, NrvRailMoveMapParts.Move.data()))
startNerveAction(this, "StandBy");
}

bool RailMoveMapParts::receiveMsg(const SensorMsg* message, HitSensor* other, HitSensor* self) {
if (isMsgShowModel(message)) {
showModelIfHide(this);

return true;
}

if (isMsgHideModel(message)) {
hideModelIfShow(this);

return true;
}

return false;
}

void RailMoveMapParts::control() {
if (mSwitchKeepOnAreaGroup != nullptr)
mSwitchKeepOnAreaGroup->update(getTrans(this));

if (mSwitchOnAreaGroup != nullptr)
mSwitchOnAreaGroup->update(getTrans(this));
}

void RailMoveMapParts::appearAndSetStart() {
setSyncRailToCoord(this, mRailCoord);
startNerveAction(this, "MoveSign");
}

void RailMoveMapParts::exeStandBy() {}

void RailMoveMapParts::exeMoveSign() {
if ((isFirstStep(this) && !tryStartAction(this, "MoveSign")) || isActionEnd(this))
startNerveAction(this, "Move");
}

void RailMoveMapParts::exeMove() {
updateNerveState(this);
}
} // namespace al
32 changes: 32 additions & 0 deletions lib/al/Library/MapObj/RailMoveMapParts.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#pragma once

#include "Library/LiveActor/LiveActor.h"

namespace al {
class SwitchKeepOnAreaGroup;
class SwitchOnAreaGroup;

class RailMoveMapParts : public LiveActor {
public:
RailMoveMapParts(const char* name);

void init(const ActorInitInfo& info) override;
void start();
void stop();
bool receiveMsg(const SensorMsg* message, HitSensor* other, HitSensor* self) override;
void control() override;
void appearAndSetStart();

void exeStandBy();
void exeMoveSign();
void exeMove();

private:
SwitchKeepOnAreaGroup* mSwitchKeepOnAreaGroup = nullptr;
SwitchOnAreaGroup* mSwitchOnAreaGroup = nullptr;
sead::Vector3f mRailPos = {0.0f, 0.0f, 0.0f};
f32 mRailCoord = 0.0f;
};

static_assert(sizeof(RailMoveMapParts) == 0x128);
} // namespace al
2 changes: 2 additions & 0 deletions lib/al/Library/Rail/RailUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ class IUseRail;
class LiveActor;

void setSyncRailToNearestPos(LiveActor* actor);
void setSyncRailToCoord(LiveActor* actor, f32 coord);
void setRailPosToStart(IUseRail* railHolder);
void moveSyncRail(LiveActor* actor, f32 speed);
void moveSyncRailLoop(LiveActor* actor, f32 speed);
void moveSyncRailTurn(LiveActor* actor, f32 speed);
void calcRailUp(sead::Vector3f* out, IUseRail* railHolder);
const sead::Vector3f& getRailDir(IUseRail* railHolder);
f32 getRailCoord(IUseRail* railHolder);
bool isExistRail(IUseRail* railHolder);
void setRailClippingInfo(sead::Vector3f*, LiveActor* actor, f32, f32);
} // namespace al
1 change: 1 addition & 0 deletions lib/al/Library/Stage/StageSwitchKeeper.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ bool listenStageSwitchOnKill(IUseStageSwitch* stageSwitchHolder, const FunctorBa
bool listenStageSwitchOnOffKill(IUseStageSwitch* stageSwitchHolder, const FunctorBase& actionOnOn,
const FunctorBase& actionOnOff);
bool listenStageSwitchOnStart(IUseStageSwitch* stageSwitchHolder, const FunctorBase& actionOnOn);
bool listenStageSwitchOnStop(IUseStageSwitch* stageSwitchHolder, const FunctorBase& actionOnOn);
} // namespace al
3 changes: 2 additions & 1 deletion src/Scene/ProjectActorFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "Library/MapObj/KeyMoveMapParts.h"
#include "Library/MapObj/KeyMoveMapPartsGenerator.h"
#include "Library/MapObj/OneMeshFixMapParts.h"
#include "Library/MapObj/RailMoveMapParts.h"
#include "Library/MapObj/RollingCubeMapParts.h"
#include "Library/MapObj/SurfMapParts.h"
#include "Library/Obj/AllDeadWatcher.h"
Expand Down Expand Up @@ -567,7 +568,7 @@ static al::NameToCreator<al::ActorCreatorFunction> sProjectActorFactoryEntries[]
{"Pukupuku", nullptr},
{"PulseSwitch", nullptr},
{"RailCollision", nullptr},
{"RailMoveMapParts", nullptr},
{"RailMoveMapParts", al::createActorFunction<al::RailMoveMapParts>},
{"RiseMapParts", nullptr},
{"ReactionMapParts", nullptr},
{"RiseMapPartsHolder", nullptr},
Expand Down

0 comments on commit e4e8883

Please sign in to comment.