DarkflameServer/dGame/dBehaviors/ImaginationBehavior.cpp

33 lines
827 B
C++
Raw Normal View History

2022-08-06 03:01:59 +00:00
#include "ImaginationBehavior.h"
#include "BehaviorBranchContext.h"
#include "DestroyableComponent.h"
#include "dpWorld.h"
#include "EntityManager.h"
#include "dLogger.h"
2022-07-28 13:39:57 +00:00
void ImaginationBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch) {
auto* entity = EntityManager::Instance()->GetEntity(branch.target);
2022-07-28 13:39:57 +00:00
if (entity == nullptr) {
return;
}
auto* destroyable = entity->GetComponent<DestroyableComponent>();
2022-07-28 13:39:57 +00:00
if (destroyable == nullptr) {
return;
}
destroyable->Imagine(this->m_imagination);
}
2022-07-28 13:39:57 +00:00
void ImaginationBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch) {
Handle(context, bit_stream, branch);
}
2022-07-28 13:39:57 +00:00
void ImaginationBehavior::Load() {
this->m_imagination = GetInt("imagination");
}