Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
BTGraphCommands.h
Go to the documentation of this file.
1/**
2 * @file BTGraphCommands.h
3 * @brief Concrete command implementations for BehaviorTree operations
4 * @author Olympe Engine
5 * @details C++14 compliant undo/redo commands
6 */
7
8#pragma once
9
10#include "GraphCommand.h"
11#include <string>
12#include <vector>
13#include <map>
14
15namespace Olympe
16{
17 // Forward declarations
18 struct ClipboardNode;
19 enum class NodeType;
20 struct GraphNode;
21 class NodeGraph;
22
23 /**
24 * @class CopyNodesCommand
25 * @brief Command to copy selected nodes to clipboard
26 */
28 {
29 public:
30 CopyNodesCommand(NodeGraph* graph, const std::vector<int>& nodeIds);
31 virtual ~CopyNodesCommand() = default;
32
33 bool Execute() override;
34 bool Undo() override;
35 std::string GetDescription() const override;
36
37 private:
39 std::vector<int> m_nodeIds;
40 std::vector<ClipboardNode> m_clipboardData;
41 };
42
43 /**
44 * @class PasteNodesCommand
45 * @brief Command to paste nodes from clipboard with offset
46 */
48 {
49 public:
50 PasteNodesCommand(NodeGraph* graph, float offsetX = 30.0f, float offsetY = 30.0f);
51 virtual ~PasteNodesCommand() = default;
52
53 bool Execute() override;
54 bool Undo() override;
55 std::string GetDescription() const override;
56
57 private:
60 std::vector<int> m_pastedNodeIds; // IDs of newly created nodes
61 std::map<int, int> m_idMapping; // Original ID -> New ID mapping
62 };
63
64 /**
65 * @class DuplicateNodeCommand
66 * @brief Command to duplicate selected nodes (copy + paste in one action)
67 */
69 {
70 public:
71 DuplicateNodeCommand(NodeGraph* graph, const std::vector<int>& nodeIds, float offsetX = 30.0f, float offsetY = 30.0f);
72 virtual ~DuplicateNodeCommand() = default;
73
74 bool Execute() override;
75 bool Undo() override;
76 std::string GetDescription() const override;
77
78 private:
80 std::vector<int> m_originalNodeIds;
81 std::vector<int> m_duplicatedNodeIds; // IDs of newly created nodes
83 };
84}
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
Base command class for undo/redo in graph operations.
Command to copy selected nodes to clipboard.
bool Undo() override
Undo the command (reverse operation)
std::vector< ClipboardNode > m_clipboardData
std::vector< int > m_nodeIds
virtual ~CopyNodesCommand()=default
bool Execute() override
Execute the command (forward operation)
std::string GetDescription() const override
Get a human-readable description of the command.
Command to duplicate selected nodes (copy + paste in one action)
std::string GetDescription() const override
Get a human-readable description of the command.
std::vector< int > m_originalNodeIds
bool Execute() override
Execute the command (forward operation)
std::vector< int > m_duplicatedNodeIds
virtual ~DuplicateNodeCommand()=default
bool Undo() override
Undo the command (reverse operation)
Abstract base class for all graph modification commands.
Command to paste nodes from clipboard with offset.
std::map< int, int > m_idMapping
bool Execute() override
Execute the command (forward operation)
std::string GetDescription() const override
Get a human-readable description of the command.
virtual ~PasteNodesCommand()=default
std::vector< int > m_pastedNodeIds
bool Undo() override
Undo the command (reverse operation)
< Provides AssetID and INVALID_ASSET_ID