refactor(component): the pet loads its row and preconditions in the client's phases

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-10-01 08:08:11 -05:00
parent 12efcd259c
commit 6fc19c114d
2 changed files with 12 additions and 3 deletions

View File

@@ -54,8 +54,6 @@ std::unordered_map<LWOOBJID, LWOOBJID> PetComponent::activePets{};
PetComponent::PetComponent(Entity* parentEntity, const int32_t componentID) : Component{ parentEntity, componentID } {
RegisterMsg(&PetComponent::OnRequestUse);
m_PetInfo = CDClientManager::GetTable<CDPetComponentTable>()->GetByID(componentID); // TODO: Make reference when safe
m_Interaction = LWOOBJID_EMPTY;
m_Owner = LWOOBJID_EMPTY;
m_ModerationStatus = 0;
@@ -69,8 +67,16 @@ PetComponent::PetComponent(Entity* parentEntity, const int32_t componentID) : Co
m_StartPosition = NiPoint3Constant::ZERO;
m_MovementAI = nullptr;
m_TreasureTime = 0;
}
std::string checkPreconditions = GeneralUtils::UTF16ToWTF8(parentEntity->GetVar<std::u16string>(u"CheckPrecondition"));
// The PetComponent row
void PetComponent::LoadDataFromTemplate() {
m_PetInfo = CDClientManager::GetTable<CDPetComponentTable>()->GetByID(m_ComponentID); // TODO: Make reference when safe
}
// The level config: the taming preconditions
void PetComponent::LoadConfigData() {
std::string checkPreconditions = GeneralUtils::UTF16ToWTF8(m_Parent->GetVar<std::u16string>(u"CheckPrecondition"));
if (!checkPreconditions.empty()) {
SetPreconditions(checkPreconditions);

View File

@@ -37,6 +37,9 @@ public:
static constexpr uint32_t PET_STATE_GOING_TO_ABILITY_OBJECT = 1 << 10;
explicit PetComponent(Entity* parentEntity, const int32_t componentID);
void LoadDataFromTemplate() override;
void LoadConfigData() override;
~PetComponent() override;
void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override;