mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-01-27 22:19:53 +00:00
use reference instead of pointer for cdclient data
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "eReplicaComponentType.h"
|
||||
#include "ePetAbilityType.h"
|
||||
#include "CDPetComponentTable.h"
|
||||
#include "CDClientManager.h"
|
||||
|
||||
/*
|
||||
* The current state of the pet AI
|
||||
@@ -67,9 +68,50 @@ class PetComponent : public Component {
|
||||
public:
|
||||
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::PET;
|
||||
|
||||
PetComponent(Entity* parentEntity, uint32_t componentId);
|
||||
/**
|
||||
* Pet information loaded from the CDClientDatabase
|
||||
*/
|
||||
CDPetComponent& m_PetInfo;
|
||||
|
||||
/**
|
||||
* PetComponent constructor
|
||||
* @param parentEntity The parent entity
|
||||
* @param componentId The component id
|
||||
*/
|
||||
explicit PetComponent(Entity* parentEntity, uint32_t componentId) : Component{ parentEntity },
|
||||
m_PetInfo{ CDClientManager::Instance().GetTable<CDPetComponentTable>()->GetByID(componentId) } {
|
||||
m_ComponentId = componentId;
|
||||
m_Interaction = LWOOBJID_EMPTY;
|
||||
m_InteractType = PetInteractType::none;
|
||||
m_Owner = LWOOBJID_EMPTY;
|
||||
m_ModerationStatus = 0;
|
||||
m_Tamer = LWOOBJID_EMPTY;
|
||||
m_ModelId = LWOOBJID_EMPTY;
|
||||
m_Timer = 0;
|
||||
m_TimerAway = 0;
|
||||
m_TimerBounce = 0;
|
||||
m_DatabaseId = LWOOBJID_EMPTY;
|
||||
m_Flags = PetFlag::SPAWNING; // Tameable
|
||||
m_Ability = ePetAbilityType::Invalid;
|
||||
m_StartPosition = m_Parent->GetPosition();
|
||||
m_MovementAI = nullptr;
|
||||
m_Preconditions = nullptr;
|
||||
|
||||
m_ReadyToInteract = false;
|
||||
SetPetAiState(PetAiState::spawn);
|
||||
SetIsHandlingInteraction(false);
|
||||
|
||||
std::string checkPreconditions = GeneralUtils::UTF16ToWTF8(parentEntity->GetVar<std::u16string>(u"CheckPrecondition"));
|
||||
|
||||
if (!checkPreconditions.empty()) {
|
||||
SetPreconditions(checkPreconditions);
|
||||
}
|
||||
|
||||
m_FollowRadius = 8.0f; //Game::zoneManager->GetPetFollowRadius(); // TODO: FIX THIS TO LOAD DYNAMICALLY
|
||||
}
|
||||
|
||||
~PetComponent() override;
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the pet
|
||||
* @param outBitStream The output bitstream
|
||||
@@ -439,11 +481,6 @@ private:
|
||||
int32_t numValidPieces;
|
||||
};
|
||||
|
||||
/**
|
||||
* Pet information loaded from the CDClientDatabase
|
||||
*/
|
||||
CDPetComponent* m_PetInfo;
|
||||
|
||||
/**
|
||||
* Cache of all the pets that are currently spawned, indexed by tamer
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user