From 9b4e0cfdedbbfd918762a0e3a6fdf6e833b7cf82 Mon Sep 17 00:00:00 2001 From: fallenoak Date: Wed, 29 Oct 2025 17:16:05 -0500 Subject: [PATCH] feat(component): add CCharacterComponent::AddItem --- src/component/CCharacterComponent.cpp | 56 +++++++++++++++++++++++++++ src/component/CCharacterComponent.hpp | 2 + 2 files changed, 58 insertions(+) diff --git a/src/component/CCharacterComponent.cpp b/src/component/CCharacterComponent.cpp index 2a9aca1..fa7eb88 100644 --- a/src/component/CCharacterComponent.cpp +++ b/src/component/CCharacterComponent.cpp @@ -440,6 +440,62 @@ void CCharacterComponent::UpdateBaseTexture(EGxTexCommand cmd, uint32_t width, u } } +void CCharacterComponent::AddItem(ITEM_SLOT itemSlot, const ItemDisplayInfoRec* displayRec, int32_t a4) { + this->m_flags |= 0x4; + + this->m_items[itemSlot] = displayRec->m_ID; + + // Helm + + if (itemSlot == ITEMSLOT_0) { + // TODO handle helm + + return; + } + + // Shoulders + + if (itemSlot == ITEMSLOT_1) { + // TODO handle shoulders + + return; + } + + // Cape + + if (itemSlot == ITEMSLOT_10) { + // TODO handle cape + + return; + } + + // Unk + + if (itemSlot == ITEMSLOT_11) { + // TODO handle unknown item + + return; + } + + if (itemSlot == ITEMSLOT_3) { + // TODO flag manipulation + } + + bool isNPC = this->m_data.flags & 0x1; + + if (isNPC) { + return; + } + + // Items don't manipulate head component sections + + for (int32_t section = SECTION_ARM_UPPER; section <= SECTION_FOOT; section++) { + if (*displayRec->m_texture[section] && s_itemPriority[itemSlot][section] != -1) { + (this->*CCharacterComponent::s_itemFunc[section])(itemSlot, displayRec, true); + } + } +} + void CCharacterComponent::ClearItemDisplay(COMPONENT_SECTIONS section, int32_t priority) { if (priority == -1) { return; diff --git a/src/component/CCharacterComponent.hpp b/src/component/CCharacterComponent.hpp index 9ea19ab..1a46061 100644 --- a/src/component/CCharacterComponent.hpp +++ b/src/component/CCharacterComponent.hpp @@ -70,8 +70,10 @@ class CCharacterComponent { HTEXTURE m_baseTexture = nullptr; void* m_texture[NUM_COMPONENT_VARIATIONS * 3] = {}; ComponentItemDisplay m_itemDisplays[NUM_COMPONENT_SECTIONS] = {}; + int32_t m_items[NUM_ITEM_SLOT] = {}; // Member functions + void AddItem(ITEM_SLOT itemSlot, const ItemDisplayInfoRec* displayRec, int32_t a4); void ClearItemDisplay(COMPONENT_SECTIONS section, int32_t priority); void CreateBaseTexture(); void GeosRenderPrep();