Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
BTNodeRegistry.h
Go to the documentation of this file.
1/**
2 * @file BTNodeRegistry.h
3 * @brief Registry of all Behavior Tree node types for AIGraphPlugin_BT
4 * @author Olympe Engine
5 * @date 2026-02-18
6 *
7 * @details
8 * Central registry that stores metadata for all BT node types (Composites,
9 * Decorators, Conditions, Actions). Provides type information including
10 * display names, categories, colors, child constraints, and parameters.
11 */
12
13#pragma once
14
15#include <string>
16#include <vector>
17#include <map>
18#include <cstdint>
19
20namespace Olympe {
21namespace AI {
22
23/**
24 * @enum BTNodeCategory
25 * @brief Categories of behavior tree nodes
26 */
27enum class BTNodeCategory : uint8_t {
28 Composite, ///< Flow control nodes (Selector, Sequence, Parallel)
29 Decorator, ///< Modifiers (Inverter, Repeater, Cooldown, etc.)
30 Condition, ///< Boolean checks (HasTarget, InRange, etc.)
31 Action ///< Leaf execution nodes (Wait, Move, Attack, etc.)
32};
33
34/**
35 * @struct BTNodeTypeInfo
36 * @brief Metadata for a behavior tree node type
37 */
39 std::string typeName; ///< Type identifier (e.g., "BT_Selector")
40 std::string displayName; ///< Human-readable name (e.g., "Selector")
41 std::string description; ///< Description of functionality
42 BTNodeCategory category; ///< Node category
43 uint32_t color = 0xFFFFFFFF; ///< RGBA color (0xAABBGGRR format)
44 std::string icon; ///< Unicode icon or symbol
45 int minChildren = -1; ///< Minimum children (-1 = no limit)
46 int maxChildren = -1; ///< Maximum children (-1 = no limit)
47 bool allowsDecorator = false; ///< Can this node be decorated?
48 std::vector<std::string> parameterNames; ///< Parameter names for this type
49};
50
51/**
52 * @class BTNodeRegistry
53 * @brief Singleton registry for all BT node types
54 *
55 * @details
56 * Manages metadata for all behavior tree node types. Automatically initializes
57 * built-in types on first access. Provides queries by type name or category.
58 */
60public:
61 /**
62 * @brief Get singleton instance
63 * @return Reference to global registry
64 */
65 static BTNodeRegistry& Get();
66
67 /**
68 * @brief Register a new node type
69 * @param info Node type metadata
70 */
72
73 /**
74 * @brief Get metadata for a node type
75 * @param typeName Node type identifier
76 * @return Pointer to metadata or nullptr if not found
77 */
78 const BTNodeTypeInfo* GetNodeTypeInfo(const std::string& typeName) const;
79
80 /**
81 * @brief Get all registered node type names
82 * @return Vector of type names
83 */
84 std::vector<std::string> GetAllNodeTypes() const;
85
86 /**
87 * @brief Get node types in a specific category
88 * @param category Category to filter by
89 * @return Vector of type names in the category
90 */
91 std::vector<std::string> GetNodeTypesByCategory(BTNodeCategory category) const;
92
93 /**
94 * @brief Check if a node type exists
95 * @param typeName Type name to check
96 * @return true if registered, false otherwise
97 */
98 bool IsValidNodeType(const std::string& typeName) const;
99
100 /**
101 * @brief Check if a node type can have children
102 * @param typeName Type name to check
103 * @return true if it can have children
104 */
105 bool CanHaveChildren(const std::string& typeName) const;
106
107 /**
108 * @brief Get minimum number of children for a node type
109 * @param typeName Type name to query
110 * @return Minimum children count (-1 = no limit)
111 */
112 int GetMinChildren(const std::string& typeName) const;
113
114 /**
115 * @brief Get maximum number of children for a node type
116 * @param typeName Type name to query
117 * @return Maximum children count (-1 = no limit)
118 */
119 int GetMaxChildren(const std::string& typeName) const;
120
121private:
123 ~BTNodeRegistry() = default;
124
127
128 /**
129 * @brief Initialize all built-in BT node types
130 */
132
133 std::map<std::string, BTNodeTypeInfo> m_nodeTypes;
134};
135
136} // namespace AI
137} // namespace Olympe
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
Singleton registry for all BT node types.
bool CanHaveChildren(const std::string &typeName) const
Check if a node type can have children.
BTNodeRegistry & operator=(const BTNodeRegistry &)=delete
std::map< std::string, BTNodeTypeInfo > m_nodeTypes
void RegisterNodeType(const BTNodeTypeInfo &info)
Register a new node type.
int GetMaxChildren(const std::string &typeName) const
Get maximum number of children for a node type.
std::vector< std::string > GetNodeTypesByCategory(BTNodeCategory category) const
Get node types in a specific category.
const BTNodeTypeInfo * GetNodeTypeInfo(const std::string &typeName) const
Get metadata for a node type.
BTNodeRegistry(const BTNodeRegistry &)=delete
bool IsValidNodeType(const std::string &typeName) const
Check if a node type exists.
std::vector< std::string > GetAllNodeTypes() const
Get all registered node type names.
void InitializeBuiltInTypes()
Initialize all built-in BT node types.
static BTNodeRegistry & Get()
Get singleton instance.
int GetMinChildren(const std::string &typeName) const
Get minimum number of children for a node type.
BTNodeCategory
Categories of behavior tree nodes.
@ Action
Leaf execution nodes (Wait, Move, Attack, etc.)
@ Composite
Flow control nodes (Selector, Sequence, Parallel)
@ Decorator
Modifiers (Inverter, Repeater, Cooldown, etc.)
@ Condition
Boolean checks (HasTarget, InRange, etc.)
< Provides AssetID and INVALID_ASSET_ID
Metadata for a behavior tree node type.
BTNodeCategory category
Node category.
std::string displayName
Human-readable name (e.g., "Selector")
std::string description
Description of functionality.
bool allowsDecorator
Can this node be decorated?
std::string typeName
Type identifier (e.g., "BT_Selector")
std::vector< std::string > parameterNames
Parameter names for this type.
std::string icon
Unicode icon or symbol.
int minChildren
Minimum children (-1 = no limit)
int maxChildren
Maximum children (-1 = no limit)
uint32_t color
RGBA color (0xAABBGGRR format)