diff --git a/data/file_list.yml b/data/file_list.yml index 64c53263..7931b985 100644 --- a/data/file_list.yml +++ b/data/file_list.yml @@ -81596,81 +81596,81 @@ MapObj/RhyhtmInfoWatcher.o: - offset: 0x2f7050 size: 160 label: _ZN17RhyhtmInfoWatcherC2EPKc - status: NotDecompiled + status: Matching - offset: 0x2f70f0 size: 156 label: _ZN17RhyhtmInfoWatcherC1EPKc - status: NotDecompiled + status: Matching - offset: 0x2f718c size: 92 label: _ZN17RhyhtmInfoWatcher26initAfterPlacementSceneObjERKN2al13ActorInitInfoE - status: NotDecompiled + status: Matching - offset: 0x2f71e8 size: 108 label: _ZThn264_N17RhyhtmInfoWatcher26initAfterPlacementSceneObjERKN2al13ActorInitInfoE - status: NotDecompiled + status: Matching - offset: 0x2f7254 size: 84 label: _ZN17RhyhtmInfoWatcher7controlEv - status: NotDecompiled + status: Matching - offset: 0x2f72a8 size: 20 label: _ZN17RhyhtmInfoWatcher9loopCheckEv - status: NotDecompiled + status: Matching - offset: 0x2f72bc size: 36 label: _ZN2rs11getInstanceEPN2al18IUseSceneObjHolderE - status: NotDecompiled + status: Matching - offset: 0x2f72e0 size: 60 label: _ZN2rs26registerRhyhtmInfoListenerEPN2al18IUseSceneObjHolderE - status: NotDecompiled + status: Matching - offset: 0x2f731c size: 44 label: _ZN2rs14getCurrentBeatEPN2al18IUseSceneObjHolderE - status: NotDecompiled + status: Matching - offset: 0x2f7348 size: 44 label: _ZN2rs12getBeatDeltaEPN2al18IUseSceneObjHolderE - status: NotDecompiled + status: Matching - offset: 0x2f7374 size: 44 label: _ZN2rs9isLoopingEPN2al18IUseSceneObjHolderE - status: NotDecompiled + status: Matching - offset: 0x2f73a0 size: 8 label: _ZNK17RhyhtmInfoWatcher14getCurrentBeatEv - status: NotDecompiled + status: Matching lazy: true - offset: 0x2f73a8 size: 16 label: _ZNK17RhyhtmInfoWatcher12getBeatDeltaEv - status: NotDecompiled + status: Matching lazy: true - offset: 0x2f73b8 size: 8 label: _ZNK17RhyhtmInfoWatcher9isLoopingEv - status: NotDecompiled + status: Matching lazy: true - offset: 0x2f73c0 size: 4 label: _ZN17RhyhtmInfoWatcherD1Ev - status: NotDecompiled + status: Matching lazy: true - offset: 0x2f73c4 size: 4 label: _ZN17RhyhtmInfoWatcherD0Ev - status: NotDecompiled + status: Matching lazy: true - offset: 0x2f73c8 size: 4 label: _ZThn264_N17RhyhtmInfoWatcherD1Ev - status: NotDecompiled + status: Matching lazy: true - offset: 0x2f73cc size: 8 label: _ZThn264_N17RhyhtmInfoWatcherD0Ev - status: NotDecompiled + status: Matching lazy: true MapObj/RhythmSpotlight.o: '.text': diff --git a/src/MapObj/RhyhtmInfoWatcher.cpp b/src/MapObj/RhyhtmInfoWatcher.cpp new file mode 100644 index 00000000..5f112f4a --- /dev/null +++ b/src/MapObj/RhyhtmInfoWatcher.cpp @@ -0,0 +1,72 @@ +#include "MapObj/RhyhtmInfoWatcher.h" + +#include "Library/Bgm/BgmLineFunction.h" +#include "Library/LiveActor/ActorInitFunction.h" +#include "Library/Scene/SceneObjUtil.h" + +RhyhtmInfoWatcher::RhyhtmInfoWatcher(const char* name) : al::LiveActor(name) {} + +void RhyhtmInfoWatcher::initAfterPlacementSceneObj(const al::ActorInitInfo& info) { + al::initActorSceneInfo(this, info); + al::initExecutorWatchObj(this, info); + al::initActorBgmKeeper(this, info, nullptr); + getSceneObjName(); + makeActorAlive(); +} + +void RhyhtmInfoWatcher::control() { + const al::IUseAudioKeeper* audioKeeper = this; + + if (!al::isEnableRhythmAnim(audioKeeper, nullptr)) + return; + + mPreviousBeat = mCurrentBeat; + + f32 currentBeat = al::getCurBeat(audioKeeper); + + mCurrentBeat = currentBeat; + mIsLooping = loopCheck(); +} + +bool RhyhtmInfoWatcher::loopCheck() { + return !(mPreviousBeat <= mCurrentBeat); +} + +f32 RhyhtmInfoWatcher::getCurrentBeat() const { + return mCurrentBeat; +} + +f32 RhyhtmInfoWatcher::getBeatDelta() const { + return mCurrentBeat - mPreviousBeat; +} + +bool RhyhtmInfoWatcher::isLooping() const { + return mIsLooping; +} + +namespace rs { + +RhyhtmInfoWatcher* getInstance(al::IUseSceneObjHolder* holder) { + return al::getSceneObj(holder); +} + +void registerRhyhtmInfoListener(al::IUseSceneObjHolder* holder) { + if (al::isExistSceneObj(holder, SceneObjID_RhyhtmInfoWatcher)) + return; + + al::createSceneObj(holder, SceneObjID_RhyhtmInfoWatcher); +} + +f32 getCurrentBeat(al::IUseSceneObjHolder* holder) { + return al::getSceneObj(holder)->getCurrentBeat(); +} + +f32 getBeatDelta(al::IUseSceneObjHolder* holder) { + return al::getSceneObj(holder)->getBeatDelta(); +} + +bool isLooping(al::IUseSceneObjHolder* holder) { + return al::getSceneObj(holder)->isLooping(); +} + +} // namespace rs diff --git a/src/MapObj/RhyhtmInfoWatcher.h b/src/MapObj/RhyhtmInfoWatcher.h new file mode 100644 index 00000000..7ac86029 --- /dev/null +++ b/src/MapObj/RhyhtmInfoWatcher.h @@ -0,0 +1,44 @@ +#pragma once + +#include + +#include "Library/LiveActor/LiveActor.h" +#include "Library/Scene/ISceneObj.h" + +#include "Scene/SceneObjFactory.h" + +namespace al { +struct ActorInitInfo; +class IUseSceneObjHolder; +} // namespace al + +class RhyhtmInfoWatcher : public al::LiveActor, public al::ISceneObj { +public: + static constexpr s32 sSceneObjId = SceneObjID_RhyhtmInfoWatcher; + + RhyhtmInfoWatcher(const char* name); + + void initAfterPlacementSceneObj(const al::ActorInitInfo& info) override; + void control() override; + + virtual f32 getCurrentBeat() const; + virtual f32 getBeatDelta() const; + virtual bool isLooping() const; + +private: + bool loopCheck(); + + f32 mCurrentBeat = -1.0f; + f32 mPreviousBeat = -1.0f; + bool mIsLooping = false; +}; + +static_assert(sizeof(RhyhtmInfoWatcher) == 0x120); + +namespace rs { +RhyhtmInfoWatcher* getInstance(al::IUseSceneObjHolder* holder); +void registerRhyhtmInfoListener(al::IUseSceneObjHolder* holder); +f32 getCurrentBeat(al::IUseSceneObjHolder* holder); +f32 getBeatDelta(al::IUseSceneObjHolder* holder); +bool isLooping(al::IUseSceneObjHolder* holder); +} // namespace rs diff --git a/src/Scene/SceneObjFactory.cpp b/src/Scene/SceneObjFactory.cpp index 5c457e24..4e297b5e 100644 --- a/src/Scene/SceneObjFactory.cpp +++ b/src/Scene/SceneObjFactory.cpp @@ -9,6 +9,7 @@ #include "Item/CoinCollectHolder.h" #include "Item/CoinCollectWatcher.h" #include "Layout/KidsModeLayoutAccessor.h" +#include "MapObj/RhyhtmInfoWatcher.h" #include "MapObj/RouteGuideDirector.h" #include "Scene/HintPhotoLayoutHolder.h" @@ -84,7 +85,7 @@ static al::ISceneObj* sceneObjCreator(s32 id) { return nullptr; case SceneObjID_RhyhtmInfoWatcher: - return nullptr; + return new RhyhtmInfoWatcher(""); case SceneObjID_RouteGuideDirector: return new RouteGuideDirector();