Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
AIEvents.h
Go to the documentation of this file.
1/*
2Olympe Engine V2 - 2025
3Nicolas Chereau
4nchereau@gmail.com
5
6This file is part of Olympe Engine V2.
7
8AI Events purpose: Helper functions for emitting AI-related gameplay events via EventQueue.
9
10*/
11
12#pragma once
13
14#include "../system/EventQueue.h"
15#include "../system/message.h"
16#include "../system/system_consts.h"
17#include "../vector.h"
18#include "../ECS_Entity.h"
19
20namespace AIEvents
21{
22 // Emit an explosion event at a position
23 // This will be heard by NPCs within their hearing radius
24 inline void EmitExplosion(const Vector& position, float radius)
25 {
29 );
30 msg.param1 = position.x;
31 msg.param2 = position.y;
32 msg.state = static_cast<int>(radius);
33
35 }
36
37 // Emit a noise/sound event at a position
38 // Intensity affects how far the sound travels
39 inline void EmitNoise(const Vector& position, float intensity = 1.0f)
40 {
44 );
45 msg.param1 = position.x;
46 msg.param2 = position.y;
47 msg.state = static_cast<int>(intensity * 100.0f);
48
50 }
51
52 // Emit a damage dealt event
53 // This notifies NPCs when damage is dealt, allowing them to react
54 inline void EmitDamageDealt(EntityID victim, EntityID attacker, float damage)
55 {
59 );
60 msg.targetUid = victim;
61 msg.deviceId = static_cast<int>(attacker);
62 msg.param1 = damage;
63
65 }
66}
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
std::uint64_t EntityID
Definition ECS_Entity.h:21
void Push(const Message &msg)
Definition EventQueue.h:37
static EventQueue & Get()
Definition EventQueue.h:34
float y
Definition vector.h:27
float x
Definition vector.h:27
void EmitNoise(const Vector &position, float intensity=1.0f)
Definition AIEvents.h:39
void EmitDamageDealt(EntityID victim, EntityID attacker, float damage)
Definition AIEvents.h:54
void EmitExplosion(const Vector &position, float radius)
Definition AIEvents.h:24
static Message Create(EventType _ev_t, EventDomain _domain, int _d_id=-1, int _c_id=-1, uint64_t _t_uid=0)
Definition message.h:28
@ Olympe_EventType_AI_Noise
@ Olympe_EventType_AI_Explosion