mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-24 22:43:34 +00:00
31 lines
1003 B
C++
31 lines
1003 B
C++
|
#include "FvRaceDragon.h"
|
||
|
#include "RenderComponent.h"
|
||
|
#include "RacingControlComponent.h"
|
||
|
|
||
|
void FvRaceDragon::OnCollisionPhantom(Entity* self, Entity* target) {
|
||
|
if (!target) return;
|
||
|
|
||
|
const auto racingControllers = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::RACING_CONTROL);
|
||
|
if (racingControllers.empty()) return;
|
||
|
|
||
|
auto* racingControlComponent = racingControllers[0]->GetComponent<RacingControlComponent>();
|
||
|
if (!racingControlComponent) return;
|
||
|
|
||
|
const auto* player = racingControlComponent->GetPlayerData(target->GetObjectID());
|
||
|
if (!player) return;
|
||
|
|
||
|
if (player->lap != m_Lap) return;
|
||
|
|
||
|
const auto dragons = Game::entityManager->GetEntitiesInGroup("dragon");
|
||
|
for (const auto& dragon : dragons) {
|
||
|
if (!dragon || dragon->GetLOT() != this->m_Dragon) continue;
|
||
|
|
||
|
auto* renderComponent = dragon->GetComponent<RenderComponent>();
|
||
|
if (!renderComponent) continue;
|
||
|
|
||
|
renderComponent->PlayAnimation(dragon, m_LapAnimName);
|
||
|
|
||
|
}
|
||
|
Game::entityManager->DestroyEntity(self);
|
||
|
}
|