mirror of
https://github.com/DarkflameUniverse/DarkflameServer
synced 2024-08-30 18:43:58 +00:00
b261e63233
* chore: Change entity and component logic to use bitstream references * merge
39 lines
1.3 KiB
C++
39 lines
1.3 KiB
C++
#include "LootBuffBehavior.h"
|
|
|
|
void LootBuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) {
|
|
auto target = Game::entityManager->GetEntity(context->caster);
|
|
if (!target) return;
|
|
|
|
auto controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>();
|
|
if (!controllablePhysicsComponent) return;
|
|
|
|
controllablePhysicsComponent->AddPickupRadiusScale(m_Scale);
|
|
Game::entityManager->SerializeEntity(target);
|
|
|
|
if (branch.duration > 0) context->RegisterTimerBehavior(this, branch);
|
|
|
|
}
|
|
|
|
void LootBuffBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) {
|
|
Handle(context, bitStream, branch);
|
|
}
|
|
|
|
void LootBuffBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch) {
|
|
auto target = Game::entityManager->GetEntity(context->caster);
|
|
if (!target) return;
|
|
|
|
auto controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>();
|
|
if (!controllablePhysicsComponent) return;
|
|
|
|
controllablePhysicsComponent->RemovePickupRadiusScale(m_Scale);
|
|
Game::entityManager->SerializeEntity(target);
|
|
}
|
|
|
|
void LootBuffBehavior::Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) {
|
|
UnCast(context, branch);
|
|
}
|
|
|
|
void LootBuffBehavior::Load() {
|
|
this->m_Scale = GetFloat("scale");
|
|
}
|