Add project files.
This commit is contained in:
33
L2BotDll/Events/AbnormalEffectChangedEvent.h
Normal file
33
L2BotDll/Events/AbnormalEffectChangedEvent.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
#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<int32_t> GetSkillInfo() const
|
||||
{
|
||||
return m_SkillInfo;
|
||||
}
|
||||
|
||||
AbnormalEffectChangedEvent(const std::vector<int32_t> skillInfo) :
|
||||
m_SkillInfo(skillInfo)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
AbnormalEffectChangedEvent() = delete;
|
||||
virtual ~AbnormalEffectChangedEvent() = default;
|
||||
|
||||
private:
|
||||
const std::vector<int32_t> m_SkillInfo;
|
||||
};
|
32
L2BotDll/Events/CreatureDiedEvent.h
Normal file
32
L2BotDll/Events/CreatureDiedEvent.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#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;
|
||||
}
|
||||
|
||||
CreatureDiedEvent(uint32_t creatureId) :
|
||||
m_CreatureId(creatureId)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CreatureDiedEvent() = delete;
|
||||
virtual ~CreatureDiedEvent() = default;
|
||||
|
||||
private:
|
||||
const uint32_t m_CreatureId;
|
||||
};
|
12
L2BotDll/Events/Event.h
Normal file
12
L2BotDll/Events/Event.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
class Event
|
||||
{
|
||||
public:
|
||||
virtual const std::string GetName() const = 0;
|
||||
|
||||
Event() = default;
|
||||
virtual ~Event() = default;
|
||||
};
|
47
L2BotDll/Events/EventDispatcher.h
Normal file
47
L2BotDll/Events/EventDispatcher.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include "Event.h"
|
||||
|
||||
class EventDispatcher
|
||||
{
|
||||
public:
|
||||
using Delegate = std::function<void(const Event&)>;
|
||||
|
||||
static EventDispatcher& GetInstance() {
|
||||
static EventDispatcher instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
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(std::string eventName, Delegate handler)
|
||||
{
|
||||
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<std::string, std::vector<Delegate>> m_Handlers;
|
||||
};
|
19
L2BotDll/Events/HeroCreatedEvent.h
Normal file
19
L2BotDll/Events/HeroCreatedEvent.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
#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;
|
||||
};
|
17
L2BotDll/Events/HeroDeletedEvent.h
Normal file
17
L2BotDll/Events/HeroDeletedEvent.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#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;
|
||||
};
|
32
L2BotDll/Events/SkillCancelledEvent.h
Normal file
32
L2BotDll/Events/SkillCancelledEvent.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#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;
|
||||
};
|
33
L2BotDll/Events/SkillCreatedEvent.h
Normal file
33
L2BotDll/Events/SkillCreatedEvent.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
#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<int32_t> GetSkillInfo() const
|
||||
{
|
||||
return m_SkillInfo;
|
||||
}
|
||||
|
||||
SkillCreatedEvent(const std::vector<int32_t> skillInfo) :
|
||||
m_SkillInfo(skillInfo)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SkillCreatedEvent() = delete;
|
||||
virtual ~SkillCreatedEvent() = default;
|
||||
|
||||
private:
|
||||
const std::vector<int32_t> m_SkillInfo;
|
||||
};
|
33
L2BotDll/Events/SkillUsedEvent.h
Normal file
33
L2BotDll/Events/SkillUsedEvent.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
#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<int32_t> GetSkillInfo() const
|
||||
{
|
||||
return m_SkillInfo;
|
||||
}
|
||||
|
||||
SkillUsedEvent(const std::vector<int32_t> skillInfo) :
|
||||
m_SkillInfo(skillInfo)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SkillUsedEvent() = delete;
|
||||
virtual ~SkillUsedEvent() = default;
|
||||
|
||||
private:
|
||||
const std::vector<int32_t> m_SkillInfo;
|
||||
};
|
18
L2BotDll/Events/SpoiledEvent.h
Normal file
18
L2BotDll/Events/SpoiledEvent.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#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;
|
||||
};
|
Reference in New Issue
Block a user