diff --git a/data/file_list.yml b/data/file_list.yml index fc06e492aa..c657d62055 100644 --- a/data/file_list.yml +++ b/data/file_list.yml @@ -50844,23 +50844,23 @@ Item/YoshiFruitShineHolder.o: - offset: 0x1d7b28 size: 128 label: _ZN21YoshiFruitShineHolderC2EPKc - status: NotDecompiled + status: Matching - offset: 0x1d7ba8 size: 140 label: _ZN21YoshiFruitShineHolderC1EPKc - status: NotDecompiled + status: Matching - offset: 0x1d7c34 size: 228 label: _ZN21YoshiFruitShineHolder4initERKN2al13ActorInitInfoE - status: NotDecompiled + status: Matching - offset: 0x1d7d18 size: 72 label: _ZN21YoshiFruitShineHolder13updateHintPosERKN4sead7Vector3IfEE - status: NotDecompiled + status: Matching - offset: 0x1d7d60 size: 92 label: _ZN21YoshiFruitShineHolder20appearShineFromFruitERKN4sead7Vector3IfEE - status: NotDecompiled + status: Matching Item/YoshiFruitWatcher.o: '.text': - offset: 0x1d7dbc diff --git a/src/Item/YoshiFruitShineHolder.cpp b/src/Item/YoshiFruitShineHolder.cpp new file mode 100644 index 0000000000..12056b7449 --- /dev/null +++ b/src/Item/YoshiFruitShineHolder.cpp @@ -0,0 +1,42 @@ +#include "Item/YoshiFruitShineHolder.h" + +#include "Library/LiveActor/ActorInitFunction.h" +#include "Library/LiveActor/ActorMovementFunction.h" +#include "Library/Placement/PlacementFunction.h" + +#include "Item/Shine.h" +#include "Util/ItemUtil.h" + +YoshiFruitShineHolder::YoshiFruitShineHolder(const char* name) : al::LiveActor(name) {} + +void YoshiFruitShineHolder::init(const al::ActorInitInfo& info) { + al::initActorSceneInfo(this, info); + + s32 shineNum = al::calcLinkChildNum(info, "ShineFromFruit"); + mAppearedCount = 0; + mShines.allocBuffer(shineNum, nullptr); + + for (s32 i = 0; i < shineNum; i++) { + Shine* shine = rs::initLinkShine(info, "ShineFromFruit", i); + mShines.pushBack(shine); + if (shine->isGot()) + mAppearedCount++; + } + + rs::registerFruitShineHolder(this); + makeActorAlive(); +} + +void YoshiFruitShineHolder::updateHintPos(const sead::Vector3f& pos) { + for (Shine& shine : mShines) + rs::updateHintTrans(&shine, pos); +} + +Shine* YoshiFruitShineHolder::appearShineFromFruit(const sead::Vector3f& pos) { + Shine* shine = mShines[mAppearedCount]; + + al::resetPosition(shine, pos); + shine->appearStatic(); + mAppearedCount++; + return shine; +} diff --git a/src/Item/YoshiFruitShineHolder.h b/src/Item/YoshiFruitShineHolder.h new file mode 100644 index 0000000000..76b3d1ab23 --- /dev/null +++ b/src/Item/YoshiFruitShineHolder.h @@ -0,0 +1,28 @@ +#pragma once + +#include +#include +#include + +#include "Library/LiveActor/LiveActor.h" + +namespace al { +struct ActorInitInfo; +} // namespace al + +class Shine; + +class YoshiFruitShineHolder : public al::LiveActor { +public: + YoshiFruitShineHolder(const char* name); + + void init(const al::ActorInitInfo& info) override; + void updateHintPos(const sead::Vector3f& pos); + Shine* appearShineFromFruit(const sead::Vector3f& pos); + +private: + sead::PtrArray mShines; + s32 mAppearedCount = 0; +}; + +static_assert(sizeof(YoshiFruitShineHolder) == 0x120); diff --git a/src/Util/ItemUtil.h b/src/Util/ItemUtil.h index b428ca4cf0..3f3b9953bc 100644 --- a/src/Util/ItemUtil.h +++ b/src/Util/ItemUtil.h @@ -11,6 +11,7 @@ class HitSensor; class SensorMsg; } // namespace al class Shine; +class YoshiFruitShineHolder; namespace rs { // TODO: Replace this with SEAD_ENUM_EX when its ValueArray constructor matches @@ -61,6 +62,7 @@ bool isAliveShine(const Shine* shine); bool isMainShine(const Shine* shine); void updateHintTrans(const Shine* shine, const sead::Vector3f& trans); +void registerFruitShineHolder(YoshiFruitShineHolder* holder); void appearShineAndJoinBossDemo(Shine* shine, const char* name, const sead::Quatf& quat, const sead::Vector3f& trans); void endShineBossDemo(Shine* shine);