mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-12 19:28:21 +00:00
455f9470a5
* Move EntityManager to Game namespace * move initialization to later Need to wait for dZoneManager to be initialized. * Fix bugs - Cannot delete from a RandomAccessIterator while in a range based for loop. Touchup zone manager initialize replace magic numbers with better named constants replace magic zonecontrol id with a more readable hex alternative condense stack variables move initializers closer to their use initialize entity manager with zone control change initialize timings If zone is not zero we expect to initialize the entity manager during zone manager initialization Add constexpr for zone control LOT * Add proper error handling * revert vanity changes * Update WorldServer.cpp * Update dZoneManager.cpp
87 lines
2.1 KiB
C++
87 lines
2.1 KiB
C++
#include "InterruptBehavior.h"
|
|
#include "BehaviorBranchContext.h"
|
|
#include "BehaviorContext.h"
|
|
#include "Game.h"
|
|
#include "dLogger.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)) {
|
|
Game::logger->Log("InterruptBehavior", "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)) {
|
|
Game::logger->Log("InterruptBehavior", "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)) {
|
|
Game::logger->Log("InterruptBehavior", "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");
|
|
}
|