2022-04-27 04:44:35 +00:00
|
|
|
#include "LootBuffBehavior.h"
|
|
|
|
|
2024-02-27 07:25:44 +00:00
|
|
|
void LootBuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) {
|
2023-07-15 20:56:33 +00:00
|
|
|
auto target = Game::entityManager->GetEntity(context->caster);
|
2022-04-27 04:44:35 +00:00
|
|
|
if (!target) return;
|
|
|
|
|
|
|
|
auto controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>();
|
|
|
|
if (!controllablePhysicsComponent) return;
|
|
|
|
|
|
|
|
controllablePhysicsComponent->AddPickupRadiusScale(m_Scale);
|
2023-07-15 20:56:33 +00:00
|
|
|
Game::entityManager->SerializeEntity(target);
|
2022-04-27 04:44:35 +00:00
|
|
|
|
|
|
|
if (branch.duration > 0) context->RegisterTimerBehavior(this, branch);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-02-27 07:25:44 +00:00
|
|
|
void LootBuffBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) {
|
2022-04-27 04:44:35 +00:00
|
|
|
Handle(context, bitStream, branch);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LootBuffBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch) {
|
2023-07-15 20:56:33 +00:00
|
|
|
auto target = Game::entityManager->GetEntity(context->caster);
|
2022-04-27 04:44:35 +00:00
|
|
|
if (!target) return;
|
|
|
|
|
|
|
|
auto controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>();
|
|
|
|
if (!controllablePhysicsComponent) return;
|
|
|
|
|
|
|
|
controllablePhysicsComponent->RemovePickupRadiusScale(m_Scale);
|
2023-07-15 20:56:33 +00:00
|
|
|
Game::entityManager->SerializeEntity(target);
|
2022-04-27 04:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LootBuffBehavior::Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) {
|
|
|
|
UnCast(context, branch);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LootBuffBehavior::Load() {
|
|
|
|
this->m_Scale = GetFloat("scale");
|
|
|
|
}
|