mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-25 23:13:35 +00:00
update loop cleanup
This commit is contained in:
parent
81d8c187ea
commit
57a1c05e98
@ -341,42 +341,18 @@ void PetComponent::Update(float deltaTime) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_Owner == LWOOBJID_EMPTY) {
|
if (m_Owner == LWOOBJID_EMPTY) {
|
||||||
if (m_Tamer != LWOOBJID_EMPTY) {
|
UpdateUnowned(deltaTime);
|
||||||
if (m_Timer > 0) {
|
|
||||||
m_Timer -= deltaTime;
|
|
||||||
|
|
||||||
if (m_Timer <= 0) {
|
|
||||||
m_Timer = 0;
|
|
||||||
|
|
||||||
ClientFailTamingMinigame();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (m_Timer > 0) {
|
|
||||||
m_Timer -= deltaTime;
|
|
||||||
|
|
||||||
if (m_Timer <= 0) {
|
|
||||||
Wander();
|
|
||||||
Game::entityManager->SerializeEntity(m_Parent);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
m_Timer = 5;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* owner = GetOwner();
|
auto* owner = GetOwner();
|
||||||
if (owner == nullptr) {
|
if (!owner) {
|
||||||
m_Parent->Kill();
|
m_Parent->Kill();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_MovementAI = m_Parent->GetComponent<MovementAIComponent>();
|
m_MovementAI = m_Parent->GetComponent<MovementAIComponent>();
|
||||||
if (m_MovementAI == nullptr) {
|
if (!m_MovementAI) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_TresureTime > 0.0f) { //TODO: Find better trigger?
|
if (m_TresureTime > 0.0f) { //TODO: Find better trigger?
|
||||||
InteractDig(deltaTime);
|
InteractDig(deltaTime);
|
||||||
@ -404,7 +380,6 @@ void PetComponent::Update(float deltaTime) {
|
|||||||
|
|
||||||
if (m_Timer > 0) {
|
if (m_Timer > 0) {
|
||||||
m_Timer -= deltaTime;
|
m_Timer -= deltaTime;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -468,6 +443,29 @@ skipTresure:
|
|||||||
m_Timer = 1;
|
m_Timer = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PetComponent::UpdateUnowned(float deltaTime) {
|
||||||
|
if (m_Tamer != LWOOBJID_EMPTY) {
|
||||||
|
if (m_Timer > 0) {
|
||||||
|
m_Timer -= deltaTime;
|
||||||
|
|
||||||
|
if (m_Timer <= 0) {
|
||||||
|
m_Timer = 0;
|
||||||
|
|
||||||
|
ClientFailTamingMinigame();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (m_Timer > 0) {
|
||||||
|
m_Timer -= deltaTime;
|
||||||
|
|
||||||
|
if (m_Timer <= 0) Wander();
|
||||||
|
} else {
|
||||||
|
m_Timer = 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PetComponent::SetIsReadyToDig(bool isReady) {
|
void PetComponent::SetIsReadyToDig(bool isReady) {
|
||||||
if (isReady) {
|
if (isReady) {
|
||||||
LOG("Dig state reached!");
|
LOG("Dig state reached!");
|
||||||
|
@ -47,6 +47,12 @@ public:
|
|||||||
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
|
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) override;
|
||||||
void Update(float deltaTime) override;
|
void Update(float deltaTime) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles updates for unowned pets
|
||||||
|
* @param deltaTime time since last update
|
||||||
|
*/
|
||||||
|
void UpdateUnowned(float deltaTime);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles an OnUse event from another entity, initializing the pet taming minigame if this pet is untamed.
|
* Handles an OnUse event from another entity, initializing the pet taming minigame if this pet is untamed.
|
||||||
* @param originator the entity that triggered the event
|
* @param originator the entity that triggered the event
|
||||||
|
Loading…
Reference in New Issue
Block a user