mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-09 20:24:16 +00:00
Public release of the DLU server code!
Have fun!
This commit is contained in:
51
dGame/dBehaviors/CarBoostBehavior.cpp
Normal file
51
dGame/dBehaviors/CarBoostBehavior.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
#include "CarBoostBehavior.h"
|
||||
#include "BehaviorBranchContext.h"
|
||||
#include "GameMessages.h"
|
||||
#include "EntityManager.h"
|
||||
#include "BehaviorContext.h"
|
||||
#include "CharacterComponent.h"
|
||||
#include "Game.h"
|
||||
#include "dLogger.h"
|
||||
#include "PossessableComponent.h"
|
||||
|
||||
void CarBoostBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
||||
{
|
||||
GameMessages::SendVehicleAddPassiveBoostAction(branch.target, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
auto* entity = EntityManager::Instance()->GetEntity(context->originator);
|
||||
|
||||
if (entity == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Game::logger->Log("Car boost", "Activating car boost!\n");
|
||||
|
||||
auto* possessableComponent = entity->GetComponent<PossessableComponent>();
|
||||
if (possessableComponent != nullptr) {
|
||||
|
||||
auto* possessor = EntityManager::Instance()->GetEntity(possessableComponent->GetPossessor());
|
||||
if (possessor != nullptr) {
|
||||
|
||||
auto* characterComponent = possessor->GetComponent<CharacterComponent>();
|
||||
if (characterComponent != nullptr) {
|
||||
Game::logger->Log("Car boost", "Tracking car boost!\n");
|
||||
characterComponent->UpdatePlayerStatistic(RacingCarBoostsActivated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
m_Action->Handle(context, bitStream, branch);
|
||||
|
||||
entity->AddCallbackTimer(m_Time, [entity] () {
|
||||
GameMessages::SendVehicleRemovePassiveBoostAction(entity->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||
});
|
||||
}
|
||||
|
||||
void CarBoostBehavior::Load()
|
||||
{
|
||||
m_Action = GetAction("action");
|
||||
|
||||
m_Time = GetFloat("time");
|
||||
}
|
Reference in New Issue
Block a user