Enzo
Loading...
Searching...
No Matches
CreateNodeCommand.h
1#pragma once
2
3#include "Engine/Core/Types.h"
4#include "Engine/Network/NetworkManager.h"
5#include "Engine/Network/NodeSnapshot.h"
6#include "Engine/UndoRedo/UndoCommand.h"
7
8namespace enzo::nt {
9
11{
12 public:
13 CreateNodeCommand(NodeId nodeId) : nodeId_(nodeId) {}
14
15 void undo() override
16 {
17 snapshot_ = NodeSnapshot::capture(nm().getNode(nodeId_));
18 nm().deleteNode(nodeId_);
19 }
20
21 void redo() override { snapshot_.restore(nodeId_); }
22
23 UndoCommandType type() const override { return UndoCommandType::CreateNode; }
24
25 private:
26 NodeId nodeId_;
27 NodeSnapshot snapshot_;
28};
29
30} // namespace enzo::nt
Basic attribute, parameter, and node types for Enzo.
uint64_t NodeId
The unique ID assigned to each node in the network.
Definition Types.h:306
Definition CreateNodeCommand.h:11
void deleteNode(NodeId nodeId)
Deletes a node, pushing an undo command.
Definition NetworkManager.cpp:52
Everything one node carries, held apart from the network so it can be rebuilt.
Definition NodeSnapshot.h:25
void restore(NodeId nodeId) const
Rebuilds the node under the given id with the path, position, and parameters it had.
Definition NodeSnapshot.cpp:22
static NodeSnapshot capture(Node &node)
Returns a snapshot of the node as it stands.
Definition NodeSnapshot.cpp:8
Definition UndoCommand.h:8