diff --git a/L2BotCore/Domain/Repositories/EntityRepositoryInterface.h b/L2BotCore/Domain/Repositories/EntityRepositoryInterface.h index 3d34459..f95d507 100644 --- a/L2BotCore/Domain/Repositories/EntityRepositoryInterface.h +++ b/L2BotCore/Domain/Repositories/EntityRepositoryInterface.h @@ -9,5 +9,6 @@ namespace L2Bot::Domain::Repositories public: virtual const std::unordered_map> GetEntities() = 0; virtual void Reset() = 0; + virtual void Init() {}; }; } diff --git a/L2BotCore/Domain/Services/WorldHandler.h b/L2BotCore/Domain/Services/WorldHandler.h index a1f8365..0cf681b 100644 --- a/L2BotCore/Domain/Services/WorldHandler.h +++ b/L2BotCore/Domain/Services/WorldHandler.h @@ -46,6 +46,15 @@ namespace L2Bot::Domain::Services void Start() { + m_DropRepository.Init(); + m_HeroRepository.Init(); + m_NPCRepository.Init(); + m_PlayerRepository.Init(); + m_SkillRepository.Init(); + m_ItemRepository.Init(); + m_AbnormalEffectRepository.Init(); + m_ChatMessageRepository.Init(); + m_ConnectingThread = std::thread(&WorldHandler::Connect, this); m_SendingThread = std::thread(&WorldHandler::Send, this); m_ReceivingThread = std::thread(&WorldHandler::Receive, this); diff --git a/L2BotDll/Application.h b/L2BotDll/Application.h index d1ea49c..72d1a02 100644 --- a/L2BotDll/Application.h +++ b/L2BotDll/Application.h @@ -9,6 +9,8 @@ #include "Serializers/JsonIncomingMessageFactory.h" #include "Transports/NamedPipeTransport.h" #include "Versions/VersionAbstractFactory.h" +#include "Services/ServiceLocator.h" +#include "Events/HeroDeletedEvent.h" using namespace L2Bot::Domain; @@ -33,20 +35,13 @@ public: m_Transport ) { - } Application() = delete; virtual ~Application() = default; void Start() { - HMODULE hEngine = GetModuleHandleA("Engine.dll"); - HMODULE hCore = GetModuleHandleA("Core.dll"); - - m_AbstractFactory.GetNetworkHandler().Init(hEngine); - m_AbstractFactory.GetGameEngine().Init(hEngine); - m_AbstractFactory.GetL2GameData().Init(hEngine); - m_AbstractFactory.GetFName().Init(hCore); + Init(); m_WorldHandler.Start(); } @@ -58,6 +53,20 @@ public: m_AbstractFactory.GetNetworkHandler().Restore(); } +private: + void Init() + { + ServiceLocator::GetInstance().SetEventDispatcher(std::make_unique()); + + HMODULE hEngine = GetModuleHandleA("Engine.dll"); + HMODULE hCore = GetModuleHandleA("Core.dll"); + + m_AbstractFactory.GetNetworkHandler().Init(hEngine); + m_AbstractFactory.GetGameEngine().Init(hEngine); + m_AbstractFactory.GetL2GameData().Init(hEngine); + m_AbstractFactory.GetFName().Init(hCore); + } + private: const VersionAbstractFactory& m_AbstractFactory; Services::WorldHandler m_WorldHandler; diff --git a/L2BotDll/Events/EventDispatcher.h b/L2BotDll/Events/EventDispatcher.h index ab36cf7..04e4645 100644 --- a/L2BotDll/Events/EventDispatcher.h +++ b/L2BotDll/Events/EventDispatcher.h @@ -11,10 +11,8 @@ class EventDispatcher public: using Delegate = std::function; - static EventDispatcher& GetInstance() { - static EventDispatcher instance; - return instance; - } + EventDispatcher() = default; + virtual ~EventDispatcher() = default; void Dispatch(const Event& evt) { @@ -36,12 +34,6 @@ public: m_Handlers[eventName].push_back(handler); } -private: - EventDispatcher() = default; - virtual ~EventDispatcher() = default; - EventDispatcher(const EventDispatcher&) = delete; - EventDispatcher& operator=(const EventDispatcher&) = delete; - private: std::unordered_map> m_Handlers; }; \ No newline at end of file diff --git a/L2BotDll/L2BotDll.vcxproj b/L2BotDll/L2BotDll.vcxproj index f2554a8..7a4918b 100644 --- a/L2BotDll/L2BotDll.vcxproj +++ b/L2BotDll/L2BotDll.vcxproj @@ -186,6 +186,7 @@ + diff --git a/L2BotDll/L2BotDll.vcxproj.filters b/L2BotDll/L2BotDll.vcxproj.filters index d1ced81..ac49ea5 100644 --- a/L2BotDll/L2BotDll.vcxproj.filters +++ b/L2BotDll/L2BotDll.vcxproj.filters @@ -204,6 +204,9 @@ Header Files + + Header Files + diff --git a/L2BotDll/Services/ServiceLocator.h b/L2BotDll/Services/ServiceLocator.h new file mode 100644 index 0000000..77e2ca8 --- /dev/null +++ b/L2BotDll/Services/ServiceLocator.h @@ -0,0 +1,30 @@ +#pragma once + +#include +#include "../Events/EventDispatcher.h" + +class ServiceLocator +{ +public: + static ServiceLocator& GetInstance() { + static ServiceLocator instance; + return instance; + } + + const std::unique_ptr& GetEventDispatcher() + { + return m_EventDispatcher; + } + void SetEventDispatcher(std::unique_ptr dispatcher) + { + m_EventDispatcher = std::move(dispatcher); + } +private: + ServiceLocator() = default; + virtual ~ServiceLocator() = default; + + ServiceLocator(const ServiceLocator&) = delete; + ServiceLocator& operator=(const ServiceLocator&) = delete; +private: + std::unique_ptr m_EventDispatcher; +}; \ No newline at end of file diff --git a/L2BotDll/Versions/Interlude/GameStructs/GameEngineWrapper.cpp b/L2BotDll/Versions/Interlude/GameStructs/GameEngineWrapper.cpp index ae885d8..69e1add 100644 --- a/L2BotDll/Versions/Interlude/GameStructs/GameEngineWrapper.cpp +++ b/L2BotDll/Versions/Interlude/GameStructs/GameEngineWrapper.cpp @@ -7,7 +7,6 @@ #include "../../../Events/SkillUsedEvent.h" #include "../../../Events/SkillCancelledEvent.h" #include "../../../Events/AbnormalEffectChangedEvent.h" -#include "../../../Events/EventDispatcher.h" #include "../../../Events/ItemCreatedEvent.h" #include "../../../Events/ItemUpdatedEvent.h" #include "../../../Events/ItemDeletedEvent.h" @@ -18,6 +17,7 @@ #include "../../../Events/CreatureDiedEvent.h" #include "../../../DTO/ItemData.h" #include "FName.h" +#include "../../../Services/ServiceLocator.h" namespace Interlude { @@ -94,31 +94,31 @@ namespace Interlude void __fastcall GameEngineWrapper::__OnSkillListPacket_hook(GameEngine* This, uint32_t, L2ParamStack& stack) { - EventDispatcher::GetInstance().Dispatch(SkillCreatedEvent{stack.GetBufferAsVector()}); + ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(SkillCreatedEvent{stack.GetBufferAsVector()}); (*__OnSkillListPacket)(This, stack); } int __fastcall GameEngineWrapper::__OnReceiveMagicSkillUse_hook(GameEngine* This, uint32_t, User* u1, User* u2, L2ParamStack& stack) { - EventDispatcher::GetInstance().Dispatch(SkillUsedEvent{ stack.GetBufferAsVector() }); + ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(SkillUsedEvent{ stack.GetBufferAsVector() }); return (*__OnReceiveMagicSkillUse)(This, u1, u2, stack); } void __fastcall GameEngineWrapper::__OnReceiveMagicSkillCanceled_hook(GameEngine* This, uint32_t, User* user) { - EventDispatcher::GetInstance().Dispatch(SkillCancelledEvent{ user->objectId }); + ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(SkillCancelledEvent{ user->objectId }); (*__OnReceiveMagicSkillCanceled)(This, user); } void __fastcall GameEngineWrapper::__AddAbnormalStatus_hook(GameEngine* This, uint32_t, L2ParamStack& stack) { - EventDispatcher::GetInstance().Dispatch(AbnormalEffectChangedEvent{ stack.GetBufferAsVector(3) }); + ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(AbnormalEffectChangedEvent{ stack.GetBufferAsVector(3) }); (*__AddAbnormalStatus)(This, stack); } void __fastcall GameEngineWrapper::__AddInventoryItem_hook(GameEngine* This, uint32_t, ItemInfo& itemInfo) { - EventDispatcher::GetInstance().Dispatch( + ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch( ItemCreatedEvent { ItemData @@ -154,13 +154,13 @@ namespace Interlude switch (actionType) { case UpdateItemListActionType::created: - EventDispatcher::GetInstance().Dispatch(ItemCreatedEvent{ itemData }); + ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(ItemCreatedEvent{ itemData }); break; case UpdateItemListActionType::updated: - EventDispatcher::GetInstance().Dispatch(ItemUpdatedEvent{ itemData }); + ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(ItemUpdatedEvent{ itemData }); break; case UpdateItemListActionType::deleted: - EventDispatcher::GetInstance().Dispatch(ItemDeletedEvent{ itemInfo.objectId }); + ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(ItemDeletedEvent{ itemInfo.objectId }); break; } (*__OnReceiveUpdateItemList)(This, actionType, itemInfo); @@ -168,7 +168,7 @@ namespace Interlude void __fastcall GameEngineWrapper::__OnExAutoSoulShot_hook(GameEngine* This, uint32_t, L2ParamStack& stack) { - EventDispatcher::GetInstance().Dispatch(ItemAutousedEvent{ stack.GetBufferAsVector() }); + ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(ItemAutousedEvent{ stack.GetBufferAsVector() }); (*__OnExAutoSoulShot)(This, stack); } @@ -181,13 +181,13 @@ namespace Interlude (*__Tick)(This, deltaTime); - EventDispatcher::GetInstance().Dispatch(GameEngineTickedEvent{}); + ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(GameEngineTickedEvent{}); } void __fastcall GameEngineWrapper::__OnSay2_hook(GameEngine* This, uint32_t, L2ParamStack& stack) { const auto buffer = stack.GetBufferAsVector(); - EventDispatcher::GetInstance().Dispatch( + ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch( ChatMessageCreatedEvent { ChatMessage @@ -204,7 +204,7 @@ namespace Interlude } void __fastcall GameEngineWrapper::__OnEndItemList_hook(GameEngine* This, uint32_t) { - EventDispatcher::GetInstance().Dispatch(OnEndItemListEvent()); + ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(OnEndItemListEvent()); (*__OnEndItemList)(This); } // TODO ini @@ -217,7 +217,7 @@ namespace Interlude int __fastcall GameEngineWrapper::__OnDie_hook(GameEngine* This, int, User* creature, L2ParamStack& stack) { - EventDispatcher::GetInstance().Dispatch(CreatureDiedEvent{ creature->objectId, stack.GetBufferAsVector() }); + ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(CreatureDiedEvent{ creature->objectId, stack.GetBufferAsVector() }); return (*__OnDie)(This, creature, stack); } diff --git a/L2BotDll/Versions/Interlude/GameStructs/NetworkHandlerWrapper.cpp b/L2BotDll/Versions/Interlude/GameStructs/NetworkHandlerWrapper.cpp index 22052c7..5e03b4f 100644 --- a/L2BotDll/Versions/Interlude/GameStructs/NetworkHandlerWrapper.cpp +++ b/L2BotDll/Versions/Interlude/GameStructs/NetworkHandlerWrapper.cpp @@ -2,8 +2,8 @@ #include "../../../Common/apihook.h" #include "NetworkHandlerWrapper.h" #include "../../../Events/SpoiledEvent.h" -#include "../../../Events/EventDispatcher.h" #include "ProcessManipulation.h" +#include "../../../Services/ServiceLocator.h" namespace Interlude { @@ -176,7 +176,7 @@ namespace Interlude p->GetMessageId() == static_cast(L2::SystemMessagePacket::Type::SPOIL_SUCCESS) || p->GetMessageId() == static_cast(L2::SystemMessagePacket::Type::ALREADY_SPOILED) ) { - EventDispatcher::GetInstance().Dispatch(SpoiledEvent{}); + ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(SpoiledEvent{}); } } diff --git a/L2BotDll/Versions/Interlude/Repositories/AbnormalEffectRepository.h b/L2BotDll/Versions/Interlude/Repositories/AbnormalEffectRepository.h index dc5162d..9774323 100644 --- a/L2BotDll/Versions/Interlude/Repositories/AbnormalEffectRepository.h +++ b/L2BotDll/Versions/Interlude/Repositories/AbnormalEffectRepository.h @@ -7,8 +7,8 @@ #include "../Factories/AbnormalEffectFactory.h" #include "../../../Events/AbnormalEffectChangedEvent.h" #include "../../../Events/HeroDeletedEvent.h" -#include "../../../Events/EventDispatcher.h" #include "../GameStructs/NetworkHandlerWrapper.h" +#include "../../../Services/ServiceLocator.h" using namespace L2Bot::Domain; @@ -27,12 +27,6 @@ namespace Interlude AbnormalEffectRepository(const AbnormalEffectFactory& factory) : m_Factory(factory) { - EventDispatcher::GetInstance().Subscribe(AbnormalEffectChangedEvent::name, [this](const Event& evt) { - OnEffectToggled(evt); - }); - EventDispatcher::GetInstance().Subscribe(HeroDeletedEvent::name, [this](const Event& evt) { - OnHeroDeleted(evt); - }); } AbnormalEffectRepository() = delete; @@ -41,6 +35,16 @@ namespace Interlude Reset(); } + void Init() override + { + ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(AbnormalEffectChangedEvent::name, [this](const Event& evt) { + OnEffectToggled(evt); + }); + ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(HeroDeletedEvent::name, [this](const Event& evt) { + OnHeroDeleted(evt); + }); + } + void Reset() override { std::shared_lock(m_Mutex); diff --git a/L2BotDll/Versions/Interlude/Repositories/ChatMessageRepository.h b/L2BotDll/Versions/Interlude/Repositories/ChatMessageRepository.h index aab817d..7f0f3d4 100644 --- a/L2BotDll/Versions/Interlude/Repositories/ChatMessageRepository.h +++ b/L2BotDll/Versions/Interlude/Repositories/ChatMessageRepository.h @@ -4,7 +4,7 @@ #include #include "../Factories/ChatMessageFactory.h" #include "../../../Events/ChatMessageCreatedEvent.h" -#include "../../../Events/EventDispatcher.h" +#include "../../../Services/ServiceLocator.h" using namespace L2Bot::Domain; @@ -20,18 +20,22 @@ namespace Interlude return m_Messages; } - void Reset() + void Reset() override { std::shared_lock(m_Mutex); m_Messages.clear(); } + void Init() override + { + ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(ChatMessageCreatedEvent::name, [this](const Event& evt) { + OnMessageCreated(evt); + }); + } + ChatMessageRepository(const ChatMessageFactory& factory) : m_Factory(factory) { - EventDispatcher::GetInstance().Subscribe(ChatMessageCreatedEvent::name, [this](const Event& evt) { - OnMessageCreated(evt); - }); } void OnMessageCreated(const Event& evt) diff --git a/L2BotDll/Versions/Interlude/Repositories/HeroRepository.h b/L2BotDll/Versions/Interlude/Repositories/HeroRepository.h index 2d57b71..c640544 100644 --- a/L2BotDll/Versions/Interlude/Repositories/HeroRepository.h +++ b/L2BotDll/Versions/Interlude/Repositories/HeroRepository.h @@ -3,10 +3,10 @@ #include #include "Domain/Repositories/EntityRepositoryInterface.h" #include "../Factories/HeroFactory.h" -#include "../../../Events/EventDispatcher.h" #include "../../../Events/HeroCreatedEvent.h" #include "../../../Events/HeroDeletedEvent.h" #include "../GameStructs/NetworkHandlerWrapper.h" +#include "../../../Services/ServiceLocator.h" using namespace L2Bot::Domain; @@ -25,7 +25,7 @@ namespace Interlude if (hero) { if (!m_Hero) { m_Hero = m_Factory.Create(hero); - EventDispatcher::GetInstance().Dispatch(HeroCreatedEvent{}); + ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(HeroCreatedEvent{}); } else { @@ -35,7 +35,7 @@ namespace Interlude } else if (m_Hero) { m_Hero = nullptr; - EventDispatcher::GetInstance().Dispatch(HeroDeletedEvent{}); + ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(HeroDeletedEvent{}); } return result; diff --git a/L2BotDll/Versions/Interlude/Repositories/ItemRepository.h b/L2BotDll/Versions/Interlude/Repositories/ItemRepository.h index 52eef0b..9c528d2 100644 --- a/L2BotDll/Versions/Interlude/Repositories/ItemRepository.h +++ b/L2BotDll/Versions/Interlude/Repositories/ItemRepository.h @@ -12,7 +12,7 @@ #include "../../../Events/HeroDeletedEvent.h" #include "../../../Events/ItemAutousedEvent.h" #include "../../../Events/OnEndItemListEvent.h" -#include "../../../Events/EventDispatcher.h" +#include "../../../Services/ServiceLocator.h" using namespace L2Bot::Domain; @@ -44,24 +44,6 @@ namespace Interlude m_NetworkHandler(networkHandler), m_Factory(factory) { - EventDispatcher::GetInstance().Subscribe(ItemCreatedEvent::name, [this](const Event& evt) { - OnItemCreated(evt); - }); - EventDispatcher::GetInstance().Subscribe(ItemUpdatedEvent::name, [this](const Event& evt) { - OnItemUpdated(evt); - }); - EventDispatcher::GetInstance().Subscribe(ItemDeletedEvent::name, [this](const Event& evt) { - OnItemDeleted(evt); - }); - EventDispatcher::GetInstance().Subscribe(HeroDeletedEvent::name, [this](const Event& evt) { - OnHeroDeleted(evt); - }); - EventDispatcher::GetInstance().Subscribe(ItemAutousedEvent::name, [this](const Event& evt) { - OnItemAutoused(evt); - }); - EventDispatcher::GetInstance().Subscribe(OnEndItemListEvent::name, [this](const Event& evt) { - OnEndItemList(evt); - }); } void OnEndItemList(const Event& evt) @@ -198,6 +180,28 @@ namespace Interlude m_NetworkHandler.RequestItemList(); } + void Init() override + { + ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(ItemCreatedEvent::name, [this](const Event& evt) { + OnItemCreated(evt); + }); + ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(ItemUpdatedEvent::name, [this](const Event& evt) { + OnItemUpdated(evt); + }); + ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(ItemDeletedEvent::name, [this](const Event& evt) { + OnItemDeleted(evt); + }); + ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(HeroDeletedEvent::name, [this](const Event& evt) { + OnHeroDeleted(evt); + }); + ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(ItemAutousedEvent::name, [this](const Event& evt) { + OnItemAutoused(evt); + }); + ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(OnEndItemListEvent::name, [this](const Event& evt) { + OnEndItemList(evt); + }); + } + private: const ItemFactory& m_Factory; std::unordered_map> m_Items; diff --git a/L2BotDll/Versions/Interlude/Repositories/NPCRepository.h b/L2BotDll/Versions/Interlude/Repositories/NPCRepository.h index 7e95c30..14053a6 100644 --- a/L2BotDll/Versions/Interlude/Repositories/NPCRepository.h +++ b/L2BotDll/Versions/Interlude/Repositories/NPCRepository.h @@ -5,10 +5,10 @@ #include "../GameStructs/NetworkHandlerWrapper.h" #include "Domain/Repositories/EntityRepositoryInterface.h" #include "../Factories/NPCFactory.h" -#include "../../../Events/EventDispatcher.h" #include "../../../Events/SpoiledEvent.h" #include "../../../Events/CreatureDiedEvent.h" #include "../../GameStructs/FindObjectsTrait.h" +#include "../../../Services/ServiceLocator.h" using namespace L2Bot::Domain; @@ -55,17 +55,21 @@ namespace Interlude m_Npcs.clear(); } + void Init() override + { + ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(SpoiledEvent::name, [this](const Event& evt) { + OnSpoiled(evt); + }); + ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(CreatureDiedEvent::name, [this](const Event& evt) { + OnCreatureDied(evt); + }); + } + NPCRepository(const NetworkHandlerWrapper& networkHandler, const NPCFactory& factory, const uint16_t radius) : m_NetworkHandler(networkHandler), m_Factory(factory), m_Radius(radius) { - EventDispatcher::GetInstance().Subscribe(SpoiledEvent::name, [this](const Event& evt) { - OnSpoiled(evt); - }); - EventDispatcher::GetInstance().Subscribe(CreatureDiedEvent::name, [this](const Event& evt) { - OnCreatureDied(evt); - }); } NPCRepository() = delete; diff --git a/L2BotDll/Versions/Interlude/Repositories/SkillRepository.h b/L2BotDll/Versions/Interlude/Repositories/SkillRepository.h index b3b6f1c..a17de1c 100644 --- a/L2BotDll/Versions/Interlude/Repositories/SkillRepository.h +++ b/L2BotDll/Versions/Interlude/Repositories/SkillRepository.h @@ -11,9 +11,9 @@ #include "../../../Events/AbnormalEffectChangedEvent.h" #include "../../../Events/HeroDeletedEvent.h" #include "../../../Events/GameEngineTickedEvent.h" -#include "../../../Events/EventDispatcher.h" #include "../GameStructs/NetworkHandlerWrapper.h" #include "../../../Common/TimerMap.h" +#include "../../../Services/ServiceLocator.h" using namespace L2Bot::Domain; @@ -34,24 +34,7 @@ namespace Interlude m_NetworkHandler(networkHandler), m_Factory(factory) { - EventDispatcher::GetInstance().Subscribe(SkillCreatedEvent::name, [this](const Event& evt) { - OnSkillCreated(evt); - }); - EventDispatcher::GetInstance().Subscribe(SkillUsedEvent::name, [this](const Event& evt) { - OnSkillUsed(evt); - }); - EventDispatcher::GetInstance().Subscribe(SkillCancelledEvent::name, [this](const Event& evt) { - OnSkillCancelled(evt); - }); - EventDispatcher::GetInstance().Subscribe(AbnormalEffectChangedEvent::name, [this](const Event& evt) { - OnSkillToggled(evt); - }); - EventDispatcher::GetInstance().Subscribe(HeroDeletedEvent::name, [this](const Event& evt) { - OnHeroDeleted(evt); - }); - EventDispatcher::GetInstance().Subscribe(GameEngineTickedEvent::name, [this](const Event& evt) { - OnGameEngineTicked(evt); - }); + } SkillRepository() = delete; @@ -68,6 +51,28 @@ namespace Interlude m_NewSkills.clear(); } + void Init() override + { + ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(SkillCreatedEvent::name, [this](const Event& evt) { + OnSkillCreated(evt); + }); + ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(SkillUsedEvent::name, [this](const Event& evt) { + OnSkillUsed(evt); + }); + ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(SkillCancelledEvent::name, [this](const Event& evt) { + OnSkillCancelled(evt); + }); + ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(AbnormalEffectChangedEvent::name, [this](const Event& evt) { + OnSkillToggled(evt); + }); + ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(HeroDeletedEvent::name, [this](const Event& evt) { + OnHeroDeleted(evt); + }); + ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(GameEngineTickedEvent::name, [this](const Event& evt) { + OnGameEngineTicked(evt); + }); + } + void OnGameEngineTicked(const Event& evt) { std::shared_lock(m_Mutex);