mirror of
https://github.com/HarbourMasters/Starship
synced 2026-06-10 13:04:59 -04:00
Moved spawner to OnGameUpdate hook
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user