2022-12-23 18:05:30 -08:00
|
|
|
#include "DarkInspirationBehavior.h"
|
|
|
|
|
|
|
|
#include "BehaviorBranchContext.h"
|
|
|
|
#include "Entity.h"
|
|
|
|
#include "DestroyableComponent.h"
|
|
|
|
#include "EntityManager.h"
|
|
|
|
#include "BehaviorContext.h"
|
|
|
|
|
2024-02-27 01:25:44 -06:00
|
|
|
void DarkInspirationBehavior::Handle(BehaviorContext* context, RakNet::BitStream& bitStream, const BehaviorBranchContext branch) {
|
2023-07-15 13:56:33 -07:00
|
|
|
auto* target = Game::entityManager->GetEntity(branch.target);
|
2022-12-23 18:05:30 -08:00
|
|
|
|
|
|
|
if (target == nullptr) {
|
2023-10-21 16:31:55 -07:00
|
|
|
LOG_DEBUG("Failed to find target (%llu)!", branch.target);
|
2022-12-23 18:05:30 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto* destroyableComponent = target->GetComponent<DestroyableComponent>();
|
|
|
|
|
|
|
|
if (destroyableComponent == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (destroyableComponent->HasFaction(m_FactionList)) {
|
|
|
|
this->m_ActionIfFactionMatches->Handle(context, bitStream, branch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-27 01:25:44 -06:00
|
|
|
void DarkInspirationBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) {
|
2023-07-15 13:56:33 -07:00
|
|
|
auto* target = Game::entityManager->GetEntity(branch.target);
|
2022-12-23 18:05:30 -08:00
|
|
|
|
|
|
|
if (target == nullptr) {
|
2023-10-21 16:31:55 -07:00
|
|
|
LOG_DEBUG("Failed to find target (%llu)!", branch.target);
|
2022-12-23 18:05:30 -08:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto* destroyableComponent = target->GetComponent<DestroyableComponent>();
|
|
|
|
|
|
|
|
if (destroyableComponent == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (destroyableComponent->HasFaction(m_FactionList)) {
|
|
|
|
this->m_ActionIfFactionMatches->Calculate(context, bitStream, branch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DarkInspirationBehavior::Load() {
|
|
|
|
this->m_ActionIfFactionMatches = GetAction("action");
|
|
|
|
|
|
|
|
this->m_FactionList = GetInt("faction_list");
|
|
|
|
}
|