private static void ExecuteCommands() { if (commandBuffer.Count > 0) { IObjectPlaceCommand command = commandBuffer.Dequeue(); command.Execute(); commandHistory.Add(command); counter++; } else { if (Input.GetKeyDown(KeyCode.Z)) { if (counter > 0) { counter--; commandHistory[counter].Undo(); } } else if (Input.GetKeyDown(KeyCode.R)) { if (counter < commandHistory.Count) { commandHistory[counter].Execute(); counter++; } } } }
public static void AddCommand(IObjectPlaceCommand command) { while (commandHistory.Count > counter) { commandHistory.RemoveAt(counter); } commandBuffer.Enqueue(command); }