Enzo
Loading...
Searching...
No Matches
MoveNodeCommand.h
1#pragma once
2
3#include "Engine/Core/Types.h"
4#include "Engine/Network/NetworkManager.h"
5#include "Engine/UndoRedo/UndoCommand.h"
6
7namespace enzo::nt {
8
10{
11 public:
12 MoveNodeCommand(NodeId nodeId, Vector2 oldPos, Vector2 newPos)
13 : nodeId_(nodeId), oldPos_(oldPos), newPos_(newPos)
14 {
15 }
16
17 void undo() override
18 {
19 nm().getNode(nodeId_).setPosition(oldPos_);
20 nm().nodePositionChanged(nodeId_, oldPos_);
21 }
22
23 void redo() override
24 {
25 nm().getNode(nodeId_).setPosition(newPos_);
26 nm().nodePositionChanged(nodeId_, newPos_);
27 }
28
29 UndoCommandType type() const override { return UndoCommandType::MoveNode; }
30
31 private:
32 NodeId nodeId_;
33 Vector2 oldPos_;
34 Vector2 newPos_;
35};
36
37} // 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 MoveNodeCommand.h:10
Node & getNode(nt::NodeId nodeId)
Returns a reference to the Node with the given NodeId.
Definition NetworkManager.cpp:130
void setPosition(Vector2 pos)
Sets the node's position in the network graph.
Definition Node.h:130
Definition UndoCommand.h:8