Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
BTEditorCommand.h
Go to the documentation of this file.
1// [DEPRECATED - Phase 5 - 2026-03-07]
2// Ce fichier est archivé. Il ne doit plus être inclus ni compilé.
3// Remplacé par : BPCommandSystem (Blueprint::CreateNodeCommand, etc.)
4// Voir : Docs/BLUEPRINT-REFACTOR-MARCH-2026.md
5
6/**
7 * @file BTEditorCommand.h
8 * @brief Command pattern implementation for behavior tree editor undo/redo
9 * @author Olympe Engine - BT Editor
10 * @date 2026
11 *
12 * @details
13 * Implements the Command pattern for all editor operations to enable undo/redo.
14 * Each command encapsulates an action and stores the data needed to undo it.
15 */
16
17#pragma once
18
19#include "BehaviorTree.h"
20#include "../vector.h"
21#include <string>
22#include <vector>
23#include <memory>
24
25namespace Olympe
26{
27 /**
28 * @class BTEditorCommand
29 * @brief Base class for all editor commands
30 */
32 {
33 public:
34 virtual ~BTEditorCommand() = default;
35
36 /**
37 * @brief Execute the command
38 */
39 virtual void Execute() = 0;
40
41 /**
42 * @brief Undo the command
43 */
44 virtual void Undo() = 0;
45
46 /**
47 * @brief Get a human-readable description of the command
48 */
49 virtual std::string GetDescription() const = 0;
50 };
51
52 /**
53 * @class BTCommandStack
54 * @brief Manages undo/redo stacks for editor commands
55 */
57 {
58 public:
59 /**
60 * @brief Execute a command and add it to the undo stack
61 * @param cmd Command to execute
62 */
63 void Execute(std::unique_ptr<BTEditorCommand> cmd);
64
65 /**
66 * @brief Undo the last command
67 */
68 void Undo();
69
70 /**
71 * @brief Redo the last undone command
72 */
73 void Redo();
74
75 /**
76 * @brief Check if undo is available
77 */
78 bool CanUndo() const;
79
80 /**
81 * @brief Check if redo is available
82 */
83 bool CanRedo() const;
84
85 /**
86 * @brief Get description of the next undo command
87 */
88 std::string GetUndoDescription() const;
89
90 /**
91 * @brief Get description of the next redo command
92 */
93 std::string GetRedoDescription() const;
94
95 /**
96 * @brief Clear all commands
97 */
98 void Clear();
99
100 private:
101 std::vector<std::unique_ptr<BTEditorCommand>> m_undoStack;
102 std::vector<std::unique_ptr<BTEditorCommand>> m_redoStack;
103 static const size_t kMaxStackSize = 100;
104 };
105
106 /**
107 * @class AddNodeCommand
108 * @brief Command to add a node to the tree
109 */
111 {
112 public:
113 AddNodeCommand(BehaviorTreeAsset* tree, BTNodeType type, const std::string& name, const Vector& position);
114
115 void Execute() override;
116 void Undo() override;
117 std::string GetDescription() const override;
118
119 private:
122 std::string m_nodeName;
125 };
126
127 /**
128 * @class DeleteNodeCommand
129 * @brief Command to delete a node from the tree
130 */
132 {
133 public:
135
136 void Execute() override;
137 void Undo() override;
138 std::string GetDescription() const override;
139
140 private:
150 std::vector<Connection> m_savedConnections;
151 };
152
153 /**
154 * @class MoveNodeCommand
155 * @brief Command to move a node
156 */
158 {
159 public:
161
162 void Execute() override;
163 void Undo() override;
164 std::string GetDescription() const override;
165
166 private:
171 };
172
173 /**
174 * @class ConnectNodesCommand
175 * @brief Command to connect two nodes
176 */
178 {
179 public:
181
182 void Execute() override;
183 void Undo() override;
184 std::string GetDescription() const override;
185
186 private:
190 };
191
192 /**
193 * @class DisconnectNodesCommand
194 * @brief Command to disconnect two nodes
195 */
197 {
198 public:
200
201 void Execute() override;
202 void Undo() override;
203 std::string GetDescription() const override;
204
205 private:
209 };
210
211 /**
212 * @class EditParameterCommand
213 * @brief Command to edit a node parameter
214 */
216 {
217 public:
218 enum class ParamType { String, Int, Float };
219
221 const std::string& paramName, const std::string& oldValue,
222 const std::string& newValue, ParamType type);
223
224 void Execute() override;
225 void Undo() override;
226 std::string GetDescription() const override;
227
228 private:
231 std::string m_paramName;
232 std::string m_oldValue;
233 std::string m_newValue;
235 };
236
237} // namespace Olympe
Data-driven behavior tree system for AI decision making.
BTNodeType
Behavior tree node types.
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
Command to add a node to the tree.
std::string GetDescription() const override
Get a human-readable description of the command.
void Undo() override
Undo the command.
BehaviorTreeAsset * m_tree
void Execute() override
Execute the command.
Manages undo/redo stacks for editor commands.
std::vector< std::unique_ptr< BTEditorCommand > > m_undoStack
std::string GetUndoDescription() const
Get description of the next undo command.
bool CanRedo() const
Check if redo is available.
void Execute(std::unique_ptr< BTEditorCommand > cmd)
Execute a command and add it to the undo stack.
void Undo()
Undo the last command.
bool CanUndo() const
Check if undo is available.
static const size_t kMaxStackSize
std::string GetRedoDescription() const
Get description of the next redo command.
std::vector< std::unique_ptr< BTEditorCommand > > m_redoStack
void Clear()
Clear all commands.
void Redo()
Redo the last undone command.
Base class for all editor commands.
virtual std::string GetDescription() const =0
Get a human-readable description of the command.
virtual ~BTEditorCommand()=default
virtual void Execute()=0
Execute the command.
virtual void Undo()=0
Undo the command.
Command to connect two nodes.
std::string GetDescription() const override
Get a human-readable description of the command.
void Execute() override
Execute the command.
void Undo() override
Undo the command.
Command to delete a node from the tree.
void Undo() override
Undo the command.
std::vector< Connection > m_savedConnections
void Execute() override
Execute the command.
std::string GetDescription() const override
Get a human-readable description of the command.
BehaviorTreeAsset * m_tree
Command to disconnect two nodes.
void Undo() override
Undo the command.
std::string GetDescription() const override
Get a human-readable description of the command.
void Execute() override
Execute the command.
Command to edit a node parameter.
std::string GetDescription() const override
Get a human-readable description of the command.
void Undo() override
Undo the command.
void Execute() override
Execute the command.
Command to move a node.
std::string GetDescription() const override
Get a human-readable description of the command.
void Undo() override
Undo the command.
BehaviorTreeAsset * m_tree
void Execute() override
Execute the command.
< Provides AssetID and INVALID_ASSET_ID
Represents a single node in a behavior tree.