From efffe8a7cbbd7a162d516514a478dcb51522e9e1 Mon Sep 17 00:00:00 2001 From: k0t9i Date: Thu, 26 Oct 2023 22:16:39 +0400 Subject: [PATCH] feat: request item list on hero created --- .../Interlude/Repositories/ItemRepository.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/L2BotDll/Versions/Interlude/Repositories/ItemRepository.h b/L2BotDll/Versions/Interlude/Repositories/ItemRepository.h index 8dbe328..a8b861d 100644 --- a/L2BotDll/Versions/Interlude/Repositories/ItemRepository.h +++ b/L2BotDll/Versions/Interlude/Repositories/ItemRepository.h @@ -10,6 +10,7 @@ #include "Domain/Events/ItemUpdatedEvent.h" #include "Domain/Events/ItemDeletedEvent.h" #include "Domain/Events/HeroDeletedEvent.h" +#include "Domain/Events/HeroCreatedEvent.h" #include "Domain/Events/ItemAutousedEvent.h" #include "Domain/Events/OnEndItemListEvent.h" #include "Domain/Services/ServiceLocator.h" @@ -66,6 +67,15 @@ namespace Interlude m_IsNewCycle = true; } } + + void OnHeroCreated(const Events::Event& evt) + { + std::shared_lock(m_Mutex); + if (evt.GetName() == Events::HeroCreatedEvent::name) + { + m_NetworkHandler.RequestItemList(); + } + } void OnHeroDeleted(const Events::Event& evt) { @@ -191,6 +201,9 @@ namespace Interlude Services::ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(Events::HeroDeletedEvent::name, [this](const Events::Event& evt) { OnHeroDeleted(evt); }); + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(Events::HeroCreatedEvent::name, [this](const Events::Event& evt) { + OnHeroCreated(evt); + }); Services::ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(Events::ItemAutousedEvent::name, [this](const Events::Event& evt) { OnItemAutoused(evt); });