DarkflameServer/dScripts/ai/ACT/ActVehicleDeathTrigger.cpp

53 lines
1.3 KiB
C++
Raw Normal View History

#include "ActVehicleDeathTrigger.h"
#include "PossessableComponent.h"
#include "GameMessages.h"
#include "RacingControlComponent.h"
#include "dZoneManager.h"
#include "EntityManager.h"
#include "PossessorComponent.h"
2022-07-28 13:39:57 +00:00
void ActVehicleDeathTrigger::OnCollisionPhantom(Entity* self, Entity* target) {
2023-06-07 07:23:50 +00:00
auto possessableComponent = target->GetComponent<PossessableComponent>();
2022-07-28 13:39:57 +00:00
Entity* vehicle;
Entity* player;
if (possessableComponent != nullptr) {
auto* player = EntityManager::Instance()->GetEntity(possessableComponent->GetPossessor());
if (player == nullptr) {
return;
}
return;
} else if (target->IsPlayer()) {
2023-06-07 07:23:50 +00:00
auto possessorComponent = target->GetComponent<PossessorComponent>();
2022-07-28 13:39:57 +00:00
if (possessorComponent == nullptr) {
return;
}
vehicle = EntityManager::Instance()->GetEntity(possessorComponent->GetPossessable());
if (vehicle == nullptr) {
return;
}
player = target;
} else {
return;
}
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
auto* zoneController = dZoneManager::Instance()->GetZoneControlObject();
2023-06-07 07:23:50 +00:00
auto racingControlComponent = zoneController->GetComponent<RacingControlComponent>();
2022-07-28 13:39:57 +00:00
if (racingControlComponent != nullptr) {
racingControlComponent->OnRequestDie(player);
}
}