2021-12-05 17:54:36 +00:00
|
|
|
#include "ActVehicleDeathTrigger.h"
|
|
|
|
#include "PossessableComponent.h"
|
|
|
|
#include "GameMessages.h"
|
|
|
|
#include "RacingControlComponent.h"
|
|
|
|
#include "dZoneManager.h"
|
|
|
|
#include "EntityManager.h"
|
|
|
|
#include "PossessorComponent.h"
|
|
|
|
|
|
|
|
|
|
|
|
void ActVehicleDeathTrigger::OnCollisionPhantom(Entity* self, Entity* target) {
|
|
|
|
auto* possessableComponent = target->GetComponent<PossessableComponent>();
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
Entity* vehicle;
|
|
|
|
Entity* player;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
if (possessableComponent != nullptr) {
|
2023-07-15 20:56:33 +00:00
|
|
|
auto* player = Game::entityManager->GetEntity(possessableComponent->GetPossessor());
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
if (player == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
return;
|
|
|
|
} else if (target->IsPlayer()) {
|
|
|
|
auto* possessorComponent = target->GetComponent<PossessorComponent>();
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
if (possessorComponent == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2023-07-15 20:56:33 +00:00
|
|
|
vehicle = Game::entityManager->GetEntity(possessorComponent->GetPossessable());
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
if (vehicle == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
player = target;
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
2022-07-28 13:39:57 +00:00
|
|
|
|
|
|
|
|
2023-05-02 22:39:21 +00:00
|
|
|
GameMessages::SendDie(vehicle, self->GetObjectID(), LWOOBJID_EMPTY, true, eKillType::VIOLENT, u"", 0, 0, 0, true, false, 0);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2023-07-17 22:55:33 +00:00
|
|
|
auto* zoneController = Game::zoneManager->GetZoneControlObject();
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
auto* racingControlComponent = zoneController->GetComponent<RacingControlComponent>();
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
if (racingControlComponent != nullptr) {
|
|
|
|
racingControlComponent->OnRequestDie(player);
|
|
|
|
}
|
|
|
|
}
|