Example #1
0
 public void UndoLastCommand()
 {
     if (_commandsQueue.Count > 0)
     {
         Command cmd = _commandsQueue.Pop();
         cmd.Undo();
         Debug.Log("Undoing command - " + cmd.GetDescription());
         OnCommandUndone?.Invoke(cmd);
     }
 }
Example #2
0
 public void ExecuteCommand(Command cmd)
 {
     if (cmd.isUndoable)
     {
         _commandsQueue.Push(cmd);
     }
     cmd.Execute();
     Debug.Log("Executing command - " + cmd.GetDescription() + (cmd.isUndoable ? "" : " (not undoable)"));
     OnCommandDone?.Invoke(cmd);
 }