mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-25 06:57:28 +00:00
5942182486
* Logger: Rename logger to Logger from dLogger * Logger: Add compile time filename Fix include issues Add writers Add macros Add macro to force compilation * Logger: Replace calls with macros Allows for filename and line number to be logged * Logger: Add comments and remove extra define Logger: Replace with unique_ptr also flush console at exit. regular file writer should be flushed on file close. Logger: Remove constexpr on variable * Logger: Simplify code * Update Logger.cpp
118 lines
3.9 KiB
C++
118 lines
3.9 KiB
C++
#include "ImmunityBehavior.h"
|
|
|
|
#include "BehaviorBranchContext.h"
|
|
#include "BehaviorContext.h"
|
|
#include "EntityManager.h"
|
|
#include "Game.h"
|
|
#include "Logger.h"
|
|
#include "DestroyableComponent.h"
|
|
#include "ControllablePhysicsComponent.h"
|
|
#include "eStateChangeType.h"
|
|
|
|
void ImmunityBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) {
|
|
auto* target = Game::entityManager->GetEntity(branch.target);
|
|
|
|
if (!target) {
|
|
LOG("Failed to find target (%llu)!", branch.target);
|
|
return;
|
|
}
|
|
|
|
auto* destroyableComponent = target->GetComponent<DestroyableComponent>();
|
|
if (destroyableComponent) {
|
|
destroyableComponent->SetStatusImmunity(
|
|
eStateChangeType::PUSH,
|
|
this->m_ImmuneToBasicAttack,
|
|
this->m_ImmuneToDamageOverTime,
|
|
this->m_ImmuneToKnockback,
|
|
this->m_ImmuneToInterrupt,
|
|
this->m_ImmuneToSpeed,
|
|
this->m_ImmuneToImaginationGain,
|
|
this->m_ImmuneToImaginationLoss,
|
|
this->m_ImmuneToQuickbuildInterrupt,
|
|
this->m_ImmuneToPullToPoint
|
|
);
|
|
}
|
|
|
|
auto* controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>();
|
|
if (controllablePhysicsComponent) {
|
|
controllablePhysicsComponent->SetStunImmunity(
|
|
eStateChangeType::PUSH,
|
|
context->caster,
|
|
this->m_ImmuneToStunAttack,
|
|
this->m_ImmuneToStunEquip,
|
|
this->m_ImmuneToStunInteract,
|
|
this->m_ImmuneToStunJump,
|
|
this->m_ImmuneToStunMove,
|
|
this->m_ImmuneToStunTurn,
|
|
this->m_ImmuneToStunUseItem
|
|
);
|
|
}
|
|
|
|
context->RegisterTimerBehavior(this, branch, target->GetObjectID());
|
|
}
|
|
|
|
void ImmunityBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
|
Handle(context, bitStream, branch);
|
|
}
|
|
|
|
void ImmunityBehavior::Timer(BehaviorContext* context, BehaviorBranchContext branch, const LWOOBJID second) {
|
|
auto* target = Game::entityManager->GetEntity(second);
|
|
|
|
if (!target) {
|
|
LOG("Failed to find target (%llu)!", second);
|
|
return;
|
|
}
|
|
|
|
auto* destroyableComponent = target->GetComponent<DestroyableComponent>();
|
|
if (destroyableComponent) {
|
|
destroyableComponent->SetStatusImmunity(
|
|
eStateChangeType::POP,
|
|
this->m_ImmuneToBasicAttack,
|
|
this->m_ImmuneToDamageOverTime,
|
|
this->m_ImmuneToKnockback,
|
|
this->m_ImmuneToInterrupt,
|
|
this->m_ImmuneToSpeed,
|
|
this->m_ImmuneToImaginationGain,
|
|
this->m_ImmuneToImaginationLoss,
|
|
this->m_ImmuneToQuickbuildInterrupt,
|
|
this->m_ImmuneToPullToPoint
|
|
);
|
|
}
|
|
|
|
auto* controllablePhysicsComponent = target->GetComponent<ControllablePhysicsComponent>();
|
|
if (controllablePhysicsComponent) {
|
|
controllablePhysicsComponent->SetStunImmunity(
|
|
eStateChangeType::POP,
|
|
context->caster,
|
|
this->m_ImmuneToStunAttack,
|
|
this->m_ImmuneToStunEquip,
|
|
this->m_ImmuneToStunInteract,
|
|
this->m_ImmuneToStunJump,
|
|
this->m_ImmuneToStunMove,
|
|
this->m_ImmuneToStunTurn,
|
|
this->m_ImmuneToStunUseItem
|
|
);
|
|
}
|
|
|
|
}
|
|
|
|
void ImmunityBehavior::Load() {
|
|
//Stun
|
|
this->m_ImmuneToStunAttack = GetBoolean("immune_stun_attack", false);
|
|
this->m_ImmuneToStunEquip = GetBoolean("immune_stun_equip", false);
|
|
this->m_ImmuneToStunInteract = GetBoolean("immune_stun_interact", false);
|
|
this->m_ImmuneToStunMove = GetBoolean("immune_stun_move", false);
|
|
this->m_ImmuneToStunTurn = GetBoolean("immune_stun_rotate", false);
|
|
|
|
// Status
|
|
this->m_ImmuneToBasicAttack = GetBoolean("immune_basic_attack", false);
|
|
this->m_ImmuneToDamageOverTime = GetBoolean("immune_damage_over_time", false);
|
|
this->m_ImmuneToKnockback = GetBoolean("immune_knockback", false);
|
|
this->m_ImmuneToInterrupt = GetBoolean("immune_interrupt", false);
|
|
this->m_ImmuneToSpeed = GetBoolean("immune_speed", false);
|
|
this->m_ImmuneToImaginationGain = GetBoolean("immune_imagination_gain", false);
|
|
this->m_ImmuneToImaginationLoss = GetBoolean("immune_imagination_loss", false);
|
|
this->m_ImmuneToQuickbuildInterrupt = GetBoolean("immune_quickbuild_interrupts", false);
|
|
this->m_ImmuneToPullToPoint = GetBoolean("immune_pulltopoint", false);
|
|
}
|