feat: request item list on hero created

This commit is contained in:
k0t9i 2023-10-26 22:16:39 +04:00
parent 604ba8af9b
commit efffe8a7cb

View File

@ -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<std::shared_timed_mutex>(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);
});