mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-05-23 15:22:28 +00:00
PossessableComponent pass
This commit is contained in:
parent
598d88b307
commit
fe6b279ebb
@ -6,13 +6,17 @@
|
|||||||
|
|
||||||
PossessableComponent::PossessableComponent(Entity* parent, uint32_t componentId) : Component(parent) {
|
PossessableComponent::PossessableComponent(Entity* parent, uint32_t componentId) : Component(parent) {
|
||||||
m_Possessor = LWOOBJID_EMPTY;
|
m_Possessor = LWOOBJID_EMPTY;
|
||||||
CDItemComponent item = Inventory::FindItemComponent(m_ParentEntity->GetLOT());
|
m_ComponentId = componentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PossessableComponent::LoadTemplateData() {
|
||||||
|
auto item = Inventory::FindItemComponent(m_ParentEntity->GetLOT());
|
||||||
m_AnimationFlag = static_cast<eAnimationFlags>(item.animationFlag);
|
m_AnimationFlag = static_cast<eAnimationFlags>(item.animationFlag);
|
||||||
|
|
||||||
// Get the possession Type from the CDClient
|
// Get the possession Type from the CDClient
|
||||||
auto query = CDClientDatabase::CreatePreppedStmt("SELECT possessionType, depossessOnHit FROM PossessableComponent WHERE id = ?;");
|
auto query = CDClientDatabase::CreatePreppedStmt("SELECT possessionType, depossessOnHit FROM PossessableComponent WHERE id = ?;");
|
||||||
|
|
||||||
query.bind(1, static_cast<int>(componentId));
|
query.bind(1, static_cast<int32_t>(m_ComponentId));
|
||||||
|
|
||||||
auto result = query.execQuery();
|
auto result = query.execQuery();
|
||||||
|
|
||||||
@ -24,13 +28,11 @@ PossessableComponent::PossessableComponent(Entity* parent, uint32_t componentId)
|
|||||||
m_PossessionType = ePossessionType::ATTACHED_VISIBLE;
|
m_PossessionType = ePossessionType::ATTACHED_VISIBLE;
|
||||||
m_DepossessOnHit = false;
|
m_DepossessOnHit = false;
|
||||||
}
|
}
|
||||||
result.finalize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PossessableComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) {
|
void PossessableComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) {
|
||||||
outBitStream->Write(m_DirtyPossessable || bIsInitialUpdate);
|
outBitStream->Write(m_DirtyPossessable || bIsInitialUpdate);
|
||||||
if (m_DirtyPossessable || bIsInitialUpdate) {
|
if (m_DirtyPossessable || bIsInitialUpdate) {
|
||||||
m_DirtyPossessable = false; // reset flag
|
|
||||||
outBitStream->Write(m_Possessor != LWOOBJID_EMPTY);
|
outBitStream->Write(m_Possessor != LWOOBJID_EMPTY);
|
||||||
if (m_Possessor != LWOOBJID_EMPTY) outBitStream->Write(m_Possessor);
|
if (m_Possessor != LWOOBJID_EMPTY) outBitStream->Write(m_Possessor);
|
||||||
|
|
||||||
@ -38,7 +40,10 @@ void PossessableComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsIn
|
|||||||
if (m_AnimationFlag != eAnimationFlags::IDLE_NONE) outBitStream->Write(m_AnimationFlag);
|
if (m_AnimationFlag != eAnimationFlags::IDLE_NONE) outBitStream->Write(m_AnimationFlag);
|
||||||
|
|
||||||
outBitStream->Write(m_ImmediatelyDepossess);
|
outBitStream->Write(m_ImmediatelyDepossess);
|
||||||
m_ImmediatelyDepossess = false; // reset flag
|
if (!bIsInitialUpdate) {
|
||||||
|
m_DirtyPossessable = false;
|
||||||
|
m_ImmediatelyDepossess = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,12 +18,9 @@ public:
|
|||||||
|
|
||||||
PossessableComponent(Entity* parentEntity, uint32_t componentId);
|
PossessableComponent(Entity* parentEntity, uint32_t componentId);
|
||||||
|
|
||||||
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);
|
void LoadTemplateData() override;
|
||||||
|
|
||||||
/**
|
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags);
|
||||||
* @brief mounts the Entity
|
|
||||||
*/
|
|
||||||
void Mount();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief dismounts the Entity
|
* @brief dismounts the Entity
|
||||||
@ -34,7 +31,11 @@ public:
|
|||||||
* Sets the possessor of this Entity
|
* Sets the possessor of this Entity
|
||||||
* @param value the ID of the possessor to set
|
* @param value the ID of the possessor to set
|
||||||
*/
|
*/
|
||||||
void SetPossessor(LWOOBJID value) { m_Possessor = value; m_DirtyPossessable = true; };
|
void SetPossessor(const LWOOBJID& value) {
|
||||||
|
if (m_Possessor == value) return;
|
||||||
|
m_Possessor = value;
|
||||||
|
m_DirtyPossessable = true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the possessor of this Entity
|
* Returns the possessor of this Entity
|
||||||
@ -46,7 +47,11 @@ public:
|
|||||||
* Sets the animation Flag of the possessable
|
* Sets the animation Flag of the possessable
|
||||||
* @param value the animation flag to set to
|
* @param value the animation flag to set to
|
||||||
*/
|
*/
|
||||||
void SetAnimationFlag(eAnimationFlags value) { m_AnimationFlag = value; m_DirtyPossessable = true; };
|
void SetAnimationFlag(eAnimationFlags value) {
|
||||||
|
if (m_AnimationFlag == value) return;
|
||||||
|
m_AnimationFlag = value;
|
||||||
|
m_DirtyPossessable = true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the possession type of this Entity
|
* Returns the possession type of this Entity
|
||||||
@ -63,7 +68,10 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Forcibly depossess the Entity
|
* Forcibly depossess the Entity
|
||||||
*/
|
*/
|
||||||
void ForceDepossess() { m_ImmediatelyDepossess = true; m_DirtyPossessable = true; };
|
void ForceDepossess() {
|
||||||
|
m_ImmediatelyDepossess = true;
|
||||||
|
m_DirtyPossessable = true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set if the parent entity was spawned from an item
|
* Set if the parent entity was spawned from an item
|
||||||
@ -123,4 +131,6 @@ private:
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
bool m_ItemSpawned = false;
|
bool m_ItemSpawned = false;
|
||||||
|
|
||||||
|
int32_t m_ComponentId = -1;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user