-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEvent.h
More file actions
49 lines (39 loc) · 948 Bytes
/
Event.h
File metadata and controls
49 lines (39 loc) · 948 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#pragma once
#include "pch.h"
#include <atomic>
#include <functional>
#include <any>
namespace ndtech {
static std::atomic<size_t> nextEventId = 0;
enum class EventCategory {
Synchronous,
AnyThreadImmediate,
SynchronizeOnMainThread,
AsyncRequest,
AsyncCompletion
};
enum class EventRepeatCategory {
OnlyApplyLatest,
Repeat,
DoNotProcessDuplicatesByPredicate
};
enum class EventProcessingStage {
Input,
Logic,
Physics,
Animation,
Visibility,
Drawing
};
struct Event {
size_t EventTypeId;
std::string typeName;
std::any payload;
EventCategory EventCategory = EventCategory::Synchronous;
EventRepeatCategory EventRepeatCategory = EventRepeatCategory::Repeat;
std::function<bool(Event, Event)> predicate = nullptr;
size_t originatingEventId = (size_t)-1;
size_t entityId = (size_t)-1;
size_t EventId = nextEventId.fetch_add(1);
};
}