diff options
| author | KiritoDv <kiritodev01@gmail.com> | 2024-12-28 01:31:13 -0600 |
|---|---|---|
| committer | KiritoDv <kiritodev01@gmail.com> | 2024-12-28 01:31:13 -0600 |
| commit | 072bc49d38d857c3dd6df153dd00c2e674557b6a (patch) | |
| tree | 0c7b4f7b5c337ac037633baaa470045b83de029f /src/port/hooks/impl/EventSystem.h | |
| parent | 22e57921de56a7748861944d5ac2ad4d3d47b35a (diff) | |
Moved spawner to OnGameUpdate hook
Diffstat (limited to 'src/port/hooks/impl/EventSystem.h')
| -rw-r--r-- | src/port/hooks/impl/EventSystem.h | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/port/hooks/impl/EventSystem.h b/src/port/hooks/impl/EventSystem.h index df35545d..d7f47b73 100644 --- a/src/port/hooks/impl/EventSystem.h +++ b/src/port/hooks/impl/EventSystem.h @@ -5,6 +5,7 @@ #include <stddef.h> typedef uint16_t EventID; +typedef uint32_t ListenerID; typedef enum { EVENT_TYPE_PRE, @@ -23,6 +24,11 @@ typedef struct { typedef void (*EventCallback)(IEvent*); +typedef struct { + EventPriority priority; + EventCallback function; +} EventListener; + // ID Type // 000000000000000 0 #define EVENT_ID(id, type) ((id << 1) | type) @@ -34,12 +40,14 @@ typedef void (*EventCallback)(IEvent*); class EventSystem { public: static EventSystem* Instance; - size_t RegisterListener(EventID id, EventPriority priority, EventCallback callback); + ListenerID RegisterListener(EventID id, EventCallback callback, EventPriority priority = EVENT_PRIORITY_NORMAL); + void UnregisterListener(EventID ev, ListenerID id); void CallEvent(EventID id, IEvent* event); private: - std::array<std::vector<EventCallback>, 0xFFFF> mEventListeners; + std::array<std::vector<EventListener>, 0xFFFF> mEventListeners; }; #else -extern size_t EventSystem_RegisterListener(EventID id, EventPriority priority, EventCallback callback); +extern ListenerID EventSystem_RegisterListener(EventID id, EventCallback callback, EventPriority priority); +extern void EventSystem_UnregisterListener(EventID ev, ListenerID id); extern void EventSystem_CallEvent(EventID id, void* event); #endif
\ No newline at end of file |
