DarkflameServer/dGame/dBehaviors/VentureVisionBehavior.cpp
David Markowitz 455f9470a5
Move EntityManager to Game namespace (#1140)
* 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
2023-07-15 13:56:33 -07:00

48 lines
1.7 KiB
C++

#include "VentureVisionBehavior.h"
#include "BehaviorBranchContext.h"
#include "CharacterComponent.h"
#include "BehaviorContext.h"
void VentureVisionBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
const auto targetEntity = Game::entityManager->GetEntity(branch.target);
if (targetEntity) {
auto characterComponent = targetEntity->GetComponent<CharacterComponent>();
if (characterComponent) {
if (m_show_collectibles) characterComponent->AddVentureVisionEffect(m_ShowCollectibles);
if (m_show_minibosses) characterComponent->AddVentureVisionEffect(m_ShowMiniBosses);
if (m_show_pet_digs) characterComponent->AddVentureVisionEffect(m_ShowPetDigs);
}
if (branch.duration > 0) context->RegisterTimerBehavior(this, branch);
}
}
void VentureVisionBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch) {
const auto targetEntity = Game::entityManager->GetEntity(branch.target);
if (targetEntity) {
auto characterComponent = targetEntity->GetComponent<CharacterComponent>();
if (characterComponent) {
if (m_show_collectibles) characterComponent->RemoveVentureVisionEffect(m_ShowCollectibles);
if (m_show_minibosses) characterComponent->RemoveVentureVisionEffect(m_ShowMiniBosses);
if (m_show_pet_digs) characterComponent->RemoveVentureVisionEffect(m_ShowPetDigs);
}
}
}
void VentureVisionBehavior::Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) {
UnCast(context, branch);
}
void VentureVisionBehavior::Load() {
this->m_show_pet_digs = GetBoolean("show_pet_digs");
this->m_show_minibosses = GetBoolean("show_minibosses");
this->m_show_collectibles = GetBoolean("show_collectibles");
}