Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
RuntimeEnvironment.h
Go to the documentation of this file.
1/**
2 * @file RuntimeEnvironment.h
3 * @brief Runtime context supplying Blackboard variables and dynamic pin values.
4 * @author Olympe Engine
5 * @date 2026-03-17
6 *
7 * @details
8 * RuntimeEnvironment encapsulates the two sources of float data that
9 * ConditionEvaluator needs when it resolves Operands at runtime:
10 *
11 * - Blackboard variables (Variable-mode operands)
12 * - Dynamic pin values (Pin-mode operands)
13 *
14 * Const-mode operands carry their value directly in the Operand struct and
15 * therefore do not consult the RuntimeEnvironment at all.
16 *
17 * C++14 compliant — no std::optional, structured bindings, std::filesystem.
18 */
19
20#pragma once
21
22#include <map>
23#include <string>
24
25namespace Olympe {
26
27/**
28 * @class RuntimeEnvironment
29 * @brief Provides Blackboard variable values and dynamic pin values at runtime.
30 *
31 * @details
32 * Acts as the single source of truth for all float data during condition
33 * evaluation. Populated before evaluation begins (or updated dynamically
34 * as connected nodes provide new data).
35 */
37public:
38
39 RuntimeEnvironment() = default;
40
41 // -----------------------------------------------------------------------
42 // Blackboard variables
43 // -----------------------------------------------------------------------
44
45 /**
46 * @brief Stores or overwrites a Blackboard variable.
47 * @param key Variable identifier (e.g. "mHealth").
48 * @param value Float value to associate with the key.
49 */
50 void SetBlackboardVariable(const std::string& key, float value);
51
52 /**
53 * @brief Looks up a Blackboard variable.
54 * @param key Variable identifier.
55 * @param outValue Receives the value when found.
56 * @return true when the key exists; false otherwise.
57 */
58 bool GetBlackboardVariable(const std::string& key, float& outValue) const;
59
60 /**
61 * @brief Returns true when the given key has been set.
62 * @param key Variable identifier.
63 */
64 bool HasBlackboardVariable(const std::string& key) const;
65
66 // -----------------------------------------------------------------------
67 // Dynamic pin values
68 // -----------------------------------------------------------------------
69
70 /**
71 * @brief Stores or overwrites the runtime value for a dynamic data pin.
72 * @param pinID Pin UUID (matches DynamicDataPin::id or NodeConditionRef::leftPinID / rightPinID).
73 * @param value Float value delivered by the connected node.
74 */
75 void SetDynamicPinValue(const std::string& pinID, float value);
76
77 /**
78 * @brief Looks up the runtime value of a dynamic data pin.
79 * @param pinID Pin UUID.
80 * @param outValue Receives the value when found.
81 * @return true when the pin ID exists; false otherwise.
82 */
83 bool GetDynamicPinValue(const std::string& pinID, float& outValue) const;
84
85 // -----------------------------------------------------------------------
86 // Utility
87 // -----------------------------------------------------------------------
88
89 /**
90 * @brief Removes all stored variables and pin values.
91 */
92 void Clear();
93
94private:
95
96 std::map<std::string, float> m_blackboardVariables; ///< Blackboard key -> value
97 std::map<std::string, float> m_dynamicPinValues; ///< Pin UUID -> value
98};
99
100} // namespace Olympe
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
Provides Blackboard variable values and dynamic pin values at runtime.
bool GetBlackboardVariable(const std::string &key, float &outValue) const
Looks up a Blackboard variable.
void SetDynamicPinValue(const std::string &pinID, float value)
Stores or overwrites the runtime value for a dynamic data pin.
std::map< std::string, float > m_blackboardVariables
Blackboard key -> value.
void Clear()
Removes all stored variables and pin values.
void SetBlackboardVariable(const std::string &key, float value)
Stores or overwrites a Blackboard variable.
bool GetDynamicPinValue(const std::string &pinID, float &outValue) const
Looks up the runtime value of a dynamic data pin.
std::map< std::string, float > m_dynamicPinValues
Pin UUID -> value.
bool HasBlackboardVariable(const std::string &key) const
Returns true when the given key has been set.
< Provides AssetID and INVALID_ASSET_ID