From 95c89c50b9a9319b1ae6df536c7ff84ff0e88f74 Mon Sep 17 00:00:00 2001 From: fallenoak Date: Mon, 27 Oct 2025 22:14:57 -0500 Subject: [PATCH] feat(component): add CCharacterComponent::SetBeardStyle --- src/component/CCharacterComponent.cpp | 48 +++++++++++++++++++++++++-- src/component/CCharacterComponent.hpp | 3 +- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/component/CCharacterComponent.cpp b/src/component/CCharacterComponent.cpp index 1f34f79..3ba05c8 100644 --- a/src/component/CCharacterComponent.cpp +++ b/src/component/CCharacterComponent.cpp @@ -714,7 +714,7 @@ CharSectionsRec* CCharacterComponent::GetSectionsRecord(COMPONENT_VARIATIONS sec ); } -void CCharacterComponent::Init(ComponentData* data, const char* a3) { +int32_t CCharacterComponent::Init(ComponentData* data, const char* a3) { if (data->model) { data->model->Release(); } @@ -725,8 +725,9 @@ void CCharacterComponent::Init(ComponentData* data, const char* a3) { this->SetSkinColor(this->m_data.skinColorID, false, true, a3); this->SetHairStyle(this->m_data.hairStyleID, a3); + this->SetBeardStyle(this->m_data.facialHairStyleID, false, a3); - // TODO + return 1; } int32_t CCharacterComponent::ItemsLoaded(int32_t a2) { @@ -874,6 +875,49 @@ void CCharacterComponent::ReplaceHairTexture(int32_t hairStyleID, const char* a3 } } +void CCharacterComponent::SetBeardStyle(int32_t facialHairStyleID, bool a3, const char* a4) { + auto listIndex = this->m_data.raceID * 2 + this->m_data.sexID; + if (facialHairStyleID < 0 || facialHairStyleID > CCharacterComponent::s_characterFacialHairStylesList[listIndex]) { + return; + } + + this->m_data.facialHairStyleID = facialHairStyleID; + + auto facialHairStyleRec = ComponentGetFacialHairStyleRecord(&this->m_data); + + if (facialHairStyleRec) { + this->m_data.geosets[1] = 100 + facialHairStyleRec->m_geoset[0]; + this->m_data.geosets[2] = 200 + facialHairStyleRec->m_geoset[2]; + this->m_data.geosets[3] = 300 + facialHairStyleRec->m_geoset[1]; + this->m_data.geosets[16] = 1600 + facialHairStyleRec->m_geoset[3]; + this->m_data.geosets[17] = 1700 + facialHairStyleRec->m_geoset[4]; + + this->m_flags |= 0x4; + + if ( + (facialHairStyleRec->m_geoset[0] || facialHairStyleRec->m_geoset[1] || facialHairStyleRec->m_geoset[2]) + && (!this->m_texture[TEXTURE_INDEX(VARIATION_HAIR, 1)] || !this->m_texture[TEXTURE_INDEX(VARIATION_HAIR, 2)]) + ) { + this->ReplaceHairTexture(1, a4); + } + } + + bool isNPC = this->m_data.flags & 0x1; + + if (!isNPC) { + if (a3) { + this->LoadBaseVariation(VARIATION_FACIAL_HAIR, 0, this->m_data.facialHairStyleID, this->m_data.hairColorID, SECTION_HEAD_LOWER, a4); + this->LoadBaseVariation(VARIATION_FACIAL_HAIR, 1, this->m_data.facialHairStyleID, this->m_data.hairColorID, SECTION_HEAD_UPPER, a4); + } + + this->m_sectionDirty |= (1 << SECTION_HEAD_LOWER) | (1 << SECTION_HEAD_UPPER); + + // TODO component request logic + + this->m_flags &= ~0x8; + } +} + void CCharacterComponent::SetFace(int32_t faceID, bool a3, const char* a4) { bool isNPC = this->m_data.flags & 0x1; diff --git a/src/component/CCharacterComponent.hpp b/src/component/CCharacterComponent.hpp index 563b035..59297db 100644 --- a/src/component/CCharacterComponent.hpp +++ b/src/component/CCharacterComponent.hpp @@ -81,7 +81,7 @@ class CCharacterComponent { void CreateBaseTexture(); void GeosRenderPrep(); CharSectionsRec* GetSectionsRecord(COMPONENT_VARIATIONS sectionIndex, int32_t variationIndex, int32_t colorIndex, bool* found); - void Init(ComponentData* data, const char* a3); + int32_t Init(ComponentData* data, const char* a3); int32_t ItemsLoaded(int32_t a2); void LoadBaseVariation(COMPONENT_VARIATIONS sectionIndex, int32_t textureIndex, int32_t variationIndex, int32_t colorIndex, COMPONENT_SECTIONS section, const char* a7); void PrepSections(); @@ -90,6 +90,7 @@ class CCharacterComponent { void RenderPrepSections(); void ReplaceExtraSkinTexture(const char* a2); void ReplaceHairTexture(int32_t hairStyleID, const char* a3); + void SetBeardStyle(int32_t facialHairStyleID, bool a3, const char* a4); void SetFace(int32_t faceID, bool a3, const char* a4); void SetHairColor(int32_t hairColorID, bool a3, const char* a4); void SetHairStyle(int32_t hairStyleID, const char* a3);