mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-01-11 15:27:07 +00:00
move the pet taming minigame start logic into a separate function
This commit is contained in:
parent
7b223d1cc2
commit
68bb51f408
@ -149,12 +149,65 @@ void PetComponent::OnUse(Entity* originator) {
|
||||
case ePetAbilityType::JumpOnObject: // Bouncer
|
||||
StartInteractBouncer();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
StartTamingMinigame(originator);
|
||||
}
|
||||
}
|
||||
|
||||
void PetComponent::Update(float deltaTime) {
|
||||
// Update timers
|
||||
m_TimerBounce -= deltaTime;
|
||||
|
||||
if (m_Timer > 0) {
|
||||
m_Timer -= deltaTime;
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove "left behind" pets and handle failing pet taming minigame
|
||||
if (m_Owner != LWOOBJID_EMPTY) {
|
||||
const Entity* const owner = GetOwner();
|
||||
if (!owner) {
|
||||
m_Parent->Kill();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
ClientFailTamingMinigame(); // TODO: This is not despawning the built model correctly
|
||||
}
|
||||
|
||||
if (m_Flags.Has<PetFlag::SPAWNING>()) OnSpawn();
|
||||
|
||||
// Handle pet AI states
|
||||
switch (m_State) {
|
||||
case PetAiState::idle:
|
||||
Wander();
|
||||
break;
|
||||
|
||||
case PetAiState::follow:
|
||||
OnFollow(deltaTime);
|
||||
break;
|
||||
|
||||
case PetAiState::goToObj:
|
||||
if (m_MovementAI->AtFinalWaypoint()) {
|
||||
LOG_DEBUG("Reached object!");
|
||||
m_MovementAI->Stop();
|
||||
SetPetAiState(PetAiState::interact);
|
||||
} else {
|
||||
m_Timer += 0.5f;
|
||||
}
|
||||
break;
|
||||
|
||||
case PetAiState::interact:
|
||||
OnInteract();
|
||||
break;
|
||||
|
||||
default:
|
||||
LOG_DEBUG("Unknown state: %d!", m_Flags);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PetComponent::StartTamingMinigame(Entity* originator) {
|
||||
// The minigame logic beneath this comment should be rewritten... eventually
|
||||
if (m_Owner != LWOOBJID_EMPTY) return;
|
||||
|
||||
@ -317,58 +370,6 @@ void PetComponent::OnUse(Entity* originator) {
|
||||
m_Parent->GetScript()->OnNotifyPetTamingMinigame(m_Parent, originator, ePetTamingNotifyType::BEGIN);
|
||||
}
|
||||
|
||||
void PetComponent::Update(float deltaTime) {
|
||||
// Update timers
|
||||
m_TimerBounce -= deltaTime;
|
||||
|
||||
if (m_Timer > 0) {
|
||||
m_Timer -= deltaTime;
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove "left behind" pets and handle failing pet taming minigame
|
||||
if (m_Owner != LWOOBJID_EMPTY) {
|
||||
const Entity* const owner = GetOwner();
|
||||
if (!owner) {
|
||||
m_Parent->Kill();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
ClientFailTamingMinigame(); // TODO: This is not despawning the built model correctly
|
||||
}
|
||||
|
||||
if (m_Flags.Has<PetFlag::SPAWNING>()) OnSpawn();
|
||||
|
||||
// Handle pet AI states
|
||||
switch (m_State) {
|
||||
case PetAiState::idle:
|
||||
Wander();
|
||||
break;
|
||||
|
||||
case PetAiState::follow:
|
||||
OnFollow(deltaTime);
|
||||
break;
|
||||
|
||||
case PetAiState::goToObj:
|
||||
if (m_MovementAI->AtFinalWaypoint()) {
|
||||
LOG_DEBUG("Reached object!");
|
||||
m_MovementAI->Stop();
|
||||
SetPetAiState(PetAiState::interact);
|
||||
} else {
|
||||
m_Timer += 0.5f;
|
||||
}
|
||||
break;
|
||||
|
||||
case PetAiState::interact:
|
||||
OnInteract();
|
||||
break;
|
||||
|
||||
default:
|
||||
LOG_DEBUG("Unknown state: %d!", m_Flags);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PetComponent::TryBuild(uint32_t numBricks, bool clientFailed) {
|
||||
if (m_Tamer == LWOOBJID_EMPTY) return;
|
||||
|
||||
|
@ -120,6 +120,11 @@ public:
|
||||
*/
|
||||
void TryBuild(uint32_t numBricks, bool clientFailed);
|
||||
|
||||
/**
|
||||
* Start the pet taming minigame
|
||||
*/
|
||||
void StartTamingMinigame(Entity* originator);
|
||||
|
||||
/**
|
||||
* Handles a notification from the client regarding the completion of the pet minigame, adding the pet to their
|
||||
* inventory.
|
||||
|
Loading…
Reference in New Issue
Block a user