diff options
| author | KiritoDv <kiritodev01@gmail.com> | 2024-12-28 01:31:13 -0600 |
|---|---|---|
| committer | Lywx <kiritodev01@gmail.com> | 2025-01-03 16:56:49 -0600 |
| commit | 7cfa58117dc1306efcd21b565d97e661944dffac (patch) | |
| tree | fe1870196289aee8d79765c73bc3be5a70e852e8 /src/port/hooks/impl/EventSystem.h | |
| parent | 4dd2eb6eb670b695d76c23357344a051fab7f7dd (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 |
