mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-24 06:23:35 +00:00
update loop cleanup
This commit is contained in:
parent
3f1468ebdf
commit
e4b3e22570
@ -341,42 +341,18 @@ void PetComponent::Update(float deltaTime) {
|
||||
}
|
||||
|
||||
if (m_Owner == LWOOBJID_EMPTY) {
|
||||
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();
|
||||
Game::entityManager->SerializeEntity(m_Parent);
|
||||
}
|
||||
} else {
|
||||
m_Timer = 5;
|
||||
}
|
||||
}
|
||||
|
||||
UpdateUnowned(deltaTime);
|
||||
return;
|
||||
}
|
||||
|
||||
auto* owner = GetOwner();
|
||||
if (owner == nullptr) {
|
||||
if (!owner) {
|
||||
m_Parent->Kill();
|
||||
return;
|
||||
}
|
||||
|
||||
m_MovementAI = m_Parent->GetComponent<MovementAIComponent>();
|
||||
if (m_MovementAI == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (!m_MovementAI) return;
|
||||
|
||||
if (m_TresureTime > 0.0f) { //TODO: Find better trigger?
|
||||
InteractDig(deltaTime);
|
||||
@ -404,7 +380,6 @@ void PetComponent::Update(float deltaTime) {
|
||||
|
||||
if (m_Timer > 0) {
|
||||
m_Timer -= deltaTime;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -468,6 +443,29 @@ skipTresure:
|
||||
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) {
|
||||
if (isReady) {
|
||||
LOG("Dig state reached!");
|
||||
|
@ -47,6 +47,12 @@ public:
|
||||
void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate) 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.
|
||||
* @param originator the entity that triggered the event
|
||||
|
Loading…
Reference in New Issue
Block a user