mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-26 23:43:34 +00:00
5942182486
* Logger: Rename logger to Logger from dLogger * Logger: Add compile time filename Fix include issues Add writers Add macros Add macro to force compilation * Logger: Replace calls with macros Allows for filename and line number to be logged * Logger: Add comments and remove extra define Logger: Replace with unique_ptr also flush console at exit. regular file writer should be flushed on file close. Logger: Remove constexpr on variable * Logger: Simplify code * Update Logger.cpp
55 lines
1.7 KiB
C++
55 lines
1.7 KiB
C++
#include "SpeedBehavior.h"
|
|
|
|
#include "ControllablePhysicsComponent.h"
|
|
#include "BehaviorContext.h"
|
|
#include "BehaviorBranchContext.h"
|
|
#include "Logger.h"
|
|
|
|
|
|
void SpeedBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
|
if (m_AffectsCaster) branch.target = context->caster;
|
|
|
|
auto* target = Game::entityManager->GetEntity(branch.target);
|
|
if (!target) return;
|
|
|
|
auto* controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>();
|
|
if (!controllablePhysicsComponent) return;
|
|
|
|
controllablePhysicsComponent->AddSpeedboost(m_RunSpeed);
|
|
Game::entityManager->SerializeEntity(target);
|
|
|
|
if (branch.duration > 0.0f) {
|
|
context->RegisterTimerBehavior(this, branch);
|
|
} else if (branch.start > 0) {
|
|
context->RegisterEndBehavior(this, branch);
|
|
}
|
|
}
|
|
|
|
void SpeedBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
|
Handle(context, bitStream, branch);
|
|
}
|
|
|
|
void SpeedBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch) {
|
|
End(context, branch, LWOOBJID_EMPTY);
|
|
}
|
|
|
|
void SpeedBehavior::Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) {
|
|
End(context, branch, second);
|
|
}
|
|
|
|
void SpeedBehavior::End(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) {
|
|
auto* target = Game::entityManager->GetEntity(branch.target);
|
|
if (!target) return;
|
|
|
|
auto* controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>();
|
|
if (!controllablePhysicsComponent) return;
|
|
|
|
controllablePhysicsComponent->RemoveSpeedboost(m_RunSpeed);
|
|
Game::entityManager->SerializeEntity(target);
|
|
}
|
|
|
|
void SpeedBehavior::Load() {
|
|
m_RunSpeed = GetFloat("run_speed");
|
|
m_AffectsCaster = GetBoolean("affects_caster");
|
|
}
|