DarkflameServer/dGame/dBehaviors/LootBuffBehavior.cpp

39 lines
1.3 KiB
C++
Raw Normal View History

#include "LootBuffBehavior.h"
2022-07-28 13:39:57 +00:00
void LootBuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
auto target = Game::entityManager->GetEntity(context->caster);
2022-07-28 13:39:57 +00:00
if (!target) return;
2022-07-28 13:39:57 +00:00
auto controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>();
if (!controllablePhysicsComponent) return;
2022-07-28 13:39:57 +00:00
controllablePhysicsComponent->AddPickupRadiusScale(m_Scale);
Game::entityManager->SerializeEntity(target);
2022-07-28 13:39:57 +00:00
if (branch.duration > 0) context->RegisterTimerBehavior(this, branch);
}
void LootBuffBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
2022-07-28 13:39:57 +00:00
Handle(context, bitStream, branch);
}
void LootBuffBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch) {
auto target = Game::entityManager->GetEntity(context->caster);
2022-07-28 13:39:57 +00:00
if (!target) return;
2022-07-28 13:39:57 +00:00
auto controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>();
if (!controllablePhysicsComponent) return;
2022-07-28 13:39:57 +00:00
controllablePhysicsComponent->RemovePickupRadiusScale(m_Scale);
Game::entityManager->SerializeEntity(target);
}
void LootBuffBehavior::Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) {
2022-07-28 13:39:57 +00:00
UnCast(context, branch);
}
void LootBuffBehavior::Load() {
2022-07-28 13:39:57 +00:00
this->m_Scale = GetFloat("scale");
}