mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-09 20:24:16 +00:00
format codebase
This commit is contained in:
@@ -6,57 +6,46 @@
|
||||
#include "BehaviorContext.h"
|
||||
#include "BuffComponent.h"
|
||||
|
||||
void SwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch)
|
||||
{
|
||||
void SwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) {
|
||||
auto state = true;
|
||||
|
||||
if (this->m_imagination > 0 || !this->m_isEnemyFaction)
|
||||
{
|
||||
if (this->m_imagination > 0 || !this->m_isEnemyFaction) {
|
||||
bitStream->Read(state);
|
||||
}
|
||||
|
||||
auto* entity = EntityManager::Instance()->GetEntity(context->originator);
|
||||
auto* entity = EntityManager::Instance()->GetEntity(context->originator);
|
||||
|
||||
if (entity == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>();
|
||||
|
||||
if (destroyableComponent == nullptr)
|
||||
{
|
||||
if (entity == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
Game::logger->Log("SwitchBehavior", "[%i] State: (%d), imagination: (%i) / (%f)", entity->GetLOT(), state, destroyableComponent->GetImagination(), destroyableComponent->GetMaxImagination());
|
||||
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>();
|
||||
|
||||
if (state || (entity->GetLOT() == 8092 && destroyableComponent->GetImagination() >= m_imagination))
|
||||
{
|
||||
this->m_actionTrue->Handle(context, bitStream, branch);
|
||||
if (destroyableComponent == nullptr) {
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Game::logger->Log("SwitchBehavior", "[%i] State: (%d), imagination: (%i) / (%f)", entity->GetLOT(), state, destroyableComponent->GetImagination(), destroyableComponent->GetMaxImagination());
|
||||
|
||||
if (state || (entity->GetLOT() == 8092 && destroyableComponent->GetImagination() >= m_imagination)) {
|
||||
this->m_actionTrue->Handle(context, bitStream, branch);
|
||||
} else {
|
||||
this->m_actionFalse->Handle(context, bitStream, branch);
|
||||
}
|
||||
}
|
||||
|
||||
void SwitchBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
||||
{
|
||||
void SwitchBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||
auto state = true;
|
||||
|
||||
if (this->m_imagination > 0 || !this->m_isEnemyFaction)
|
||||
{
|
||||
if (this->m_imagination > 0 || !this->m_isEnemyFaction) {
|
||||
auto* entity = EntityManager::Instance()->GetEntity(branch.target);
|
||||
|
||||
state = entity != nullptr;
|
||||
|
||||
if (state && m_targetHasBuff != 0)
|
||||
{
|
||||
auto* buffComponent = entity->GetComponent<BuffComponent>();
|
||||
if (state && m_targetHasBuff != 0) {
|
||||
auto* buffComponent = entity->GetComponent<BuffComponent>();
|
||||
|
||||
if (buffComponent != nullptr && !buffComponent->HasBuff(m_targetHasBuff))
|
||||
{
|
||||
if (buffComponent != nullptr && !buffComponent->HasBuff(m_targetHasBuff)) {
|
||||
state = false;
|
||||
}
|
||||
}
|
||||
@@ -64,18 +53,14 @@ void SwitchBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS
|
||||
bitStream->Write(state);
|
||||
}
|
||||
|
||||
if (state)
|
||||
{
|
||||
if (state) {
|
||||
this->m_actionTrue->Calculate(context, bitStream, branch);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this->m_actionFalse->Calculate(context, bitStream, branch);
|
||||
}
|
||||
}
|
||||
|
||||
void SwitchBehavior::Load()
|
||||
{
|
||||
void SwitchBehavior::Load() {
|
||||
this->m_actionTrue = GetAction("action_true");
|
||||
|
||||
this->m_actionFalse = GetAction("action_false");
|
||||
|
Reference in New Issue
Block a user