2021-12-05 17:54:36 +00:00
|
|
|
#include "PetFromObjectServer.h"
|
|
|
|
#include "PetComponent.h"
|
2023-05-02 22:39:21 +00:00
|
|
|
#include "ePetTamingNotifyType.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
void PetFromObjectServer::OnStartup(Entity* self) {
|
|
|
|
self->SetNetworkVar(u"pettamer", std::to_string(self->GetVar<LWOOBJID>(u"tamer")));
|
|
|
|
self->AddTimer("killSelf", 45.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PetFromObjectServer::OnTimerDone(Entity* self, std::string timerName) {
|
|
|
|
if (timerName == "killSelf") {
|
|
|
|
const auto* petComponent = self->GetComponent<PetComponent>();
|
|
|
|
if (petComponent == nullptr || petComponent->GetOwner() != nullptr)
|
|
|
|
return;
|
2023-05-02 22:39:21 +00:00
|
|
|
self->Smash(self->GetObjectID(), eKillType::SILENT);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-02 22:39:21 +00:00
|
|
|
void PetFromObjectServer::OnNotifyPetTamingMinigame(Entity* self, Entity* tamer, ePetTamingNotifyType type) {
|
2021-12-05 17:54:36 +00:00
|
|
|
switch (type) {
|
2023-05-02 22:39:21 +00:00
|
|
|
case ePetTamingNotifyType::BEGIN:
|
2021-12-05 17:54:36 +00:00
|
|
|
self->CancelAllTimers();
|
|
|
|
break;
|
2023-05-02 22:39:21 +00:00
|
|
|
case ePetTamingNotifyType::QUIT:
|
|
|
|
case ePetTamingNotifyType::FAILED:
|
|
|
|
self->Smash(self->GetObjectID(), eKillType::SILENT);
|
2021-12-05 17:54:36 +00:00
|
|
|
break;
|
2023-05-02 22:39:21 +00:00
|
|
|
case ePetTamingNotifyType::SUCCESS:
|
2021-12-05 17:54:36 +00:00
|
|
|
// TODO: Remove from groups?
|
|
|
|
GameMessages::SendNotifyClientObject(self->GetObjectID(), u"UpdateSuccessPicking", 0,
|
|
|
|
0, tamer->GetObjectID(), "", UNASSIGNED_SYSTEM_ADDRESS);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|