feat(component): implement CCharacterComponent::AddLink

This commit is contained in:
fallenoak 2025-11-03 19:55:08 -06:00
parent 20caf39136
commit 9ef900f80f
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D
2 changed files with 54 additions and 3 deletions

View File

@ -6,6 +6,7 @@
#include "gx/Device.hpp"
#include "gx/Texture.hpp"
#include "model/CM2Model.hpp"
#include "model/CM2Scene.hpp"
#include "object/Types.hpp"
#include "util/CStatus.hpp"
#include "util/Unimplemented.hpp"
@ -160,8 +161,58 @@ int32_t CCharacterComponent::AddHandItem(CM2Model* model, const ItemDisplayInfoR
return link;
}
void CCharacterComponent::AddLink(CM2Model* model, GEOCOMPONENTLINKS link, char const* modelPath, char const* texturePath, int32_t a5, const ItemDisplayInfoRec* displayRec) {
// TODO
void CCharacterComponent::AddLink(CM2Model* parent, GEOCOMPONENTLINKS link, char const* modelPath, char const* texturePath, int32_t visualID, const ItemDisplayInfoRec* displayRec) {
if (!parent) {
return;
}
// Create item model
auto model = parent->m_scene->CreateModel(modelPath, 0);
if (!model) {
return;
}
// Create item texture
auto textureFlags = CGxTexFlags(GxTex_LinearMipNearest, 0, 0, 0, 0, 0, 1);
auto texture = TextureCreate(texturePath, textureFlags, &s_status, 0);
if (!texture) {
model->Release();
return;
}
// Replace item texture
model->ReplaceTexture(2, texture);
HandleClose(texture);
// Add item visual
if (visualID > 0) {
// TODO CCharacterComponent::ComponentUtilAddItemVisual(model, visualID);
}
// Attach item to parent
parent->DetachAllChildrenById(link);
model->AttachToParent(parent, link, nullptr, 0);
// Add link point
if (link == ATTACH_HANDR) {
// TODO CCharacterComponent::AddLinkpt(parent, 0);
} else if (link == ATTACH_HANDL) {
// TODO CCharacterComponent::AddLinkpt(parent, 1);
}
// Replace item particle color
// TODO ReplaceParticleColor(displayRec->m_particleColorID, model);
model->Release();
}
CCharacterComponent* CCharacterComponent::AllocComponent() {

View File

@ -48,7 +48,7 @@ class CCharacterComponent {
// Static functions
static int32_t AddHandItem(CM2Model* model, const ItemDisplayInfoRec* displayRec, INVENTORY_SLOTS invSlot, SHEATHE_TYPE sheatheType, bool sheathed, bool shield, bool a7, int32_t a8);
static void AddLink(CM2Model* model, GEOCOMPONENTLINKS link, char const* modelPath, char const* texturePath, int32_t a5, const ItemDisplayInfoRec* displayRec);
static void AddLink(CM2Model* parent, GEOCOMPONENTLINKS link, char const* modelPath, char const* texturePath, int32_t visualID, const ItemDisplayInfoRec* displayRec);
static CCharacterComponent* AllocComponent();
static HTEXTURE CreateTexture(const char* fileName, CStatus* status);
static GEOCOMPONENTLINKS GetSheatheLink(SHEATHE_TYPE sheatheType, bool a2);