2021-12-05 17:54:36 +00:00
|
|
|
#include "MaestromExtracticatorServer.h"
|
|
|
|
#include "GameMessages.h"
|
|
|
|
#include "GeneralUtils.h"
|
|
|
|
#include "EntityManager.h"
|
|
|
|
#include "MissionComponent.h"
|
|
|
|
#include "eMissionTaskType.h"
|
2023-03-20 13:10:52 +00:00
|
|
|
#include "RenderComponent.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
void MaestromExtracticatorServer::OnStartup(Entity* self) {
|
2023-03-26 10:09:04 +00:00
|
|
|
float animTime = RenderComponent::PlayAnimation(self, failAnim);
|
|
|
|
if (animTime == 0.0f) animTime = defaultTime;
|
|
|
|
|
|
|
|
self->AddTimer("PlayFail", animTime);
|
2021-12-05 17:54:36 +00:00
|
|
|
self->AddTimer("RemoveSample", destroyAfterNoSampleTime);
|
|
|
|
}
|
|
|
|
|
2023-03-20 13:10:52 +00:00
|
|
|
void MaestromExtracticatorServer::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) {
|
|
|
|
if (sender == nullptr) return;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
if (args == "attemptCollection") {
|
|
|
|
Entity* player = EntityManager::Instance()->GetEntity(self->GetSpawnerID());
|
|
|
|
if (!player) return;
|
|
|
|
|
2023-06-09 08:27:05 +00:00
|
|
|
auto* missionComponent = player->GetComponent<MissionComponent>();
|
2021-12-05 17:54:36 +00:00
|
|
|
if (missionComponent == nullptr) return;
|
|
|
|
|
|
|
|
missionComponent->Progress(eMissionTaskType::SMASH, 14718);
|
|
|
|
CollectSample(self, sender->GetObjectID());
|
|
|
|
sender->ScheduleKillAfterUpdate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MaestromExtracticatorServer::CollectSample(Entity* self, LWOOBJID sampleObj) {
|
2023-03-20 13:10:52 +00:00
|
|
|
self->AddTimer("RemoveSample", PlayAnimAndReturnTime(self, collectAnim));
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2023-03-20 13:10:52 +00:00
|
|
|
float MaestromExtracticatorServer::PlayAnimAndReturnTime(Entity* self, std::string animID) {
|
|
|
|
return RenderComponent::PlayAnimation(self, animID);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MaestromExtracticatorServer::OnTimerDone(Entity* self, std::string timerName) {
|
|
|
|
if (timerName == "RemoveSample") {
|
|
|
|
self->ScheduleKillAfterUpdate();
|
2023-03-20 13:10:52 +00:00
|
|
|
} else if (timerName == "PlayFail") {
|
|
|
|
RenderComponent::PlayAnimation(self, failAnim);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
}
|