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 = EntityManager::Instance()->GetEntity(context->caster);
if (!target) return;
auto* controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>();
2022-07-28 13:39:57 +00:00
if (!controllablePhysicsComponent) return;
2022-07-28 13:39:57 +00:00
controllablePhysicsComponent->AddPickupRadiusScale(m_Scale);
EntityManager::Instance()->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) {
2022-07-28 13:39:57 +00:00
auto target = EntityManager::Instance()->GetEntity(context->caster);
if (!target) return;
auto* controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>();
2022-07-28 13:39:57 +00:00
if (!controllablePhysicsComponent) return;
2022-07-28 13:39:57 +00:00
controllablePhysicsComponent->RemovePickupRadiusScale(m_Scale);
EntityManager::Instance()->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");
}