Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
NodeConditionRef.h
Go to the documentation of this file.
1/**
2 * @file NodeConditionRef.h
3 * @brief Defines NodeConditionRef — a node's reference to a global ConditionPreset.
4 * @author Olympe Engine
5 * @date 2026-03-16
6 *
7 * @details
8 * NodeConditionRef links a NodeBranch to a ConditionPreset via its UUID.
9 * When a preset has Pin-mode operands the ref also stores the IDs of the
10 * DynamicDataPin instances that were created to supply those values.
11 *
12 * Multiple NodeConditionRefs on a single node are combined with logical AND
13 * or OR operators to form a compound boolean expression.
14 *
15 * C++14 compliant — no std::optional, structured bindings, std::filesystem.
16 */
17
18#pragma once
19
20#include <string>
21#include "../../third_party/nlohmann/json.hpp"
22
23namespace Olympe {
24
25/**
26 * @enum LogicalOp
27 * @brief How this condition is combined with the one preceding it.
28 */
29enum class LogicalOp {
30 Start, ///< First condition in the list (no logical combinator)
31 And, ///< Combined with AND
32 Or ///< Combined with OR
33};
34
35/**
36 * @struct NodeConditionRef
37 * @brief One entry in a NodeBranch's conditions list.
38 *
39 * @details
40 * References a ConditionPreset by UUID. If the referenced preset's left or
41 * right operand is in Pin mode, `leftPinID` / `rightPinID` store the UUID of
42 * the corresponding DynamicDataPin so the runtime evaluator can find the live
43 * float value.
44 */
46 std::string presetID; ///< UUID of the referenced ConditionPreset
47 LogicalOp logicalOp; ///< Combinator with previous condition (ignored for first)
48 std::string leftPinID; ///< DynamicDataPin UUID for left Pin operand (or empty)
49 std::string rightPinID; ///< DynamicDataPin UUID for right Pin operand (or empty)
50
51 // -----------------------------------------------------------------------
52 // Constructors
53 // -----------------------------------------------------------------------
54
55 /// Default constructor — empty preset ID, LogicalOp::Start.
57
58 /// @brief Convenience constructor.
59 /// @param pid Preset UUID to reference.
60 /// @param op Logical combinator (Start for the first condition).
61 NodeConditionRef(const std::string& pid, LogicalOp op);
62
63 // -----------------------------------------------------------------------
64 // Helpers
65 // -----------------------------------------------------------------------
66
67 /// @brief Returns the logical-op as a display string ("Start", "And", "Or").
68 std::string GetLogicalOpString() const;
69
70 /// @brief Returns true when a left-side DynamicDataPin is assigned.
71 bool HasLeftPin() const;
72
73 /// @brief Returns true when a right-side DynamicDataPin is assigned.
74 bool HasRightPin() const;
75
76 // -----------------------------------------------------------------------
77 // Serialization
78 // -----------------------------------------------------------------------
79
80 /// @brief Serializes this ref to a JSON object.
81 nlohmann::json ToJson() const;
82
83 /// @brief Deserializes a NodeConditionRef from a JSON object.
84 static NodeConditionRef FromJson(const nlohmann::json& data);
85};
86
87} // namespace Olympe
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
< Provides AssetID and INVALID_ASSET_ID
LogicalOp
How this condition is combined with the one preceding it.
@ Or
Combined with OR.
@ Start
First condition in the list (no logical combinator)
@ And
Combined with AND.
nlohmann::json json
One entry in a NodeBranch's conditions list.
std::string rightPinID
DynamicDataPin UUID for right Pin operand (or empty)
nlohmann::json ToJson() const
Serializes this ref to a JSON object.
std::string GetLogicalOpString() const
Returns the logical-op as a display string ("Start", "And", "Or").
bool HasLeftPin() const
Returns true when a left-side DynamicDataPin is assigned.
bool HasRightPin() const
Returns true when a right-side DynamicDataPin is assigned.
static NodeConditionRef FromJson(const nlohmann::json &data)
Deserializes a NodeConditionRef from a JSON object.
std::string presetID
UUID of the referenced ConditionPreset.
std::string leftPinID
DynamicDataPin UUID for left Pin operand (or empty)
NodeConditionRef()
Default constructor — empty preset ID, LogicalOp::Start.
LogicalOp logicalOp
Combinator with previous condition (ignored for first)