mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-24 06:27:24 +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
87 lines
2.0 KiB
C++
87 lines
2.0 KiB
C++
#include "InterruptBehavior.h"
|
|
#include "BehaviorBranchContext.h"
|
|
#include "BehaviorContext.h"
|
|
#include "Game.h"
|
|
#include "Logger.h"
|
|
#include "EntityManager.h"
|
|
#include "SkillComponent.h"
|
|
|
|
|
|
void InterruptBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
|
if (branch.target != context->originator) {
|
|
bool unknown = false;
|
|
|
|
if (!bitStream->Read(unknown)) {
|
|
LOG("Unable to read unknown1 from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());
|
|
return;
|
|
};
|
|
|
|
if (unknown) return;
|
|
}
|
|
|
|
if (!this->m_interruptBlock) {
|
|
bool unknown = false;
|
|
|
|
if (!bitStream->Read(unknown)) {
|
|
LOG("Unable to read unknown2 from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());
|
|
return;
|
|
};
|
|
|
|
if (unknown) return;
|
|
}
|
|
|
|
if (this->m_target) // Guess...
|
|
{
|
|
bool unknown = false;
|
|
|
|
if (!bitStream->Read(unknown)) {
|
|
LOG("Unable to read unknown3 from bitStream, aborting Handle! %i", bitStream->GetNumberOfUnreadBits());
|
|
return;
|
|
};
|
|
}
|
|
|
|
if (branch.target == context->originator) return;
|
|
|
|
auto* target = Game::entityManager->GetEntity(branch.target);
|
|
|
|
if (target == nullptr) return;
|
|
|
|
auto* skillComponent = target->GetComponent<SkillComponent>();
|
|
|
|
if (skillComponent == nullptr) return;
|
|
|
|
skillComponent->Interrupt();
|
|
}
|
|
|
|
|
|
void InterruptBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
|
if (branch.target != context->originator) {
|
|
bitStream->Write(false);
|
|
}
|
|
|
|
if (!this->m_interruptBlock) {
|
|
bitStream->Write(false);
|
|
}
|
|
|
|
bitStream->Write(false);
|
|
|
|
if (branch.target == context->originator) return;
|
|
|
|
auto* target = Game::entityManager->GetEntity(branch.target);
|
|
|
|
if (target == nullptr) return;
|
|
|
|
auto* skillComponent = target->GetComponent<SkillComponent>();
|
|
|
|
if (skillComponent == nullptr) return;
|
|
|
|
skillComponent->Interrupt();
|
|
}
|
|
|
|
|
|
void InterruptBehavior::Load() {
|
|
this->m_target = GetBoolean("target");
|
|
|
|
this->m_interruptBlock = GetBoolean("interrupt_block");
|
|
}
|