2021-12-05 17:54:36 +00:00
|
|
|
#include "CharacterComponent.h"
|
2022-02-05 11:28:17 +00:00
|
|
|
#include "DestroyableComponent.h"
|
|
|
|
#include "EntityManager.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
#include "PossessableComponent.h"
|
2022-02-05 11:28:17 +00:00
|
|
|
#include "RaceImagineCrateServer.h"
|
|
|
|
#include "RacingTaskParam.h"
|
2022-07-05 06:00:10 +00:00
|
|
|
#include "MissionComponent.h"
|
2022-02-05 11:28:17 +00:00
|
|
|
#include "SkillComponent.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void RaceImagineCrateServer::OnDie(Entity* self, Entity* killer) {
|
|
|
|
if (self->GetVar<bool>(u"bIsDead")) {
|
|
|
|
return;
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
self->SetVar<bool>(u"bIsDead", true);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (killer == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
auto* skillComponent = killer->GetComponent<SkillComponent>();
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (skillComponent == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
auto* destroyableComponent = killer->GetComponent<DestroyableComponent>();
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (destroyableComponent != nullptr) {
|
|
|
|
destroyableComponent->SetImagination(60);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
EntityManager::Instance()->SerializeEntity(killer);
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
// Find possessor of race car to progress missions and update stats.
|
|
|
|
auto* possessableComponent = killer->GetComponent<PossessableComponent>();
|
|
|
|
if (possessableComponent != nullptr) {
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
auto* possessor = EntityManager::Instance()->GetEntity(possessableComponent->GetPossessor());
|
|
|
|
if (possessor != nullptr) {
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
auto* missionComponent = possessor->GetComponent<MissionComponent>();
|
|
|
|
auto* characterComponent = possessor->GetComponent<CharacterComponent>();
|
2022-02-05 11:28:17 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (characterComponent != nullptr) {
|
|
|
|
characterComponent->UpdatePlayerStatistic(RacingImaginationCratesSmashed);
|
|
|
|
characterComponent->UpdatePlayerStatistic(RacingSmashablesSmashed);
|
|
|
|
}
|
2022-02-05 11:28:17 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
// Progress racing smashable missions
|
|
|
|
if (missionComponent == nullptr) return;
|
|
|
|
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_RACING, 0, (LWOOBJID)RacingTaskParam::RACING_TASK_PARAM_SMASHABLES);
|
|
|
|
}
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|