diff --git a/data/file_list.yml b/data/file_list.yml index 64c53263..f99f9339 100644 --- a/data/file_list.yml +++ b/data/file_list.yml @@ -44786,76 +44786,76 @@ Event/EventActorMovementRailTraffic.o: label: - _ZN29EventActorMovementRailTrafficC1EPKcPN2al9LiveActorE - _ZN29EventActorMovementRailTrafficC2EPKcPN2al9LiveActorE - status: NotDecompiled + status: Matching - offset: 0x1aec98 size: 156 label: _ZN29EventActorMovementRailTraffic4initERKN2al13ActorInitInfoE - status: NotDecompiled + status: Matching - offset: 0x1aed34 size: 52 label: _ZN29EventActorMovementRailTraffic6appearEv - status: NotDecompiled + status: Matching - offset: 0x1aed68 size: 68 label: _ZN29EventActorMovementRailTraffic7exeMoveEv - status: NotDecompiled + status: Matching - offset: 0x1aedac size: 100 label: _ZN29EventActorMovementRailTraffic17exeStopByOtherNpcEv - status: NotDecompiled + status: Matching - offset: 0x1aee10 size: 20 label: _ZN29EventActorMovementRailTraffic12exeStopAfterEv - status: NotDecompiled + status: Matching - offset: 0x1aee24 size: 8 label: _ZNK2al17EventFlowMovement22getEventFlowDataHolderEv - status: NotDecompiled + status: Matching lazy: true - offset: 0x1aee2c size: 4 label: _ZN2al17EventFlowMovement4killEv - status: NotDecompiled + status: Matching lazy: true - offset: 0x1aee30 size: 4 label: _ZN2al17EventFlowMovement7controlEv - status: NotDecompiled + status: Matching lazy: true - offset: 0x1aee34 size: 8 label: _ZNK2al17EventFlowMovement14getNerveKeeperEv - status: NotDecompiled + status: Matching lazy: true - offset: 0x1aee3c size: 8 label: _ZNK2al17EventFlowMovement14isTurnMovementEv - status: NotDecompiled + status: Matching lazy: true - offset: 0x1aee44 size: 8 label: _ZNK2al17EventFlowMovement21isWaitAtPointMovementEv - status: NotDecompiled + status: Matching lazy: true - offset: 0x1aee4c size: 8 label: _ZThn8_NK2al17EventFlowMovement14getNerveKeeperEv - status: NotDecompiled + status: Matching lazy: true - offset: 0x1aee54 size: 80 label: _ZNK12_GLOBAL__N_136EventActorMovementRailTrafficNrvMove7executeEPN2al11NerveKeeperE - status: NotDecompiled + status: Matching guess: true - offset: 0x1aeea4 size: 112 label: _ZNK12_GLOBAL__N_146EventActorMovementRailTrafficNrvStopByOtherNpc7executeEPN2al11NerveKeeperE - status: NotDecompiled + status: Matching guess: true - offset: 0x1aef14 size: 36 label: _ZNK12_GLOBAL__N_141EventActorMovementRailTrafficNrvStopAfter7executeEPN2al11NerveKeeperE - status: NotDecompiled + status: Matching guess: true Event/EventActorMovementTurn.o: '.text': diff --git a/lib/al/Library/Event/EventFlowActorStateRail.h b/lib/al/Library/Event/EventFlowActorStateRail.h new file mode 100644 index 00000000..781eb66e --- /dev/null +++ b/lib/al/Library/Event/EventFlowActorStateRail.h @@ -0,0 +1,27 @@ +#pragma once + +#include +#include + +#include "Project/Event/EventFlowActorStateBase.h" + +namespace al { +struct ActorInitInfo; +class EventFlowMovement; + +class EventFlowActorStateRail : public EventFlowActorStateBase { +public: + EventFlowActorStateRail(const char* name, EventFlowMovement* movement); + + void initByPlacementInfo(const ActorInitInfo& info); + void appear() override; + void exeWalk(); + void exeTurn(); + +private: + sead::Vector3f mRailOffset = sead::Vector3f::zero; + s32 mRailMoveType = -1; +}; + +static_assert(sizeof(EventFlowActorStateRail) == 0x38); +} // namespace al diff --git a/lib/al/Library/Event/EventFlowMovement.h b/lib/al/Library/Event/EventFlowMovement.h new file mode 100644 index 00000000..2ce3ee82 --- /dev/null +++ b/lib/al/Library/Event/EventFlowMovement.h @@ -0,0 +1,46 @@ +#pragma once + +#include + +#include "Library/Event/IUseEventFlowData.h" +#include "Library/Nerve/IUseNerve.h" + +namespace al { +struct ActorInitInfo; +class EventFlowDataHolder; +class LiveActor; +class Nerve; +class NerveKeeper; + +class EventFlowMovement : public IUseEventFlowData, public IUseNerve { +public: + EventFlowMovement(const char* name, LiveActor* actor); + + void movement(); + void initNerve(const Nerve* nerve, s32 stateCount); + + virtual void init(const ActorInitInfo& info) = 0; + + virtual void kill() {} + + virtual void appear() {} + + virtual void control() {} + + NerveKeeper* getNerveKeeper() const override { return mNerveKeeper; } + + virtual bool isTurnMovement() const { return false; } + + virtual bool isWaitAtPointMovement() const { return false; } + + EventFlowDataHolder* getEventFlowDataHolder() const override { return mEventFlowDataHolder; } + +protected: + const char* mName = nullptr; + LiveActor* mActor = nullptr; + NerveKeeper* mNerveKeeper = nullptr; + EventFlowDataHolder* mEventFlowDataHolder = nullptr; +}; + +static_assert(sizeof(EventFlowMovement) == 0x30); +} // namespace al diff --git a/src/Event/EventActorMovementRailTraffic.cpp b/src/Event/EventActorMovementRailTraffic.cpp new file mode 100644 index 00000000..f54e671c --- /dev/null +++ b/src/Event/EventActorMovementRailTraffic.cpp @@ -0,0 +1,52 @@ +#include "Event/EventActorMovementRailTraffic.h" + +#include "Library/Event/EventFlowActorStateRail.h" +#include "Library/Event/EventFlowUtil.h" +#include "Library/Nerve/NerveSetupUtil.h" +#include "Library/Nerve/NerveUtil.h" + +#include "Npc/TrafficRailWatcherDirector.h" + +namespace { +NERVE_IMPL(EventActorMovementRailTraffic, Move); +NERVE_IMPL(EventActorMovementRailTraffic, StopByOtherNpc); +NERVE_IMPL(EventActorMovementRailTraffic, StopAfter); + +NERVES_MAKE_NOSTRUCT(EventActorMovementRailTraffic, Move, StopByOtherNpc, StopAfter); +} // namespace + +EventActorMovementRailTraffic::EventActorMovementRailTraffic(const char* name, al::LiveActor* actor) + : al::EventFlowMovement(name, actor) {} + +void EventActorMovementRailTraffic::init(const al::ActorInitInfo& info) { + initNerve(&Move, 1); + + al::EventFlowActorStateRail* railState = new al::EventFlowActorStateRail("", this); + railState->initByPlacementInfo(info); + al::initNerveState(this, railState, &Move, ""); + rs::registerTrafficRailWatcher(mActor, info); + appear(); +} + +void EventActorMovementRailTraffic::appear() { + al::setNerve(this, getNerveKeeper()->getCurrentNerve()); +} + +void EventActorMovementRailTraffic::exeMove() { + if (rs::tryStopTrafficRailByOtherNpc(mActor)) + al::setNerve(this, &StopByOtherNpc); + else + al::updateNerveState(this); +} + +void EventActorMovementRailTraffic::exeStopByOtherNpc() { + if (al::isFirstStep(this)) + al::tryStartEventActionIfNotPlaying(mActor, this, "Wait"); + + if (rs::tryRestartTrafficRailByOtherNpc(mActor)) + al::setNerve(this, &StopAfter); +} + +void EventActorMovementRailTraffic::exeStopAfter() { + al::setNerveAtGreaterEqualStep(this, &Move, 20); +} diff --git a/src/Event/EventActorMovementRailTraffic.h b/src/Event/EventActorMovementRailTraffic.h new file mode 100644 index 00000000..8f158f4a --- /dev/null +++ b/src/Event/EventActorMovementRailTraffic.h @@ -0,0 +1,22 @@ +#pragma once + +#include "Library/Event/EventFlowMovement.h" + +namespace al { +struct ActorInitInfo; +class LiveActor; +} // namespace al + +class EventActorMovementRailTraffic : public al::EventFlowMovement { +public: + EventActorMovementRailTraffic(const char* name, al::LiveActor* actor); + + void init(const al::ActorInitInfo& info) override; + void appear() override; + + void exeMove(); + void exeStopByOtherNpc(); + void exeStopAfter(); +}; + +static_assert(sizeof(EventActorMovementRailTraffic) == 0x30); diff --git a/src/Npc/TrafficRailWatcherDirector.h b/src/Npc/TrafficRailWatcherDirector.h new file mode 100644 index 00000000..f032b037 --- /dev/null +++ b/src/Npc/TrafficRailWatcherDirector.h @@ -0,0 +1,36 @@ +#pragma once + +#include + +#include "Library/HostIO/HioNode.h" +#include "Library/Scene/ISceneObj.h" + +class TrafficRailWatcher; + +namespace al { +struct ActorInitInfo; +class LiveActor; +} // namespace al + +class TrafficRailWatcherDirector : public al::HioNode, public al::ISceneObj { +public: + TrafficRailWatcherDirector(); + + void* registerActor(const al::LiveActor* actor, const al::ActorInitInfo& info); + TrafficRailWatcher* findActorRailWatcher(const al::LiveActor* actor) const; + const char* getSceneObjName() const override; + +private: + s32 mWatcherCount = 0; + TrafficRailWatcher** mWatchers = nullptr; +}; + +static_assert(sizeof(TrafficRailWatcherDirector) == 0x18); + +namespace rs { +void* registerTrafficRailWatcher(const al::LiveActor* actor, const al::ActorInitInfo& info); +void stopTrafficRailByTraffic(const al::LiveActor* actor); +void restartTrafficRailByTraffic(const al::LiveActor* actor); +bool tryStopTrafficRailByOtherNpc(const al::LiveActor* actor); +bool tryRestartTrafficRailByOtherNpc(const al::LiveActor* actor); +} // namespace rs diff --git a/src/Project/Event/EventFlowActorStateBase.h b/src/Project/Event/EventFlowActorStateBase.h new file mode 100644 index 00000000..789d02dc --- /dev/null +++ b/src/Project/Event/EventFlowActorStateBase.h @@ -0,0 +1,23 @@ +#pragma once + +#include "Library/Event/IUseEventFlowData.h" +#include "Library/Nerve/NerveStateBase.h" + +namespace al { +class EventFlowDataHolder; +class EventFlowMovement; +class LiveActor; + +class EventFlowActorStateBase : public NerveStateBase, public IUseEventFlowData { +public: + EventFlowActorStateBase(const char* name, EventFlowMovement* movement); + + LiveActor* getActor() const; + EventFlowDataHolder* getEventFlowDataHolder() const override; + +protected: + EventFlowMovement* mMovement = nullptr; +}; + +static_assert(sizeof(EventFlowActorStateBase) == 0x28); +} // namespace al