29 graph.BuildLookupCache();
34 auto it = std::remove_if(
graph.Nodes.begin(),
graph.Nodes.end(),
37 graph.BuildLookupCache();
42 std::ostringstream
ss;
59 for (
const auto&
n :
graph.Nodes)
70 for (
const auto&
ec :
graph.ExecConnections)
78 for (
const auto&
dc :
graph.DataConnections)
85 auto it = std::remove_if(
graph.Nodes.begin(),
graph.Nodes.end(),
90 auto eit = std::remove_if(
graph.ExecConnections.begin(),
graph.ExecConnections.end(),
92 { return ec.SourceNodeID == m_nodeID || ec.TargetNodeID == m_nodeID; });
93 graph.ExecConnections.erase(
eit,
graph.ExecConnections.end());
96 auto dit = std::remove_if(
graph.DataConnections.begin(),
graph.DataConnections.end(),
98 { return dc.SourceNodeID == m_nodeID || dc.TargetNodeID == m_nodeID; });
99 graph.DataConnections.erase(
dit,
graph.DataConnections.end());
101 graph.BuildLookupCache();
111 graph.ExecConnections.push_back(
ec);
113 graph.DataConnections.push_back(
dc);
115 graph.BuildLookupCache();
120 std::ostringstream
ss;
139 int32_t nodeID,
float x,
float y)
141 for (
auto&
n :
graph.Nodes)
143 if (
n.NodeID == nodeID)
151 n.Parameters[
"__posX"] =
bx;
152 n.Parameters[
"__posY"] =
by;
170 std::ostringstream
ss;
193 auto it = std::remove_if(
graph.ExecConnections.begin(),
graph.ExecConnections.end(),
196 return ec.SourceNodeID == m_conn.SourceNodeID &&
197 ec.TargetNodeID == m_conn.TargetNodeID &&
198 ec.SourcePinName == m_conn.SourcePinName &&
199 ec.TargetPinName == m_conn.TargetPinName;
201 graph.ExecConnections.erase(
it,
graph.ExecConnections.end());
206 std::ostringstream
ss;
228 auto it = std::remove_if(
graph.DataConnections.begin(),
graph.DataConnections.end(),
231 return dc.SourceNodeID == m_conn.SourceNodeID &&
232 dc.TargetNodeID == m_conn.TargetNodeID &&
233 dc.SourcePinName == m_conn.SourcePinName &&
234 dc.TargetPinName == m_conn.TargetPinName;
236 graph.DataConnections.erase(
it,
graph.DataConnections.end());
241 std::ostringstream
ss;
252 : m_isExecConn(
true), m_savedExecConn(
conn), m_savedDataConn()
257 : m_isExecConn(
false), m_savedExecConn(), m_savedDataConn(
conn)
265 auto it = std::remove_if(
graph.ExecConnections.begin(),
graph.ExecConnections.end(),
268 return ec.SourceNodeID == m_savedExecConn.SourceNodeID &&
269 ec.TargetNodeID == m_savedExecConn.TargetNodeID &&
270 ec.SourcePinName == m_savedExecConn.SourcePinName &&
271 ec.TargetPinName == m_savedExecConn.TargetPinName;
273 graph.ExecConnections.erase(
it,
graph.ExecConnections.end());
277 auto it = std::remove_if(
graph.DataConnections.begin(),
graph.DataConnections.end(),
280 return dc.SourceNodeID == m_savedDataConn.SourceNodeID &&
281 dc.TargetNodeID == m_savedDataConn.TargetNodeID &&
282 dc.SourcePinName == m_savedDataConn.SourcePinName &&
283 dc.TargetPinName == m_savedDataConn.TargetPinName;
285 graph.DataConnections.erase(
it,
graph.DataConnections.end());
287 graph.BuildLookupCache();
296 graph.BuildLookupCache();
301 std::ostringstream
ss;
335 const std::string&
key,
338 if (
key ==
"NodeName")
340 else if (
key ==
"AtomicTaskID")
342 else if (
key ==
"ConditionID")
344 else if (
key ==
"BBKey")
346 else if (
key ==
"MathOperator")
348 else if (
key ==
"SubGraphPath")
350 else if (
key ==
"DelaySeconds")
356 for (
size_t i = 0;
i <
graph.Nodes.size(); ++
i)
364 graph.BuildLookupCache();
369 for (
size_t i = 0;
i <
graph.Nodes.size(); ++
i)
377 graph.BuildLookupCache();
382 std::ostringstream
ss;
399 for (
size_t i = 0;
i <
graph.Nodes.size(); ++
i)
407 graph.BuildLookupCache();
412 for (
size_t i = 0;
i <
graph.Nodes.size(); ++
i)
416 std::vector<std::string>&
pins =
graph.Nodes[
i].DynamicExecOutputPins;
422 graph.BuildLookupCache();
435 const std::string& pinName,
450 for (
size_t i = 0;
i <
graph.Nodes.size(); ++
i)
454 std::vector<std::string>&
pins =
graph.Nodes[
i].DynamicExecOutputPins;
462 auto it = std::remove_if(
graph.ExecConnections.begin(),
graph.ExecConnections.end(),
465 return ec.SourceNodeID == m_nodeID && ec.SourcePinName == m_pinName;
467 graph.ExecConnections.erase(
it,
graph.ExecConnections.end());
469 graph.BuildLookupCache();
475 for (
size_t i = 0;
i <
graph.Nodes.size(); ++
i)
479 std::vector<std::string>&
pins =
graph.Nodes[
i].DynamicExecOutputPins;
501 graph.BuildLookupCache();
615 for (
size_t i = 0;
i <
graph.Nodes.size(); ++
i)
627 for (
size_t i = 0;
i <
graph.Nodes.size(); ++
i)
656 for (
size_t i = 0;
i <
graph.Nodes.size(); ++
i)
668 for (
size_t i = 0;
i <
graph.Nodes.size(); ++
i)
680 return "Edit node properties on node #" + std::to_string(
m_nodeID);
ComponentTypeID GetComponentTypeID_Static()
Undo/Redo command stack for ATS Visual Scripting editor (Phase 6).
std::string GetDescription() const override
Returns a short human-readable description (e.g.
void Execute(TaskGraphTemplate &graph) override
Applies the command to the graph.
void Undo(TaskGraphTemplate &graph) override
Reverses the command on the graph.
AddConnectionCommand(const ExecPinConnection &conn)
void Undo(TaskGraphTemplate &graph) override
Reverses the command on the graph.
std::string GetDescription() const override
Returns a short human-readable description (e.g.
AddDataConnectionCommand(const DataPinConnection &conn)
void Execute(TaskGraphTemplate &graph) override
Applies the command to the graph.
void Execute(TaskGraphTemplate &graph) override
Applies the command to the graph.
std::string GetDescription() const override
Returns a short human-readable description (e.g.
AddDynamicPinCommand(int32_t nodeID, const std::string &pinName)
void Undo(TaskGraphTemplate &graph) override
Reverses the command on the graph.
TaskNodeDefinition m_node
std::string GetDescription() const override
Get a human-readable description of the command.
void Undo() override
Undo the command.
AddNodeCommand(BehaviorTreeAsset *tree, BTNodeType type, const std::string &name, const Vector &position)
void Execute() override
Execute the command.
void Execute(TaskGraphTemplate &graph) override
Applies the command to the graph.
DataPinConnection m_savedDataConn
ExecPinConnection m_savedExecConn
void Undo(TaskGraphTemplate &graph) override
Reverses the command on the graph.
std::string GetDescription() const override
Returns a short human-readable description (e.g.
DeleteLinkCommand(const ExecPinConnection &conn)
void Undo() override
Undo the command.
std::vector< DataPinConnection > m_savedDataConns
void Execute() override
Execute the command.
std::string GetDescription() const override
Get a human-readable description of the command.
std::vector< ExecPinConnection > m_savedExecConns
DeleteNodeCommand(BehaviorTreeAsset *tree, uint32_t nodeId)
std::string GetDescription() const override
Returns a short human-readable description (e.g.
void Execute(TaskGraphTemplate &graph) override
Applies the command to the graph.
EditNodePropertiesCommand(int32_t nodeID, const ParameterMap &oldParams, const ParameterMap &newParams)
void Undo(TaskGraphTemplate &graph) override
Reverses the command on the graph.
std::unordered_map< std::string, ParameterBinding > ParameterMap
EditNodePropertyCommand(int32_t nodeID, const std::string &propertyKey, const PropertyValue &oldValue, const PropertyValue &newValue)
void Undo(TaskGraphTemplate &graph) override
Reverses the command on the graph.
std::string m_propertyKey
void Execute(TaskGraphTemplate &graph) override
Applies the command to the graph.
static void ApplyValue(TaskNodeDefinition &node, const std::string &key, const PropertyValue &value)
Applies value to the named field of node.
std::string GetDescription() const override
Returns a short human-readable description (e.g.
std::string GetDescription() const override
Get a human-readable description of the command.
EditParameterCommand(BehaviorTreeAsset *tree, uint32_t nodeId, const std::string ¶mName, const std::string &oldValue, const std::string &newValue, ParamType type)
void Undo() override
Undo the command.
void Execute() override
Execute the command.
ParameterBinding m_oldBinding
ParameterBinding m_newBinding
std::string GetDescription() const override
Get a human-readable description of the command.
void Undo() override
Undo the command.
static void SetNodePos(TaskGraphTemplate &graph, int32_t nodeID, float x, float y)
MoveNodeCommand(BehaviorTreeAsset *tree, uint32_t nodeId, const Vector &oldPos, const Vector &newPos)
void Execute() override
Execute the command.
std::string m_linkedTargetPinName
RemoveExecPinCommand(int32_t nodeID, const std::string &pinName, int pinIndex, int32_t linkedTargetNodeID, const std::string &linkedTargetPinName)
std::string GetDescription() const override
Returns a short human-readable description (e.g.
int32_t m_linkedTargetNodeID
-1 if no outgoing link was present
void Execute(TaskGraphTemplate &graph) override
Applies the command to the graph.
void Undo(TaskGraphTemplate &graph) override
Reverses the command on the graph.
Immutable, shareable task graph asset.
C++14-compliant type-safe value container for task parameters.
bool CanUndo() const
Returns true if there is at least one command to undo.
std::size_t RedoSize() const
Returns the number of commands currently on the redo stack.
void Clear()
Clears both undo and redo stacks (e.g.
std::size_t UndoSize() const
Returns the number of commands currently on the undo stack.
bool CanRedo() const
Returns true if there is at least one command to redo.
std::string PeekUndoDescription() const
Returns the description of the top undo command, or "" if empty.
void Redo(TaskGraphTemplate &graph)
Re-applies the last undone command, moving it back to the undo stack.
std::string PeekRedoDescription() const
Returns the description of the top redo command, or "" if empty.
void Undo(TaskGraphTemplate &graph)
Undoes the last command, moving it to the redo stack.
std::vector< std::unique_ptr< ICommand > > m_undoStack
std::vector< std::unique_ptr< ICommand > > m_redoStack
void PushCommand(std::unique_ptr< ICommand > cmd, TaskGraphTemplate &graph)
Executes the command on graph, then pushes it onto the undo stack.
static const std::size_t MAX_STACK_SIZE
Maximum number of undo entries kept in memory.
< Provides AssetID and INVALID_ASSET_ID
@ Literal
Value is embedded directly in the template.
Explicit connection between an output data pin of a source node and an input data pin of a target nod...
std::string TargetPinName
std::string SourcePinName
Explicit connection between a named exec-out pin of a source node and the exec-in pin of a target nod...
std::string SourcePinName
e.g. "Then", "Else", "Loop", "Completed"
std::string TargetPinName
e.g. "In"
Describes how a single parameter value is supplied to a task node.
ParameterBindingType Type
Binding mode.
Discriminated union of property value types (String / Float).
Full description of a single node in the task graph.
std::string NodeName
Human-readable name.
int32_t NodeID
Unique ID within this template.