From df3e9cacb8d882893a6e67711f816d51f85e5371 Mon Sep 17 00:00:00 2001 From: Nicholas Yoannou Date: Thu, 28 May 2026 21:21:02 +0100 Subject: [PATCH 1/2] Item: Implement `YoshiFruitShineHolder` --- data/file_list.yml | 10 +++---- src/Item/YoshiFruitShineHolder.cpp | 42 ++++++++++++++++++++++++++++++ src/Item/YoshiFruitShineHolder.h | 32 +++++++++++++++++++++++ 3 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 src/Item/YoshiFruitShineHolder.cpp create mode 100644 src/Item/YoshiFruitShineHolder.h 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..7358fb2aec --- /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); +} + +al::LiveActor* 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..0e246be1a2 --- /dev/null +++ b/src/Item/YoshiFruitShineHolder.h @@ -0,0 +1,32 @@ +#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); + al::LiveActor* appearShineFromFruit(const sead::Vector3f& pos); + +private: + sead::PtrArray mShines; + s32 mAppearedCount = 0; +}; + +static_assert(sizeof(YoshiFruitShineHolder) == 0x120); + +namespace rs { +void registerFruitShineHolder(YoshiFruitShineHolder*); +} // namespace rs From 0a0edf88b1bd0dbc68d5135d04cc58ecad52adc2 Mon Sep 17 00:00:00 2001 From: Nicholas Yoannou Date: Thu, 28 May 2026 23:20:19 +0100 Subject: [PATCH 2/2] Address review: return Shine*, move registerFruitShineHolder to ItemUtil.h --- src/Item/YoshiFruitShineHolder.cpp | 2 +- src/Item/YoshiFruitShineHolder.h | 6 +----- src/Util/ItemUtil.h | 2 ++ 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Item/YoshiFruitShineHolder.cpp b/src/Item/YoshiFruitShineHolder.cpp index 7358fb2aec..12056b7449 100644 --- a/src/Item/YoshiFruitShineHolder.cpp +++ b/src/Item/YoshiFruitShineHolder.cpp @@ -32,7 +32,7 @@ void YoshiFruitShineHolder::updateHintPos(const sead::Vector3f& pos) { rs::updateHintTrans(&shine, pos); } -al::LiveActor* YoshiFruitShineHolder::appearShineFromFruit(const sead::Vector3f& pos) { +Shine* YoshiFruitShineHolder::appearShineFromFruit(const sead::Vector3f& pos) { Shine* shine = mShines[mAppearedCount]; al::resetPosition(shine, pos); diff --git a/src/Item/YoshiFruitShineHolder.h b/src/Item/YoshiFruitShineHolder.h index 0e246be1a2..76b3d1ab23 100644 --- a/src/Item/YoshiFruitShineHolder.h +++ b/src/Item/YoshiFruitShineHolder.h @@ -18,7 +18,7 @@ class YoshiFruitShineHolder : public al::LiveActor { void init(const al::ActorInitInfo& info) override; void updateHintPos(const sead::Vector3f& pos); - al::LiveActor* appearShineFromFruit(const sead::Vector3f& pos); + Shine* appearShineFromFruit(const sead::Vector3f& pos); private: sead::PtrArray mShines; @@ -26,7 +26,3 @@ class YoshiFruitShineHolder : public al::LiveActor { }; static_assert(sizeof(YoshiFruitShineHolder) == 0x120); - -namespace rs { -void registerFruitShineHolder(YoshiFruitShineHolder*); -} // namespace rs 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);