public void Undo() { if (CanUndo()) { CreateAnimation($"Command Undone: {GetUndoHint()}"); var command = _commands.Pop(); command.Undo(); CommandStackChanged?.Invoke(); } }
public void ExecuteCommand(ICommand command, bool isUndoable = true) { if (command == null) { throw new ArgumentNullException("Command is null"); } if (isUndoable) { _commands.Push(command); } command.Initialize(Game); command.Execute(); CreateAnimation($"Command added: {command.GetHintText()}"); if (isUndoable) { CommandStackChanged?.Invoke(); } }