2021-12-05 17:54:36 +00:00
|
|
|
#include "CarBoostBehavior.h"
|
|
|
|
#include "BehaviorBranchContext.h"
|
|
|
|
#include "GameMessages.h"
|
|
|
|
#include "EntityManager.h"
|
|
|
|
#include "BehaviorContext.h"
|
|
|
|
#include "CharacterComponent.h"
|
|
|
|
#include "Game.h"
|
2023-10-21 23:31:55 +00:00
|
|
|
#include "Logger.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
#include "PossessableComponent.h"
|
|
|
|
|
2024-02-27 07:25:44 +00:00
|
|
|
void CarBoostBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) {
|
2021-12-05 17:54:36 +00:00
|
|
|
GameMessages::SendVehicleAddPassiveBoostAction(branch.target, UNASSIGNED_SYSTEM_ADDRESS);
|
|
|
|
|
2023-07-15 20:56:33 +00:00
|
|
|
auto* entity = Game::entityManager->GetEntity(context->originator);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
if (entity == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-03-13 02:10:01 +00:00
|
|
|
Log::Info("Activating car boost!");
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
auto* possessableComponent = entity->GetComponent<PossessableComponent>();
|
|
|
|
if (possessableComponent != nullptr) {
|
|
|
|
|
2023-07-15 20:56:33 +00:00
|
|
|
auto* possessor = Game::entityManager->GetEntity(possessableComponent->GetPossessor());
|
2021-12-05 17:54:36 +00:00
|
|
|
if (possessor != nullptr) {
|
|
|
|
|
|
|
|
auto* characterComponent = possessor->GetComponent<CharacterComponent>();
|
|
|
|
if (characterComponent != nullptr) {
|
2024-03-13 02:10:01 +00:00
|
|
|
Log::Info("Tracking car boost!");
|
2021-12-05 17:54:36 +00:00
|
|
|
characterComponent->UpdatePlayerStatistic(RacingCarBoostsActivated);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
m_Action->Handle(context, bitStream, branch);
|
|
|
|
|
|
|
|
entity->AddCallbackTimer(m_Time, [entity]() {
|
|
|
|
GameMessages::SendVehicleRemovePassiveBoostAction(entity->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-07-25 02:26:51 +00:00
|
|
|
void CarBoostBehavior::Load() {
|
2021-12-05 17:54:36 +00:00
|
|
|
m_Action = GetAction("action");
|
|
|
|
|
|
|
|
m_Time = GetFloat("time");
|
|
|
|
}
|