Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
BTEventTypeRegistry.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <string>
5#include <vector>
6#include <map>
7#include "../../third_party/nlohmann/json.hpp"
8
9// Forward declarations
10enum class EventType;
11enum class EventDomain;
12
13/**
14 * @brief Registry for BT-accessible event types loaded from JSON configuration
15 * Mirrors BTNodeRegistry pattern for consistency
16 */
18{
19public:
20 /**
21 * @brief Event type entry from JSON configuration
22 */
24 {
25 std::string id; // e.g., "Olympe_EventType_AI_Explosion"
26 std::string displayName; // e.g., "AI Explosion"
27 std::string domain; // e.g., "Gameplay"
28 std::string description; // e.g., "Explosion detected at position"
29 std::string category; // e.g., "AI Stimulus"
30 };
31
32 /**
33 * @brief Initialize registry from JSON file with fallback
34 * @param filepath Path to EventTypes.json (e.g., "./Gamedata/BehaviorTree/EventTypes.json")
35 * @return true if loaded successfully (JSON or fallback)
36 */
37 static bool Initialize(const std::string& filepath);
38
39 /**
40 * @brief Get all registered event types
41 */
42 static const std::vector<EventTypeEntry>& GetAllEventTypes();
43
44 /**
45 * @brief Get event type entry by id
46 * @param id Event type identifier (e.g., "Olympe_EventType_AI_Explosion")
47 * @return pointer to entry, nullptr if not found
48 */
49 static const EventTypeEntry* GetEventTypeEntry(const std::string& id);
50
51 /**
52 * @brief Get display name for event type id
53 */
54 static std::string GetDisplayName(const std::string& id);
55
56 /**
57 * @brief Get domain for event type id
58 */
59 static std::string GetDomain(const std::string& id);
60
61 /**
62 * @brief Get category for event type id
63 */
64 static std::string GetCategory(const std::string& id);
65
66 /**
67 * @brief Get all event types for a specific category
68 */
69 static std::vector<EventTypeEntry> GetEventTypesByCategory(const std::string& category);
70
71 /**
72 * @brief Get all unique categories
73 */
74 static std::vector<std::string> GetAllCategories();
75
76 /**
77 * @brief Reload registry from file (for live editing)
78 */
79 static bool Reload(const std::string& filepath);
80
81 /**
82 * @brief Check if event type is registered
83 */
84 static bool IsValid(const std::string& id);
85
86private:
87 /**
88 * @brief Load event types from JSON file
89 */
90 static bool LoadFromJSON(const std::string& filepath);
91
92 /**
93 * @brief Initialize default hardcoded event types (fallback)
94 */
95 static void InitializeDefaults();
96
97 static std::vector<EventTypeEntry> s_eventTypes;
98 static std::map<std::string, size_t> s_eventTypeMap; // id -> index
99 static bool s_initialized;
100};
Registry for BT-accessible event types loaded from JSON configuration Mirrors BTNodeRegistry pattern ...
static bool Initialize(const std::string &filepath)
Initialize registry from JSON file with fallback.
static std::map< std::string, size_t > s_eventTypeMap
static std::string GetDisplayName(const std::string &id)
Get display name for event type id.
static std::vector< EventTypeEntry > s_eventTypes
static std::string GetCategory(const std::string &id)
Get category for event type id.
static std::vector< EventTypeEntry > GetEventTypesByCategory(const std::string &category)
Get all event types for a specific category.
static void InitializeDefaults()
Initialize default hardcoded event types (fallback)
static std::vector< std::string > GetAllCategories()
Get all unique categories.
static bool LoadFromJSON(const std::string &filepath)
Load event types from JSON file.
static bool Reload(const std::string &filepath)
Reload registry from file (for live editing)
static const EventTypeEntry * GetEventTypeEntry(const std::string &id)
Get event type entry by id.
static bool IsValid(const std::string &id)
Check if event type is registered.
static const std::vector< EventTypeEntry > & GetAllEventTypes()
Get all registered event types.
static std::string GetDomain(const std::string &id)
Get domain for event type id.
Event type entry from JSON configuration.
EventType
EventDomain