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