2021-12-05 17:54:36 +00:00
|
|
|
#include "ActVehicleDeathTrigger.h"
|
|
|
|
#include "PossessableComponent.h"
|
|
|
|
#include "GameMessages.h"
|
2023-06-26 05:00:01 +00:00
|
|
|
#include "VehicleRacingControlComponent.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
#include "dZoneManager.h"
|
|
|
|
#include "EntityManager.h"
|
2023-06-26 17:36:36 +00:00
|
|
|
#include "PossessionComponent.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
void ActVehicleDeathTrigger::OnCollisionPhantom(Entity* self, Entity* target) {
|
2023-06-09 08:27:05 +00:00
|
|
|
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) {
|
|
|
|
auto* player = EntityManager::Instance()->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()) {
|
2023-06-26 17:36:36 +00:00
|
|
|
auto* possessionComponent = target->GetComponent<PossessionComponent>();
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2023-06-26 17:36:36 +00:00
|
|
|
if (possessionComponent == nullptr) {
|
2021-12-05 17:54:36 +00:00
|
|
|
return;
|
|
|
|
}
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2023-06-26 17:36:36 +00:00
|
|
|
vehicle = EntityManager::Instance()->GetEntity(possessionComponent->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
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
auto* zoneController = dZoneManager::Instance()->GetZoneControlObject();
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2023-06-26 05:00:01 +00:00
|
|
|
auto* vehicleRacingControlComponent = zoneController->GetComponent<VehicleRacingControlComponent>();
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2023-06-26 05:00:01 +00:00
|
|
|
if (vehicleRacingControlComponent) vehicleRacingControlComponent->OnRequestDie(player);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|