diff --git a/L2BotCore/Domain/DTO/ChatMessageData.h b/L2BotCore/Domain/DTO/ChatMessageData.h new file mode 100644 index 0000000..b26b226 --- /dev/null +++ b/L2BotCore/Domain/DTO/ChatMessageData.h @@ -0,0 +1,15 @@ +#pragma once + +#include +#include + +namespace L2Bot::Domain::DTO +{ + struct ChatMessageData + { + const uint32_t objectId = 0; + const uint8_t channel = 0; + const std::wstring name = L""; + const std::wstring text = L""; + }; +} \ No newline at end of file diff --git a/L2BotCore/Domain/DTO/ItemData.h b/L2BotCore/Domain/DTO/ItemData.h new file mode 100644 index 0000000..d6a3683 --- /dev/null +++ b/L2BotCore/Domain/DTO/ItemData.h @@ -0,0 +1,18 @@ +#pragma once + +#include + +namespace L2Bot::Domain::DTO +{ + struct ItemData + { + const uint32_t objectId = 0; + const uint32_t itemId = 0; + const uint32_t amount = 0; + const uint16_t isEquipped = 0; + const uint16_t enchantLevel = 0; + const int32_t mana = -1; + const bool isQuest = false; + const bool isTwoHanded = false; + }; +} \ No newline at end of file diff --git a/L2BotCore/Domain/Events/AbnormalEffectChangedEvent.h b/L2BotCore/Domain/Events/AbnormalEffectChangedEvent.h new file mode 100644 index 0000000..71f37d6 --- /dev/null +++ b/L2BotCore/Domain/Events/AbnormalEffectChangedEvent.h @@ -0,0 +1,36 @@ +#pragma once + +#include +#include +#include "Event.h" + +namespace L2Bot::Domain::Events +{ + class AbnormalEffectChangedEvent : public Event + { + public: + static constexpr const char* name = "abnormalEffectChanged"; + + const std::string GetName() const + { + return std::string(name); + } + + const std::vector& GetSkillInfo() const + { + return m_SkillInfo; + } + + AbnormalEffectChangedEvent(const std::vector skillInfo) : + m_SkillInfo(skillInfo) + { + + } + + AbnormalEffectChangedEvent() = delete; + virtual ~AbnormalEffectChangedEvent() = default; + + private: + const std::vector m_SkillInfo; + }; +} \ No newline at end of file diff --git a/L2BotCore/Domain/Events/ChatMessageCreatedEvent.h b/L2BotCore/Domain/Events/ChatMessageCreatedEvent.h new file mode 100644 index 0000000..58b9db2 --- /dev/null +++ b/L2BotCore/Domain/Events/ChatMessageCreatedEvent.h @@ -0,0 +1,37 @@ +#pragma once + +#include +#include +#include "Event.h" +#include "../DTO/ChatMessageData.h" + +namespace L2Bot::Domain::Events +{ + class ChatMessageCreatedEvent : public Event + { + public: + static constexpr const char* name = "chatMessageCreated"; + + const std::string GetName() const + { + return std::string(name); + } + + const DTO::ChatMessageData& GetChatMessage() const + { + return m_ChatMessage; + } + + ChatMessageCreatedEvent(const DTO::ChatMessageData chatMessage) : + m_ChatMessage(chatMessage) + { + + } + + ChatMessageCreatedEvent() = delete; + virtual ~ChatMessageCreatedEvent() = default; + + private: + const DTO::ChatMessageData m_ChatMessage; + }; +} \ No newline at end of file diff --git a/L2BotCore/Domain/Events/CreatureDiedEvent.h b/L2BotCore/Domain/Events/CreatureDiedEvent.h new file mode 100644 index 0000000..20df224 --- /dev/null +++ b/L2BotCore/Domain/Events/CreatureDiedEvent.h @@ -0,0 +1,43 @@ +#pragma once + +#include +#include +#include "Event.h" + +namespace L2Bot::Domain::Events +{ + class CreatureDiedEvent : public Event + { + public: + static constexpr const char* name = "creatureDied"; + + const std::string GetName() const + { + return std::string(name); + } + + const uint32_t GetCreatureId() const + { + return m_CreatureId; + } + + const std::vector& GetCreatureInfo() const + { + return m_CreatureInfo; + } + + CreatureDiedEvent(uint32_t creatureId, const std::vector& creatureInfo) : + m_CreatureId(creatureId), + m_CreatureInfo(creatureInfo) + { + + } + + CreatureDiedEvent() = delete; + virtual ~CreatureDiedEvent() = default; + + private: + const uint32_t m_CreatureId; + const std::vector m_CreatureInfo; + }; +} \ No newline at end of file diff --git a/L2BotCore/Domain/Events/Event.h b/L2BotCore/Domain/Events/Event.h new file mode 100644 index 0000000..1b841c1 --- /dev/null +++ b/L2BotCore/Domain/Events/Event.h @@ -0,0 +1,15 @@ +#pragma once + +#include + +namespace L2Bot::Domain::Events +{ + class Event + { + public: + virtual const std::string GetName() const = 0; + + Event() = default; + virtual ~Event() = default; + }; +} \ No newline at end of file diff --git a/L2BotCore/Domain/Events/EventDispatcher.h b/L2BotCore/Domain/Events/EventDispatcher.h new file mode 100644 index 0000000..50f9d54 --- /dev/null +++ b/L2BotCore/Domain/Events/EventDispatcher.h @@ -0,0 +1,42 @@ +#pragma once + +#include +#include +#include +#include +#include "Event.h" + +namespace L2Bot::Domain::Events +{ + class EventDispatcher + { + public: + using Delegate = std::function; + + EventDispatcher() = default; + virtual ~EventDispatcher() = default; + + void Dispatch(const Event& evt) + { + const auto& name = evt.GetName(); + + if (m_Handlers.find(name) == m_Handlers.end()) + { + return; + } + + for (const auto& handler : m_Handlers[name]) + { + handler(evt); + } + } + + void Subscribe(const std::string& eventName, const Delegate handler) + { + m_Handlers[eventName].push_back(handler); + } + + private: + std::unordered_map> m_Handlers; + }; +} \ No newline at end of file diff --git a/L2BotCore/Domain/Events/GameEngineTickedEvent.h b/L2BotCore/Domain/Events/GameEngineTickedEvent.h new file mode 100644 index 0000000..e5dbf11 --- /dev/null +++ b/L2BotCore/Domain/Events/GameEngineTickedEvent.h @@ -0,0 +1,21 @@ +#pragma once + +#include +#include "Event.h" + +namespace L2Bot::Domain::Events +{ + class GameEngineTickedEvent : public Event + { + public: + static constexpr const char* name = "gameEngineTicked"; + + const std::string GetName() const + { + return std::string(name); + } + + GameEngineTickedEvent() = default; + virtual ~GameEngineTickedEvent() = default; + }; +} \ No newline at end of file diff --git a/L2BotCore/Domain/Events/HeroCreatedEvent.h b/L2BotCore/Domain/Events/HeroCreatedEvent.h new file mode 100644 index 0000000..b3067d6 --- /dev/null +++ b/L2BotCore/Domain/Events/HeroCreatedEvent.h @@ -0,0 +1,22 @@ +#pragma once + +#include +#include +#include "Event.h" + +namespace L2Bot::Domain::Events +{ + class HeroCreatedEvent : public Event + { + public: + static constexpr const char* name = "heroCreated"; + + const std::string GetName() const + { + return std::string(name); + } + + HeroCreatedEvent() = default; + virtual ~HeroCreatedEvent() = default; + }; +} \ No newline at end of file diff --git a/L2BotCore/Domain/Events/HeroDeletedEvent.h b/L2BotCore/Domain/Events/HeroDeletedEvent.h new file mode 100644 index 0000000..6809c53 --- /dev/null +++ b/L2BotCore/Domain/Events/HeroDeletedEvent.h @@ -0,0 +1,20 @@ +#pragma once + +#include "Event.h" + +namespace L2Bot::Domain::Events +{ + class HeroDeletedEvent : public Event + { + public: + static constexpr const char* name = "heroDeleted"; + + const std::string GetName() const + { + return std::string(name); + } + + HeroDeletedEvent() = default; + virtual ~HeroDeletedEvent() = default; + }; +} \ No newline at end of file diff --git a/L2BotCore/Domain/Events/ItemAutousedEvent.h b/L2BotCore/Domain/Events/ItemAutousedEvent.h new file mode 100644 index 0000000..8293aec --- /dev/null +++ b/L2BotCore/Domain/Events/ItemAutousedEvent.h @@ -0,0 +1,36 @@ +#pragma once + +#include +#include +#include "Event.h" + +namespace L2Bot::Domain::Events +{ + class ItemAutousedEvent : public Event + { + public: + static constexpr const char* name = "itemAutoused"; + + const std::string GetName() const + { + return std::string(name); + } + + const std::vector& GetAutouseInfo() const + { + return m_AutouseInfo; + } + + ItemAutousedEvent(const std::vector autouseInfo) : + m_AutouseInfo(autouseInfo) + { + + } + + ItemAutousedEvent() = delete; + virtual ~ItemAutousedEvent() = default; + + private: + const std::vector m_AutouseInfo; + }; +} \ No newline at end of file diff --git a/L2BotCore/Domain/Events/ItemCreatedEvent.h b/L2BotCore/Domain/Events/ItemCreatedEvent.h new file mode 100644 index 0000000..8ad4d9f --- /dev/null +++ b/L2BotCore/Domain/Events/ItemCreatedEvent.h @@ -0,0 +1,37 @@ +#pragma once + +#include +#include +#include "Event.h" +#include "../DTO/ItemData.h" + +namespace L2Bot::Domain::Events +{ + class ItemCreatedEvent : public Event + { + public: + static constexpr const char* name = "itemCreated"; + + const std::string GetName() const + { + return std::string(name); + } + + const DTO::ItemData& GetItemData() const + { + return m_ItemData; + } + + ItemCreatedEvent(const DTO::ItemData itemData) : + m_ItemData(itemData) + { + + } + + ItemCreatedEvent() = delete; + virtual ~ItemCreatedEvent() = default; + + private: + const DTO::ItemData m_ItemData; + }; +} \ No newline at end of file diff --git a/L2BotCore/Domain/Events/ItemDeletedEvent.h b/L2BotCore/Domain/Events/ItemDeletedEvent.h new file mode 100644 index 0000000..9cae64b --- /dev/null +++ b/L2BotCore/Domain/Events/ItemDeletedEvent.h @@ -0,0 +1,36 @@ +#pragma once + +#include +#include +#include "Event.h" + +namespace L2Bot::Domain::Events +{ + class ItemDeletedEvent : public Event + { + public: + static constexpr const char* name = "itemDeleted"; + + const std::string GetName() const + { + return std::string(name); + } + + const uint32_t GetObjectId() const + { + return m_ObjectId; + } + + ItemDeletedEvent(const uint32_t objectId) : + m_ObjectId(objectId) + { + + } + + ItemDeletedEvent() = delete; + virtual ~ItemDeletedEvent() = default; + + private: + const uint32_t m_ObjectId; + }; +} \ No newline at end of file diff --git a/L2BotCore/Domain/Events/ItemUpdatedEvent.h b/L2BotCore/Domain/Events/ItemUpdatedEvent.h new file mode 100644 index 0000000..1fe0cab --- /dev/null +++ b/L2BotCore/Domain/Events/ItemUpdatedEvent.h @@ -0,0 +1,37 @@ +#pragma once + +#include +#include +#include "Event.h" +#include "../DTO/ItemData.h" + +namespace L2Bot::Domain::Events +{ + class ItemUpdatedEvent : public Event + { + public: + static constexpr const char* name = "itemUpdated"; + + const std::string GetName() const + { + return std::string(name); + } + + const DTO::ItemData& GetItemData() const + { + return m_ItemData; + } + + ItemUpdatedEvent(const DTO::ItemData itemData) : + m_ItemData(itemData) + { + + } + + ItemUpdatedEvent() = delete; + virtual ~ItemUpdatedEvent() = default; + + private: + const DTO::ItemData m_ItemData; + }; +} \ No newline at end of file diff --git a/L2BotCore/Domain/Events/OnEndItemListEvent.h b/L2BotCore/Domain/Events/OnEndItemListEvent.h new file mode 100644 index 0000000..4e482b7 --- /dev/null +++ b/L2BotCore/Domain/Events/OnEndItemListEvent.h @@ -0,0 +1,20 @@ +#pragma once + +#include "Event.h" + +namespace L2Bot::Domain::Events +{ + class OnEndItemListEvent : public Event + { + public: + static constexpr const char* name = "onEndItemList"; + + const std::string GetName() const + { + return std::string(name); + } + + OnEndItemListEvent() = default; + virtual ~OnEndItemListEvent() = default; + }; +} \ No newline at end of file diff --git a/L2BotCore/Domain/Events/SkillCancelledEvent.h b/L2BotCore/Domain/Events/SkillCancelledEvent.h new file mode 100644 index 0000000..039f3cb --- /dev/null +++ b/L2BotCore/Domain/Events/SkillCancelledEvent.h @@ -0,0 +1,35 @@ +#pragma once + +#include +#include "Event.h" + +namespace L2Bot::Domain::Events +{ + class SkillCancelledEvent : public Event + { + public: + static constexpr const char* name = "skillCancelled"; + + const std::string GetName() const + { + return std::string(name); + } + + const uint32_t GetInitiatorId() const + { + return m_InitiatorId; + } + + SkillCancelledEvent(const uint32_t initiatorId) : + m_InitiatorId(initiatorId) + { + + } + + SkillCancelledEvent() = delete; + virtual ~SkillCancelledEvent() = default; + + private: + const uint32_t m_InitiatorId; + }; +} \ No newline at end of file diff --git a/L2BotCore/Domain/Events/SkillCreatedEvent.h b/L2BotCore/Domain/Events/SkillCreatedEvent.h new file mode 100644 index 0000000..5f2cc9f --- /dev/null +++ b/L2BotCore/Domain/Events/SkillCreatedEvent.h @@ -0,0 +1,36 @@ +#pragma once + +#include +#include +#include "Event.h" + +namespace L2Bot::Domain::Events +{ + class SkillCreatedEvent : public Event + { + public: + static constexpr const char* name = "skillCreated"; + + const std::string GetName() const + { + return std::string(name); + } + + const std::vector& GetSkillInfo() const + { + return m_SkillInfo; + } + + SkillCreatedEvent(const std::vector skillInfo) : + m_SkillInfo(skillInfo) + { + + } + + SkillCreatedEvent() = delete; + virtual ~SkillCreatedEvent() = default; + + private: + const std::vector m_SkillInfo; + }; +} \ No newline at end of file diff --git a/L2BotCore/Domain/Events/SkillUsedEvent.h b/L2BotCore/Domain/Events/SkillUsedEvent.h new file mode 100644 index 0000000..5be8cad --- /dev/null +++ b/L2BotCore/Domain/Events/SkillUsedEvent.h @@ -0,0 +1,36 @@ +#pragma once + +#include +#include +#include "Event.h" + +namespace L2Bot::Domain::Events +{ + class SkillUsedEvent : public Event + { + public: + static constexpr const char* name = "skillUsed"; + + const std::string GetName() const + { + return std::string(name); + } + + const std::vector& GetSkillInfo() const + { + return m_SkillInfo; + } + + SkillUsedEvent(const std::vector skillInfo) : + m_SkillInfo(skillInfo) + { + + } + + SkillUsedEvent() = delete; + virtual ~SkillUsedEvent() = default; + + private: + const std::vector m_SkillInfo; + }; +} \ No newline at end of file diff --git a/L2BotCore/Domain/Events/SpoiledEvent.h b/L2BotCore/Domain/Events/SpoiledEvent.h new file mode 100644 index 0000000..8b3fe35 --- /dev/null +++ b/L2BotCore/Domain/Events/SpoiledEvent.h @@ -0,0 +1,21 @@ +#pragma once + +#include +#include "Event.h" + +namespace L2Bot::Domain::Events +{ + class SpoiledEvent : public Event + { + public: + static constexpr const char* name = "spoiled"; + + const std::string GetName() const + { + return std::string(name); + } + + SpoiledEvent() = default; + virtual ~SpoiledEvent() = default; + }; +} \ No newline at end of file diff --git a/L2BotCore/Domain/Services/ServiceLocator.h b/L2BotCore/Domain/Services/ServiceLocator.h new file mode 100644 index 0000000..149d8b7 --- /dev/null +++ b/L2BotCore/Domain/Services/ServiceLocator.h @@ -0,0 +1,33 @@ +#pragma once + +#include +#include "../Events/EventDispatcher.h" + +namespace L2Bot::Domain::Services +{ + 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/L2BotCore/L2BotCore.vcxproj b/L2BotCore/L2BotCore.vcxproj index 54d29fd..a939de2 100644 --- a/L2BotCore/L2BotCore.vcxproj +++ b/L2BotCore/L2BotCore.vcxproj @@ -159,7 +159,9 @@ + + @@ -175,12 +177,30 @@ + + + + + + + + + + + + + + + + + + diff --git a/L2BotCore/L2BotCore.vcxproj.filters b/L2BotCore/L2BotCore.vcxproj.filters index 3fe16e7..a2971ed 100644 --- a/L2BotCore/L2BotCore.vcxproj.filters +++ b/L2BotCore/L2BotCore.vcxproj.filters @@ -165,6 +165,66 @@ Header Files + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + diff --git a/L2BotDll/Application.h b/L2BotDll/Application.h index 502cecd..49d33a0 100644 --- a/L2BotDll/Application.h +++ b/L2BotDll/Application.h @@ -9,8 +9,8 @@ #include "Serializers/JsonIncomingMessageFactory.h" #include "Transports/NamedPipeTransport.h" #include "Versions/VersionAbstractFactory.h" -#include "Services/ServiceLocator.h" -#include "Events/HeroDeletedEvent.h" +#include "Domain/Services/ServiceLocator.h" +#include "Domain/Events/EventDispatcher.h" using namespace L2Bot::Domain; @@ -49,7 +49,7 @@ public: private: void Init() { - ServiceLocator::GetInstance().SetEventDispatcher(std::make_unique()); + Services::ServiceLocator::GetInstance().SetEventDispatcher(std::make_unique()); HMODULE hEngine = GetModuleHandleA("Engine.dll"); HMODULE hCore = GetModuleHandleA("Core.dll"); diff --git a/L2BotDll/DTO/ChatMessage.h b/L2BotDll/DTO/ChatMessage.h deleted file mode 100644 index 3166d03..0000000 --- a/L2BotDll/DTO/ChatMessage.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#include -#include - -struct ChatMessage -{ - const uint32_t objectId = 0; - const uint8_t channel = 0; - const std::wstring name = L""; - const std::wstring text = L""; -}; \ No newline at end of file diff --git a/L2BotDll/DTO/ItemData.h b/L2BotDll/DTO/ItemData.h deleted file mode 100644 index 3d89e46..0000000 --- a/L2BotDll/DTO/ItemData.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include - -struct ItemData -{ - const uint32_t objectId = 0; - const uint32_t itemId = 0; - const uint32_t amount = 0; - const uint16_t isEquipped = 0; - const uint16_t enchantLevel = 0; - const int32_t mana = -1; - const bool isQuest = false; - const bool isTwoHanded = false; -}; \ No newline at end of file diff --git a/L2BotDll/Events/AbnormalEffectChangedEvent.h b/L2BotDll/Events/AbnormalEffectChangedEvent.h deleted file mode 100644 index 6f9b1ab..0000000 --- a/L2BotDll/Events/AbnormalEffectChangedEvent.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include -#include -#include "Event.h" - -class AbnormalEffectChangedEvent : public Event -{ -public: - static constexpr const char* name = "abnormalEffectChanged"; - - const std::string GetName() const - { - return std::string(name); - } - - const std::vector& GetSkillInfo() const - { - return m_SkillInfo; - } - - AbnormalEffectChangedEvent(const std::vector skillInfo) : - m_SkillInfo(skillInfo) - { - - } - - AbnormalEffectChangedEvent() = delete; - virtual ~AbnormalEffectChangedEvent() = default; - -private: - const std::vector m_SkillInfo; -}; \ No newline at end of file diff --git a/L2BotDll/Events/ChatMessageCreatedEvent.h b/L2BotDll/Events/ChatMessageCreatedEvent.h deleted file mode 100644 index 50363af..0000000 --- a/L2BotDll/Events/ChatMessageCreatedEvent.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -#include -#include -#include "Event.h" -#include "../DTO/ChatMessage.h" - -class ChatMessageCreatedEvent : public Event -{ -public: - static constexpr const char* name = "chatMessageCreated"; - - const std::string GetName() const - { - return std::string(name); - } - - const ChatMessage& GetChatMessage() const - { - return m_ChatMessage; - } - - ChatMessageCreatedEvent(const ChatMessage chatMessage) : - m_ChatMessage(chatMessage) - { - - } - - ChatMessageCreatedEvent() = delete; - virtual ~ChatMessageCreatedEvent() = default; - -private: - const ChatMessage m_ChatMessage; -}; \ No newline at end of file diff --git a/L2BotDll/Events/CreatureDiedEvent.h b/L2BotDll/Events/CreatureDiedEvent.h deleted file mode 100644 index f55d6c1..0000000 --- a/L2BotDll/Events/CreatureDiedEvent.h +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once - -#include -#include "Event.h" - -class CreatureDiedEvent : public Event -{ -public: - static constexpr const char* name = "creatureDied"; - - const std::string GetName() const - { - return std::string(name); - } - - const uint32_t GetCreatureId() const - { - return m_CreatureId; - } - - const std::vector& GetCreatureInfo() const - { - return m_CreatureInfo; - } - - CreatureDiedEvent(uint32_t creatureId, const std::vector& creatureInfo) : - m_CreatureId(creatureId), - m_CreatureInfo(creatureInfo) - { - - } - - CreatureDiedEvent() = delete; - virtual ~CreatureDiedEvent() = default; - -private: - const uint32_t m_CreatureId; - const std::vector m_CreatureInfo; -}; \ No newline at end of file diff --git a/L2BotDll/Events/Event.h b/L2BotDll/Events/Event.h deleted file mode 100644 index 1be1f3d..0000000 --- a/L2BotDll/Events/Event.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -#include - -class Event -{ -public: - virtual const std::string GetName() const = 0; - - Event() = default; - virtual ~Event() = default; -}; \ No newline at end of file diff --git a/L2BotDll/Events/EventDispatcher.h b/L2BotDll/Events/EventDispatcher.h deleted file mode 100644 index 04e4645..0000000 --- a/L2BotDll/Events/EventDispatcher.h +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include "Event.h" - -class EventDispatcher -{ -public: - using Delegate = std::function; - - EventDispatcher() = default; - virtual ~EventDispatcher() = default; - - void Dispatch(const Event& evt) - { - const auto& name = evt.GetName(); - - if (m_Handlers.find(name) == m_Handlers.end()) - { - return; - } - - for (const auto& handler : m_Handlers[name]) - { - handler(evt); - } - } - - void Subscribe(const std::string& eventName, const Delegate handler) - { - m_Handlers[eventName].push_back(handler); - } - -private: - std::unordered_map> m_Handlers; -}; \ No newline at end of file diff --git a/L2BotDll/Events/GameEngineTickedEvent.h b/L2BotDll/Events/GameEngineTickedEvent.h deleted file mode 100644 index 2ba1683..0000000 --- a/L2BotDll/Events/GameEngineTickedEvent.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -#include -#include "Event.h" - -class GameEngineTickedEvent : public Event -{ -public: - static constexpr const char* name = "gameEngineTicked"; - - const std::string GetName() const - { - return std::string(name); - } - - GameEngineTickedEvent() = default; - virtual ~GameEngineTickedEvent() = default; -}; \ No newline at end of file diff --git a/L2BotDll/Events/HeroCreatedEvent.h b/L2BotDll/Events/HeroCreatedEvent.h deleted file mode 100644 index 61d34a1..0000000 --- a/L2BotDll/Events/HeroCreatedEvent.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include -#include -#include "Event.h" - -class HeroCreatedEvent : public Event -{ -public: - static constexpr const char* name = "heroCreated"; - - const std::string GetName() const - { - return std::string(name); - } - - HeroCreatedEvent() = default; - virtual ~HeroCreatedEvent() = default; -}; \ No newline at end of file diff --git a/L2BotDll/Events/HeroDeletedEvent.h b/L2BotDll/Events/HeroDeletedEvent.h deleted file mode 100644 index af932bb..0000000 --- a/L2BotDll/Events/HeroDeletedEvent.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include "Event.h" - -class HeroDeletedEvent : public Event -{ -public: - static constexpr const char* name = "heroDeleted"; - - const std::string GetName() const - { - return std::string(name); - } - - HeroDeletedEvent() = default; - virtual ~HeroDeletedEvent() = default; -}; \ No newline at end of file diff --git a/L2BotDll/Events/ItemAutousedEvent.h b/L2BotDll/Events/ItemAutousedEvent.h deleted file mode 100644 index ad044f9..0000000 --- a/L2BotDll/Events/ItemAutousedEvent.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include -#include -#include "Event.h" - -class ItemAutousedEvent : public Event -{ -public: - static constexpr const char* name = "itemAutoused"; - - const std::string GetName() const - { - return std::string(name); - } - - const std::vector& GetAutouseInfo() const - { - return m_AutouseInfo; - } - - ItemAutousedEvent(const std::vector autouseInfo) : - m_AutouseInfo(autouseInfo) - { - - } - - ItemAutousedEvent() = delete; - virtual ~ItemAutousedEvent() = default; - -private: - const std::vector m_AutouseInfo; -}; \ No newline at end of file diff --git a/L2BotDll/Events/ItemCreatedEvent.h b/L2BotDll/Events/ItemCreatedEvent.h deleted file mode 100644 index a089c5c..0000000 --- a/L2BotDll/Events/ItemCreatedEvent.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -#include -#include -#include "Event.h" -#include "../DTO/ItemData.h" - -class ItemCreatedEvent : public Event -{ -public: - static constexpr const char* name = "itemCreated"; - - const std::string GetName() const - { - return std::string(name); - } - - const ItemData& GetItemData() const - { - return m_ItemData; - } - - ItemCreatedEvent(const ItemData itemData) : - m_ItemData(itemData) - { - - } - - ItemCreatedEvent() = delete; - virtual ~ItemCreatedEvent() = default; - -private: - const ItemData m_ItemData; -}; \ No newline at end of file diff --git a/L2BotDll/Events/ItemDeletedEvent.h b/L2BotDll/Events/ItemDeletedEvent.h deleted file mode 100644 index 550e761..0000000 --- a/L2BotDll/Events/ItemDeletedEvent.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -#include -#include -#include "Event.h" -#include "../DTO/ItemData.h" - -class ItemDeletedEvent : public Event -{ -public: - static constexpr const char* name = "itemDeleted"; - - const std::string GetName() const - { - return std::string(name); - } - - const uint32_t GetObjectId() const - { - return m_ObjectId; - } - - ItemDeletedEvent(const uint32_t objectId) : - m_ObjectId(objectId) - { - - } - - ItemDeletedEvent() = delete; - virtual ~ItemDeletedEvent() = default; - -private: - const uint32_t m_ObjectId; -}; \ No newline at end of file diff --git a/L2BotDll/Events/ItemUpdatedEvent.h b/L2BotDll/Events/ItemUpdatedEvent.h deleted file mode 100644 index 508f01a..0000000 --- a/L2BotDll/Events/ItemUpdatedEvent.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -#include -#include -#include "Event.h" -#include "../DTO/ItemData.h" - -class ItemUpdatedEvent : public Event -{ -public: - static constexpr const char* name = "itemUpdated"; - - const std::string GetName() const - { - return std::string(name); - } - - const ItemData& GetItemData() const - { - return m_ItemData; - } - - ItemUpdatedEvent(const ItemData itemData) : - m_ItemData(itemData) - { - - } - - ItemUpdatedEvent() = delete; - virtual ~ItemUpdatedEvent() = default; - -private: - const ItemData m_ItemData; -}; \ No newline at end of file diff --git a/L2BotDll/Events/OnEndItemListEvent.h b/L2BotDll/Events/OnEndItemListEvent.h deleted file mode 100644 index 8789677..0000000 --- a/L2BotDll/Events/OnEndItemListEvent.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include "Event.h" - -class OnEndItemListEvent : public Event -{ -public: - static constexpr const char* name = "onEndItemList"; - - const std::string GetName() const - { - return std::string(name); - } - - OnEndItemListEvent() = default; - virtual ~OnEndItemListEvent() = default; -}; \ No newline at end of file diff --git a/L2BotDll/Events/SkillCancelledEvent.h b/L2BotDll/Events/SkillCancelledEvent.h deleted file mode 100644 index 33954f9..0000000 --- a/L2BotDll/Events/SkillCancelledEvent.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once - -#include -#include "Event.h" - -class SkillCancelledEvent : public Event -{ -public: - static constexpr const char* name = "skillCancelled"; - - const std::string GetName() const - { - return std::string(name); - } - - const uint32_t GetInitiatorId() const - { - return m_InitiatorId; - } - - SkillCancelledEvent(const uint32_t initiatorId) : - m_InitiatorId(initiatorId) - { - - } - - SkillCancelledEvent() = delete; - virtual ~SkillCancelledEvent() = default; - -private: - const uint32_t m_InitiatorId; -}; \ No newline at end of file diff --git a/L2BotDll/Events/SkillCreatedEvent.h b/L2BotDll/Events/SkillCreatedEvent.h deleted file mode 100644 index aff3967..0000000 --- a/L2BotDll/Events/SkillCreatedEvent.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include -#include -#include "Event.h" - -class SkillCreatedEvent : public Event -{ -public: - static constexpr const char* name = "skillCreated"; - - const std::string GetName() const - { - return std::string(name); - } - - const std::vector& GetSkillInfo() const - { - return m_SkillInfo; - } - - SkillCreatedEvent(const std::vector skillInfo) : - m_SkillInfo(skillInfo) - { - - } - - SkillCreatedEvent() = delete; - virtual ~SkillCreatedEvent() = default; - -private: - const std::vector m_SkillInfo; -}; \ No newline at end of file diff --git a/L2BotDll/Events/SkillUsedEvent.h b/L2BotDll/Events/SkillUsedEvent.h deleted file mode 100644 index 508cfbf..0000000 --- a/L2BotDll/Events/SkillUsedEvent.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include -#include -#include "Event.h" - -class SkillUsedEvent : public Event -{ -public: - static constexpr const char* name = "skillUsed"; - - const std::string GetName() const - { - return std::string(name); - } - - const std::vector& GetSkillInfo() const - { - return m_SkillInfo; - } - - SkillUsedEvent(const std::vector skillInfo) : - m_SkillInfo(skillInfo) - { - - } - - SkillUsedEvent() = delete; - virtual ~SkillUsedEvent() = default; - -private: - const std::vector m_SkillInfo; -}; \ No newline at end of file diff --git a/L2BotDll/Events/SpoiledEvent.h b/L2BotDll/Events/SpoiledEvent.h deleted file mode 100644 index 0399ecc..0000000 --- a/L2BotDll/Events/SpoiledEvent.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -#include -#include "Event.h" - -class SpoiledEvent : public Event -{ -public: - static constexpr const char* name = "spoiled"; - - const std::string GetName() const - { - return std::string(name); - } - - SpoiledEvent() = default; - virtual ~SpoiledEvent() = default; -}; \ No newline at end of file diff --git a/L2BotDll/L2BotDll.vcxproj b/L2BotDll/L2BotDll.vcxproj index 7a4918b..bab5615 100644 --- a/L2BotDll/L2BotDll.vcxproj +++ b/L2BotDll/L2BotDll.vcxproj @@ -164,29 +164,9 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/L2BotDll/L2BotDll.vcxproj.filters b/L2BotDll/L2BotDll.vcxproj.filters index ac49ea5..aa19f89 100644 --- a/L2BotDll/L2BotDll.vcxproj.filters +++ b/L2BotDll/L2BotDll.vcxproj.filters @@ -60,18 +60,6 @@ Header Files - - Header Files - - - Header Files - - - Header Files - - - Header Files - Header Files @@ -99,27 +87,9 @@ Header Files - - Header Files - - - Header Files - - - Header Files - Header Files - - Header Files - - - Header Files - - - Header Files - Header Files @@ -153,48 +123,21 @@ Header Files - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - Header Files Header Files - - Header Files - Header Files - - Header Files - - - Header Files - Header Files Header Files - - Header Files - Header Files @@ -204,9 +147,6 @@ Header Files - - Header Files - diff --git a/L2BotDll/Services/ServiceLocator.h b/L2BotDll/Services/ServiceLocator.h deleted file mode 100644 index 77e2ca8..0000000 --- a/L2BotDll/Services/ServiceLocator.h +++ /dev/null @@ -1,30 +0,0 @@ -#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/Factories/ChatMessageFactory.h b/L2BotDll/Versions/Interlude/Factories/ChatMessageFactory.h index 091009e..f94e989 100644 --- a/L2BotDll/Versions/Interlude/Factories/ChatMessageFactory.h +++ b/L2BotDll/Versions/Interlude/Factories/ChatMessageFactory.h @@ -1,7 +1,7 @@ #pragma once #include "Domain/Entities/ChatMessage.h" -#include "../../../DTO/ChatMessage.h" +#include "Domain/DTO/ChatMessageData.h" using namespace L2Bot::Domain; @@ -13,7 +13,7 @@ namespace Interlude ChatMessageFactory() = default; virtual ~ChatMessageFactory() = default; - std::shared_ptr Create(const ChatMessage& message) const + std::shared_ptr Create(const DTO::ChatMessageData& message) const { return std::make_shared( message.objectId, diff --git a/L2BotDll/Versions/Interlude/Factories/ItemFactory.h b/L2BotDll/Versions/Interlude/Factories/ItemFactory.h index e34cca2..2b27f40 100644 --- a/L2BotDll/Versions/Interlude/Factories/ItemFactory.h +++ b/L2BotDll/Versions/Interlude/Factories/ItemFactory.h @@ -10,7 +10,7 @@ #include "Domain/Entities/ArmorItem.h" #include "Domain/Entities/WeaponItem.h" #include "Domain/Entities/ShieldItem.h" -#include "../../../DTO/ItemData.h" +#include "Domain/DTO/ItemData.h" #include "../Helpers/EnchantHelper.h" using namespace L2Bot::Domain; @@ -88,7 +88,7 @@ namespace Interlude ItemFactory() = delete; virtual ~ItemFactory() = default; - std::shared_ptr Create(const ItemData& itemInfo) const + std::shared_ptr Create(const DTO::ItemData& itemInfo) const { //FIXME during first start data may be undefined const auto data = GetItemData(itemInfo.itemId); @@ -109,7 +109,7 @@ namespace Interlude return nullptr; } - void Update(std::shared_ptr& item, const ItemData& itemInfo) const + void Update(std::shared_ptr& item, const DTO::ItemData& itemInfo) const { //FIXME during first start data may be undefined const auto data = GetItemData(itemInfo.itemId); @@ -131,7 +131,7 @@ namespace Interlude } private: - std::shared_ptr CreateEtc(const ItemData& itemInfo) const + std::shared_ptr CreateEtc(const DTO::ItemData& itemInfo) const { const auto& data = GetEtcData(itemInfo); @@ -148,7 +148,7 @@ namespace Interlude ); } - void UpdateEtc(std::shared_ptr &item, const ItemData& itemInfo) const + void UpdateEtc(std::shared_ptr &item, const DTO::ItemData& itemInfo) const { auto etcItem = std::dynamic_pointer_cast(item); @@ -166,7 +166,7 @@ namespace Interlude ); } - std::shared_ptr CreateArmor(const ItemData& itemInfo) const + std::shared_ptr CreateArmor(const DTO::ItemData& itemInfo) const { const auto& data = GetArmorData(itemInfo); @@ -190,7 +190,7 @@ namespace Interlude ); } - void UpdateArmor(std::shared_ptr& item, const ItemData& itemInfo) const + void UpdateArmor(std::shared_ptr& item, const DTO::ItemData& itemInfo) const { auto armorItem = std::dynamic_pointer_cast(item); @@ -215,7 +215,7 @@ namespace Interlude ); } - std::shared_ptr CreateWeaponOrShield(const ItemData& itemInfo) const + std::shared_ptr CreateWeaponOrShield(const DTO::ItemData& itemInfo) const { const auto itemData = static_cast(GetItemData(itemInfo.itemId)); @@ -266,7 +266,7 @@ namespace Interlude ); } - void UpdateWeaponOrShield(std::shared_ptr& item, const ItemData& itemInfo) const + void UpdateWeaponOrShield(std::shared_ptr& item, const DTO::ItemData& itemInfo) const { const auto itemData = static_cast(GetItemData(itemInfo.itemId)); @@ -319,7 +319,7 @@ namespace Interlude ); } - const BaseData GetBaseData(const ItemData& itemInfo) const + const BaseData GetBaseData(const DTO::ItemData& itemInfo) const { const auto data = GetItemData(itemInfo.itemId); @@ -340,7 +340,7 @@ namespace Interlude }; } - const EtcData GetEtcData(const ItemData& itemInfo) const + const EtcData GetEtcData(const DTO::ItemData& itemInfo) const { const auto& baseData = GetBaseData(itemInfo); @@ -357,7 +357,7 @@ namespace Interlude }; } - const ArmorData GetArmorData(const ItemData& itemInfo) const + const ArmorData GetArmorData(const DTO::ItemData& itemInfo) const { const auto& baseData = GetBaseData(itemInfo); @@ -387,7 +387,7 @@ namespace Interlude }; } - const ShieldData GetShieldData(const ItemData& itemInfo, const FL2WeaponItemData* itemData) const + const ShieldData GetShieldData(const DTO::ItemData& itemInfo, const FL2WeaponItemData* itemData) const { const auto& baseData = GetBaseData(itemInfo); @@ -408,7 +408,7 @@ namespace Interlude }; } - const WeaponData GetWeaponData(const ItemData& itemInfo, const FL2WeaponItemData* itemData) const + const WeaponData GetWeaponData(const DTO::ItemData& itemInfo, const FL2WeaponItemData* itemData) const { const auto& baseData = GetBaseData(itemInfo); diff --git a/L2BotDll/Versions/Interlude/GameStructs/GameEngineWrapper.cpp b/L2BotDll/Versions/Interlude/GameStructs/GameEngineWrapper.cpp index 69e1add..a47b6a6 100644 --- a/L2BotDll/Versions/Interlude/GameStructs/GameEngineWrapper.cpp +++ b/L2BotDll/Versions/Interlude/GameStructs/GameEngineWrapper.cpp @@ -3,21 +3,24 @@ #include "../../../Common/Common.h" #include "GameEngineWrapper.h" #include "ProcessManipulation.h" -#include "../../../Events/SkillCreatedEvent.h" -#include "../../../Events/SkillUsedEvent.h" -#include "../../../Events/SkillCancelledEvent.h" -#include "../../../Events/AbnormalEffectChangedEvent.h" -#include "../../../Events/ItemCreatedEvent.h" -#include "../../../Events/ItemUpdatedEvent.h" -#include "../../../Events/ItemDeletedEvent.h" -#include "../../../Events/ItemAutousedEvent.h" -#include "../../../Events/GameEngineTickedEvent.h" -#include "../../../Events/ChatMessageCreatedEvent.h" -#include "../../../Events/OnEndItemListEvent.h" -#include "../../../Events/CreatureDiedEvent.h" -#include "../../../DTO/ItemData.h" +#include "Domain/Events/SkillCreatedEvent.h" +#include "Domain/Events/SkillUsedEvent.h" +#include "Domain/Events/SkillCancelledEvent.h" +#include "Domain/Events/AbnormalEffectChangedEvent.h" +#include "Domain/Events/ItemCreatedEvent.h" +#include "Domain/Events/ItemUpdatedEvent.h" +#include "Domain/Events/ItemDeletedEvent.h" +#include "Domain/Events/ItemAutousedEvent.h" +#include "Domain/Events/GameEngineTickedEvent.h" +#include "Domain/Events/ChatMessageCreatedEvent.h" +#include "Domain/Events/OnEndItemListEvent.h" +#include "Domain/Events/CreatureDiedEvent.h" +#include "Domain/DTO/ItemData.h" +#include "Domain/DTO/ChatMessageData.h" #include "FName.h" -#include "../../../Services/ServiceLocator.h" +#include "Domain/Services/ServiceLocator.h" + +using namespace L2Bot::Domain; namespace Interlude { @@ -94,34 +97,34 @@ namespace Interlude void __fastcall GameEngineWrapper::__OnSkillListPacket_hook(GameEngine* This, uint32_t, L2ParamStack& stack) { - ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(SkillCreatedEvent{stack.GetBufferAsVector()}); + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(Events::SkillCreatedEvent{stack.GetBufferAsVector()}); (*__OnSkillListPacket)(This, stack); } int __fastcall GameEngineWrapper::__OnReceiveMagicSkillUse_hook(GameEngine* This, uint32_t, User* u1, User* u2, L2ParamStack& stack) { - ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(SkillUsedEvent{ stack.GetBufferAsVector() }); + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(Events::SkillUsedEvent{ stack.GetBufferAsVector() }); return (*__OnReceiveMagicSkillUse)(This, u1, u2, stack); } void __fastcall GameEngineWrapper::__OnReceiveMagicSkillCanceled_hook(GameEngine* This, uint32_t, User* user) { - ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(SkillCancelledEvent{ user->objectId }); + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(Events::SkillCancelledEvent{ user->objectId }); (*__OnReceiveMagicSkillCanceled)(This, user); } void __fastcall GameEngineWrapper::__AddAbnormalStatus_hook(GameEngine* This, uint32_t, L2ParamStack& stack) { - ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(AbnormalEffectChangedEvent{ stack.GetBufferAsVector(3) }); + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(Events::AbnormalEffectChangedEvent{ stack.GetBufferAsVector(3) }); (*__AddAbnormalStatus)(This, stack); } void __fastcall GameEngineWrapper::__AddInventoryItem_hook(GameEngine* This, uint32_t, ItemInfo& itemInfo) { - ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch( - ItemCreatedEvent + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch( + Events::ItemCreatedEvent { - ItemData + DTO::ItemData { itemInfo.objectId, itemInfo.itemId, @@ -139,7 +142,7 @@ namespace Interlude void __fastcall GameEngineWrapper::__OnReceiveUpdateItemList_hook(GameEngine* This, uint32_t, UpdateItemListActionType actionType, ItemInfo& itemInfo) { - const ItemData itemData + const DTO::ItemData itemData { itemInfo.objectId, itemInfo.itemId, @@ -154,13 +157,13 @@ namespace Interlude switch (actionType) { case UpdateItemListActionType::created: - ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(ItemCreatedEvent{ itemData }); + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(Events::ItemCreatedEvent{ itemData }); break; case UpdateItemListActionType::updated: - ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(ItemUpdatedEvent{ itemData }); + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(Events::ItemUpdatedEvent{ itemData }); break; case UpdateItemListActionType::deleted: - ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(ItemDeletedEvent{ itemInfo.objectId }); + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(Events::ItemDeletedEvent{ itemInfo.objectId }); break; } (*__OnReceiveUpdateItemList)(This, actionType, itemInfo); @@ -168,7 +171,7 @@ namespace Interlude void __fastcall GameEngineWrapper::__OnExAutoSoulShot_hook(GameEngine* This, uint32_t, L2ParamStack& stack) { - ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(ItemAutousedEvent{ stack.GetBufferAsVector() }); + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(Events::ItemAutousedEvent{ stack.GetBufferAsVector() }); (*__OnExAutoSoulShot)(This, stack); } @@ -181,16 +184,16 @@ namespace Interlude (*__Tick)(This, deltaTime); - ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(GameEngineTickedEvent{}); + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(Events::GameEngineTickedEvent{}); } void __fastcall GameEngineWrapper::__OnSay2_hook(GameEngine* This, uint32_t, L2ParamStack& stack) { const auto buffer = stack.GetBufferAsVector(); - ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch( - ChatMessageCreatedEvent + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch( + Events::ChatMessageCreatedEvent { - ChatMessage + DTO::ChatMessageData { buffer[0], static_cast(buffer[1]), @@ -204,7 +207,7 @@ namespace Interlude } void __fastcall GameEngineWrapper::__OnEndItemList_hook(GameEngine* This, uint32_t) { - ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(OnEndItemListEvent()); + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(Events::OnEndItemListEvent()); (*__OnEndItemList)(This); } // TODO ini @@ -217,7 +220,7 @@ namespace Interlude int __fastcall GameEngineWrapper::__OnDie_hook(GameEngine* This, int, User* creature, L2ParamStack& stack) { - ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(CreatureDiedEvent{ creature->objectId, stack.GetBufferAsVector() }); + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(Events::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 5e03b4f..5d5bbb6 100644 --- a/L2BotDll/Versions/Interlude/GameStructs/NetworkHandlerWrapper.cpp +++ b/L2BotDll/Versions/Interlude/GameStructs/NetworkHandlerWrapper.cpp @@ -1,9 +1,11 @@ #include "pch.h" #include "../../../Common/apihook.h" #include "NetworkHandlerWrapper.h" -#include "../../../Events/SpoiledEvent.h" +#include "Domain/Events/SpoiledEvent.h" #include "ProcessManipulation.h" -#include "../../../Services/ServiceLocator.h" +#include "Domain/Services/ServiceLocator.h" + +using namespace L2Bot::Domain; namespace Interlude { @@ -176,7 +178,7 @@ namespace Interlude p->GetMessageId() == static_cast(L2::SystemMessagePacket::Type::SPOIL_SUCCESS) || p->GetMessageId() == static_cast(L2::SystemMessagePacket::Type::ALREADY_SPOILED) ) { - ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(SpoiledEvent{}); + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(Events::SpoiledEvent{}); } } diff --git a/L2BotDll/Versions/Interlude/Repositories/AbnormalEffectRepository.h b/L2BotDll/Versions/Interlude/Repositories/AbnormalEffectRepository.h index 9774323..0d1c574 100644 --- a/L2BotDll/Versions/Interlude/Repositories/AbnormalEffectRepository.h +++ b/L2BotDll/Versions/Interlude/Repositories/AbnormalEffectRepository.h @@ -5,10 +5,10 @@ #include #include "Domain/Repositories/EntityRepositoryInterface.h" #include "../Factories/AbnormalEffectFactory.h" -#include "../../../Events/AbnormalEffectChangedEvent.h" -#include "../../../Events/HeroDeletedEvent.h" +#include "Domain/Events/AbnormalEffectChangedEvent.h" +#include "Domain/Events/HeroDeletedEvent.h" #include "../GameStructs/NetworkHandlerWrapper.h" -#include "../../../Services/ServiceLocator.h" +#include "Domain/Services/ServiceLocator.h" using namespace L2Bot::Domain; @@ -37,10 +37,10 @@ namespace Interlude void Init() override { - ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(AbnormalEffectChangedEvent::name, [this](const Event& evt) { + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(Events::AbnormalEffectChangedEvent::name, [this](const Events::Event& evt) { OnEffectToggled(evt); }); - ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(HeroDeletedEvent::name, [this](const Event& evt) { + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(Events::HeroDeletedEvent::name, [this](const Events::Event& evt) { OnHeroDeleted(evt); }); } @@ -51,21 +51,21 @@ namespace Interlude m_Effects.clear(); } - void OnHeroDeleted(const Event& evt) + void OnHeroDeleted(const Events::Event& evt) { std::shared_lock(m_Mutex); - if (evt.GetName() == HeroDeletedEvent::name) + if (evt.GetName() == Events::HeroDeletedEvent::name) { Reset(); } } - void OnEffectToggled(const Event& evt) + void OnEffectToggled(const Events::Event& evt) { std::shared_lock(m_Mutex); - if (evt.GetName() == AbnormalEffectChangedEvent::name) + if (evt.GetName() == Events::AbnormalEffectChangedEvent::name) { - const auto casted = static_cast(evt); + const auto casted = static_cast(evt); const auto &actualIds = Create(casted.GetSkillInfo()); Delete(actualIds); diff --git a/L2BotDll/Versions/Interlude/Repositories/ChatMessageRepository.h b/L2BotDll/Versions/Interlude/Repositories/ChatMessageRepository.h index 7f0f3d4..e7ae464 100644 --- a/L2BotDll/Versions/Interlude/Repositories/ChatMessageRepository.h +++ b/L2BotDll/Versions/Interlude/Repositories/ChatMessageRepository.h @@ -3,8 +3,8 @@ #include #include #include "../Factories/ChatMessageFactory.h" -#include "../../../Events/ChatMessageCreatedEvent.h" -#include "../../../Services/ServiceLocator.h" +#include "Domain/Events/ChatMessageCreatedEvent.h" +#include "Domain/Services/ServiceLocator.h" using namespace L2Bot::Domain; @@ -28,7 +28,7 @@ namespace Interlude void Init() override { - ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(ChatMessageCreatedEvent::name, [this](const Event& evt) { + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(Events::ChatMessageCreatedEvent::name, [this](const Events::Event& evt) { OnMessageCreated(evt); }); } @@ -38,12 +38,12 @@ namespace Interlude { } - void OnMessageCreated(const Event& evt) + void OnMessageCreated(const Events::Event& evt) { std::shared_lock(m_Mutex); - if (evt.GetName() == ChatMessageCreatedEvent::name) + if (evt.GetName() == Events::ChatMessageCreatedEvent::name) { - const auto casted = static_cast(evt); + const auto casted = static_cast(evt); const auto message = m_Factory.Create(casted.GetChatMessage()); m_Messages[message->GetId()] = message; diff --git a/L2BotDll/Versions/Interlude/Repositories/HeroRepository.h b/L2BotDll/Versions/Interlude/Repositories/HeroRepository.h index c640544..eb06607 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/HeroCreatedEvent.h" -#include "../../../Events/HeroDeletedEvent.h" +#include "Domain/Events/HeroCreatedEvent.h" +#include "Domain/Events/HeroDeletedEvent.h" #include "../GameStructs/NetworkHandlerWrapper.h" -#include "../../../Services/ServiceLocator.h" +#include "Domain/Services/ServiceLocator.h" using namespace L2Bot::Domain; @@ -25,7 +25,7 @@ namespace Interlude if (hero) { if (!m_Hero) { m_Hero = m_Factory.Create(hero); - ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(HeroCreatedEvent{}); + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(Events::HeroCreatedEvent{}); } else { @@ -35,7 +35,7 @@ namespace Interlude } else if (m_Hero) { m_Hero = nullptr; - ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(HeroDeletedEvent{}); + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Dispatch(Events::HeroDeletedEvent{}); } return result; diff --git a/L2BotDll/Versions/Interlude/Repositories/ItemRepository.h b/L2BotDll/Versions/Interlude/Repositories/ItemRepository.h index 9c528d2..7fd1885 100644 --- a/L2BotDll/Versions/Interlude/Repositories/ItemRepository.h +++ b/L2BotDll/Versions/Interlude/Repositories/ItemRepository.h @@ -6,13 +6,13 @@ #include "Domain/Repositories/EntityRepositoryInterface.h" #include "../Factories/ItemFactory.h" #include "../GameStructs/NetworkHandlerWrapper.h" -#include "../../../Events/ItemCreatedEvent.h" -#include "../../../Events/ItemUpdatedEvent.h" -#include "../../../Events/ItemDeletedEvent.h" -#include "../../../Events/HeroDeletedEvent.h" -#include "../../../Events/ItemAutousedEvent.h" -#include "../../../Events/OnEndItemListEvent.h" -#include "../../../Services/ServiceLocator.h" +#include "Domain/Events/ItemCreatedEvent.h" +#include "Domain/Events/ItemUpdatedEvent.h" +#include "Domain/Events/ItemDeletedEvent.h" +#include "Domain/Events/HeroDeletedEvent.h" +#include "Domain/Events/ItemAutousedEvent.h" +#include "Domain/Events/OnEndItemListEvent.h" +#include "Domain/Services/ServiceLocator.h" using namespace L2Bot::Domain; @@ -46,10 +46,10 @@ namespace Interlude { } - void OnEndItemList(const Event& evt) + void OnEndItemList(const Events::Event& evt) { std::shared_lock(m_Mutex); - if (evt.GetName() == OnEndItemListEvent::name) + if (evt.GetName() == Events::OnEndItemListEvent::name) { for (auto it = m_Items.begin(); it != m_Items.end();) { @@ -67,21 +67,21 @@ namespace Interlude } } - void OnHeroDeleted(const Event& evt) + void OnHeroDeleted(const Events::Event& evt) { std::shared_lock(m_Mutex); - if (evt.GetName() == HeroDeletedEvent::name) + if (evt.GetName() == Events::HeroDeletedEvent::name) { Reset(); } } - void OnItemAutoused(const Event& evt) + void OnItemAutoused(const Events::Event& evt) { std::shared_lock(m_Mutex); - if (evt.GetName() == ItemAutousedEvent::name) + if (evt.GetName() == Events::ItemAutousedEvent::name) { - const auto casted = static_cast(evt); + const auto casted = static_cast(evt); const auto& data = casted.GetAutouseInfo(); const auto itemId = data[0]; @@ -104,10 +104,10 @@ namespace Interlude } } - void OnItemCreated(const Event& evt) + void OnItemCreated(const Events::Event& evt) { std::shared_lock(m_Mutex); - if (evt.GetName() == ItemCreatedEvent::name) + if (evt.GetName() == Events::ItemCreatedEvent::name) { if (m_IsNewCycle) { @@ -115,7 +115,7 @@ namespace Interlude m_NewItems.clear(); } - const auto casted = static_cast(evt); + const auto casted = static_cast(evt); const auto& data = casted.GetItemData(); @@ -135,12 +135,12 @@ namespace Interlude } } - void OnItemUpdated(const Event& evt) + void OnItemUpdated(const Events::Event& evt) { std::shared_lock(m_Mutex); - if (evt.GetName() == ItemUpdatedEvent::name) + if (evt.GetName() == Events::ItemUpdatedEvent::name) { - const auto casted = static_cast(evt); + const auto casted = static_cast(evt); const auto& data = casted.GetItemData(); //todo exception? @@ -153,13 +153,13 @@ namespace Interlude } } - void OnItemDeleted(const Event& evt) + void OnItemDeleted(const Events::Event& evt) { //fixme may be a race condition std::shared_lock(m_Mutex); - if (evt.GetName() == ItemDeletedEvent::name) + if (evt.GetName() == Events::ItemDeletedEvent::name) { - const auto casted = static_cast(evt); + const auto casted = static_cast(evt); m_Items.erase(casted.GetObjectId()); } @@ -182,22 +182,22 @@ namespace Interlude void Init() override { - ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(ItemCreatedEvent::name, [this](const Event& evt) { + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(Events::ItemCreatedEvent::name, [this](const Events::Event& evt) { OnItemCreated(evt); }); - ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(ItemUpdatedEvent::name, [this](const Event& evt) { + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(Events::ItemUpdatedEvent::name, [this](const Events::Event& evt) { OnItemUpdated(evt); }); - ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(ItemDeletedEvent::name, [this](const Event& evt) { + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(Events::ItemDeletedEvent::name, [this](const Events::Event& evt) { OnItemDeleted(evt); }); - ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(HeroDeletedEvent::name, [this](const Event& evt) { + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(Events::HeroDeletedEvent::name, [this](const Events::Event& evt) { OnHeroDeleted(evt); }); - ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(ItemAutousedEvent::name, [this](const Event& evt) { + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(Events::ItemAutousedEvent::name, [this](const Events::Event& evt) { OnItemAutoused(evt); }); - ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(OnEndItemListEvent::name, [this](const Event& evt) { + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(Events::OnEndItemListEvent::name, [this](const Events::Event& evt) { OnEndItemList(evt); }); } diff --git a/L2BotDll/Versions/Interlude/Repositories/NPCRepository.h b/L2BotDll/Versions/Interlude/Repositories/NPCRepository.h index 14053a6..5aaf6d7 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/SpoiledEvent.h" -#include "../../../Events/CreatureDiedEvent.h" +#include "Domain/Events/SpoiledEvent.h" +#include "Domain/Events/CreatureDiedEvent.h" #include "../../GameStructs/FindObjectsTrait.h" -#include "../../../Services/ServiceLocator.h" +#include "Domain/Services/ServiceLocator.h" using namespace L2Bot::Domain; @@ -57,10 +57,10 @@ namespace Interlude void Init() override { - ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(SpoiledEvent::name, [this](const Event& evt) { + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(Events::SpoiledEvent::name, [this](const Events::Event& evt) { OnSpoiled(evt); }); - ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(CreatureDiedEvent::name, [this](const Event& evt) { + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(Events::CreatureDiedEvent::name, [this](const Events::Event& evt) { OnCreatureDied(evt); }); } @@ -75,12 +75,12 @@ namespace Interlude NPCRepository() = delete; virtual ~NPCRepository() = default; - void OnSpoiled(const Event& evt) + void OnSpoiled(const Events::Event& evt) { std::shared_lock(m_Mutex); - if (evt.GetName() == SpoiledEvent::name) + if (evt.GetName() == Events::SpoiledEvent::name) { - const auto casted = static_cast(evt); + const auto casted = static_cast(evt); const auto hero = m_NetworkHandler.GetHero(); if (hero && hero->pawn && hero->pawn->lineagePlayerController) { @@ -93,12 +93,12 @@ namespace Interlude } } - void OnCreatureDied(const Event& evt) + void OnCreatureDied(const Events::Event& evt) { std::shared_lock(m_Mutex); - if (evt.GetName() == CreatureDiedEvent::name) + if (evt.GetName() == Events::CreatureDiedEvent::name) { - const auto casted = static_cast(evt); + const auto casted = static_cast(evt); if (m_Spoiled.find(casted.GetCreatureId()) != m_Spoiled.end()) { const auto isSweepable = casted.GetCreatureInfo()[4] != 0; diff --git a/L2BotDll/Versions/Interlude/Repositories/SkillRepository.h b/L2BotDll/Versions/Interlude/Repositories/SkillRepository.h index a17de1c..0bea167 100644 --- a/L2BotDll/Versions/Interlude/Repositories/SkillRepository.h +++ b/L2BotDll/Versions/Interlude/Repositories/SkillRepository.h @@ -5,15 +5,15 @@ #include #include "Domain/Repositories/EntityRepositoryInterface.h" #include "../Factories/SkillFactory.h" -#include "../../../Events/SkillCreatedEvent.h" -#include "../../../Events/SkillUsedEvent.h" -#include "../../../Events/SkillCancelledEvent.h" -#include "../../../Events/AbnormalEffectChangedEvent.h" -#include "../../../Events/HeroDeletedEvent.h" -#include "../../../Events/GameEngineTickedEvent.h" +#include "Domain/Events/SkillCreatedEvent.h" +#include "Domain/Events/SkillUsedEvent.h" +#include "Domain/Events/SkillCancelledEvent.h" +#include "Domain/Events/AbnormalEffectChangedEvent.h" +#include "Domain/Events/HeroDeletedEvent.h" +#include "Domain/Events/GameEngineTickedEvent.h" #include "../GameStructs/NetworkHandlerWrapper.h" #include "../../../Common/TimerMap.h" -#include "../../../Services/ServiceLocator.h" +#include "Domain/Services/ServiceLocator.h" using namespace L2Bot::Domain; @@ -53,30 +53,30 @@ namespace Interlude void Init() override { - ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(SkillCreatedEvent::name, [this](const Event& evt) { + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(Events::SkillCreatedEvent::name, [this](const Events::Event& evt) { OnSkillCreated(evt); }); - ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(SkillUsedEvent::name, [this](const Event& evt) { + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(Events::SkillUsedEvent::name, [this](const Events::Event& evt) { OnSkillUsed(evt); }); - ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(SkillCancelledEvent::name, [this](const Event& evt) { + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(Events::SkillCancelledEvent::name, [this](const Events::Event& evt) { OnSkillCancelled(evt); }); - ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(AbnormalEffectChangedEvent::name, [this](const Event& evt) { + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(Events::AbnormalEffectChangedEvent::name, [this](const Events::Event& evt) { OnSkillToggled(evt); }); - ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(HeroDeletedEvent::name, [this](const Event& evt) { + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(Events::HeroDeletedEvent::name, [this](const Events::Event& evt) { OnHeroDeleted(evt); }); - ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(GameEngineTickedEvent::name, [this](const Event& evt) { + Services::ServiceLocator::GetInstance().GetEventDispatcher()->Subscribe(Events::GameEngineTickedEvent::name, [this](const Events::Event& evt) { OnGameEngineTicked(evt); }); } - void OnGameEngineTicked(const Event& evt) + void OnGameEngineTicked(const Events::Event& evt) { std::shared_lock(m_Mutex); - if (evt.GetName() == GameEngineTickedEvent::name) + if (evt.GetName() == Events::GameEngineTickedEvent::name) { for (auto it = m_Skills.begin(); it != m_Skills.end();) { @@ -94,10 +94,10 @@ namespace Interlude } } - void OnHeroDeleted(const Event& evt) + void OnHeroDeleted(const Events::Event& evt) { std::shared_lock(m_Mutex); - if (evt.GetName() == HeroDeletedEvent::name) + if (evt.GetName() == Events::HeroDeletedEvent::name) { Reset(); m_CastingTimers.StopAll(); @@ -106,10 +106,10 @@ namespace Interlude } //todo need to delete skills if they are not exists in create "queue" - void OnSkillCreated(const Event& evt) + void OnSkillCreated(const Events::Event& evt) { std::shared_lock(m_Mutex); - if (evt.GetName() == SkillCreatedEvent::name) + if (evt.GetName() == Events::SkillCreatedEvent::name) { if (m_IsNewCycle) { @@ -117,7 +117,7 @@ namespace Interlude m_NewSkills.clear(); } - const auto casted = static_cast(evt); + const auto casted = static_cast(evt); const auto skillInfo = casted.GetSkillInfo(); const auto skillId = skillInfo[2]; @@ -142,12 +142,12 @@ namespace Interlude m_NewSkills[skillId] = skillId; } } - void OnSkillUsed(const Event& evt) + void OnSkillUsed(const Events::Event& evt) { std::shared_lock(m_Mutex); - if (evt.GetName() == SkillUsedEvent::name) + if (evt.GetName() == Events::SkillUsedEvent::name) { - const auto casted = static_cast(evt); + const auto casted = static_cast(evt); const auto skillInfo = casted.GetSkillInfo(); const auto skillId = skillInfo[0]; @@ -174,12 +174,12 @@ namespace Interlude }); } } - void OnSkillCancelled(const Event& evt) + void OnSkillCancelled(const Events::Event& evt) { std::shared_lock(m_Mutex); - if (evt.GetName() == SkillCancelledEvent::name) + if (evt.GetName() == Events::SkillCancelledEvent::name) { - const auto casted = static_cast(evt); + const auto casted = static_cast(evt); const auto hero = m_NetworkHandler.GetHero(); @@ -198,12 +198,12 @@ namespace Interlude } } } - void OnSkillToggled(const Event& evt) + void OnSkillToggled(const Events::Event& evt) { std::shared_lock(m_Mutex); - if (evt.GetName() == AbnormalEffectChangedEvent::name) + if (evt.GetName() == Events::AbnormalEffectChangedEvent::name) { - const auto casted = static_cast(evt); + const auto casted = static_cast(evt); const auto skillInfo = casted.GetSkillInfo(); std::unordered_map ids;