CheeseEngine
A 2D Game Engine
Loading...
Searching...
No Matches
Events.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <entt/entt.hpp>
5#include <glm/glm.hpp>
6
10struct Event {
16 virtual ~Event() = default;
17};
18
22struct CollideEvent : public Event {
23 entt::entity entityA;
24 entt::entity entityB;
25 glm::vec2 normal;
26 float force;
27
33 CollideEvent() = default;
34
44 CollideEvent(entt::entity a, entt::entity b, glm::vec2 normal, float f)
45 : entityA(a), entityB(b), normal(normal), force(f) {
46 }
47};
48
52enum class TriggerAction {
53 ENTER,
54 STAY,
55 EXIT
56};
57
61struct InterceptionEvent : public Event {
62 entt::entity entityA;
63 entt::entity entityB;
65
71 InterceptionEvent() = default;
72
80 InterceptionEvent(entt::entity a, entt::entity b, TriggerAction act)
81 : entityA(a), entityB(b), action(act) {
82 }
83};
84
85// Keeping int type for GLFW compatibility
86constexpr int INPUT_RELEASE = 0;
87constexpr int INPUT_PRESS = 1;
88constexpr int INPUT_HOLD = 2;
89
93struct InputEvent : public Event {
94 int key;
95 int action;
96
102 InputEvent() = default;
103
110 InputEvent(int k, int a) : key(k), action(a) {
111 }
112};
113
117struct QuestStartEvent : public Event {
118 uint32_t questID;
119 entt::entity entityID;
120
126 QuestStartEvent() = default;
127
134 QuestStartEvent(uint32_t q, entt::entity e) : questID(q), entityID(e) {
135 }
136};
constexpr int INPUT_PRESS
Key was pressed this frame.
Definition Events.hpp:87
constexpr int INPUT_RELEASE
Key was released.
Definition Events.hpp:86
constexpr int INPUT_HOLD
Key is being held down.
Definition Events.hpp:88
TriggerAction
Represents the state of a trigger zone overlap.
Definition Events.hpp:52
@ ENTER
Entity just entered the trigger zone.
@ STAY
Entity is currently inside the trigger zone.
@ EXIT
Entity just left the trigger zone.
Fired when two solid physical bodies collide.
Definition Events.hpp:22
float force
Magnitude of the collision impulse.
Definition Events.hpp:26
entt::entity entityA
ID of the entity that initiated the contact.
Definition Events.hpp:23
CollideEvent()=default
Default constructor for line-by-line initialization.
entt::entity entityB
ID of the entity that was hit.
Definition Events.hpp:24
glm::vec2 normal
Collision normal vector (direction of the impact)
Definition Events.hpp:25
CollideEvent(entt::entity a, entt::entity b, glm::vec2 normal, float f)
Initializes a collision event with specific physics data.
Definition Events.hpp:44
Base marker class for all engine events.
Definition Events.hpp:10
virtual ~Event()=default
Virtual destructor to ensure proper polymorphic cleanup.
Fired when input from the OS/hardware is received.
Definition Events.hpp:93
int action
State of the key (INPUT_PRESS, INPUT_HOLD, or INPUT_RELEASE)
Definition Events.hpp:95
InputEvent()=default
Default constructor.
InputEvent(int k, int a)
Initializes an input event directly from OS callbacks.
Definition Events.hpp:110
int key
GLFW key code (e.g., GLFW_KEY_E)
Definition Events.hpp:94
Fired when an entity overlaps with a non-solid trigger zone.
Definition Events.hpp:61
InterceptionEvent()=default
Default constructor for delayed initialization.
entt::entity entityA
ID of the physical entity (e.g., Player)
Definition Events.hpp:62
InterceptionEvent(entt::entity a, entt::entity b, TriggerAction act)
Initializes an interception event.
Definition Events.hpp:80
TriggerAction action
State of the intersection.
Definition Events.hpp:64
entt::entity entityB
ID of the non-solid trigger zone.
Definition Events.hpp:63
Fired when a built-in quest or script is triggered.
Definition Events.hpp:117
entt::entity entityID
ID of the entity that initiated the quest.
Definition Events.hpp:119
uint32_t questID
ID of the quest to be executed.
Definition Events.hpp:118
QuestStartEvent(uint32_t q, entt::entity e)
Initializes a quest start event.
Definition Events.hpp:134
QuestStartEvent()=default
Default constructor.