DarkflameServer/dScripts/ai/ACT/ActVehicleDeathTrigger.cpp
Aaron Kimbrell 6aa90ad5b2
Breakout rest of the enums from dCommonVars and clean it up (#1061)
* Breakout rest of the enums from dcommonvars
so we don't have to deal with merge conflicts
ePlayerFlags is not a scoped enum, yet, due to it's complexity

* address feedback

* make player flag types consistent

* fix typo
2023-05-02 17:39:21 -05:00

53 lines
1.3 KiB
C++

#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>();
Entity* vehicle;
Entity* player;
if (possessableComponent != nullptr) {
auto* player = EntityManager::Instance()->GetEntity(possessableComponent->GetPossessor());
if (player == nullptr) {
return;
}
return;
} else if (target->IsPlayer()) {
auto* possessorComponent = target->GetComponent<PossessorComponent>();
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);
auto* zoneController = dZoneManager::Instance()->GetZoneControlObject();
auto* racingControlComponent = zoneController->GetComponent<RacingControlComponent>();
if (racingControlComponent != nullptr) {
racingControlComponent->OnRequestDie(player);
}
}