mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-24 22:43:34 +00:00
455f9470a5
* Move EntityManager to Game namespace * move initialization to later Need to wait for dZoneManager to be initialized. * Fix bugs - Cannot delete from a RandomAccessIterator while in a range based for loop. Touchup zone manager initialize replace magic numbers with better named constants replace magic zonecontrol id with a more readable hex alternative condense stack variables move initializers closer to their use initialize entity manager with zone control change initialize timings If zone is not zero we expect to initialize the entity manager during zone manager initialization Add constexpr for zone control LOT * Add proper error handling * revert vanity changes * Update WorldServer.cpp * Update dZoneManager.cpp
49 lines
1.4 KiB
C++
49 lines
1.4 KiB
C++
#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 = Game::entityManager->GetEntity(context->originator);
|
|
|
|
if (entity == nullptr) {
|
|
return;
|
|
}
|
|
|
|
Game::logger->Log("Car boost", "Activating car boost!");
|
|
|
|
auto* possessableComponent = entity->GetComponent<PossessableComponent>();
|
|
if (possessableComponent != nullptr) {
|
|
|
|
auto* possessor = Game::entityManager->GetEntity(possessableComponent->GetPossessor());
|
|
if (possessor != nullptr) {
|
|
|
|
auto* characterComponent = possessor->GetComponent<CharacterComponent>();
|
|
if (characterComponent != nullptr) {
|
|
Game::logger->Log("Car boost", "Tracking car boost!");
|
|
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");
|
|
}
|