using System.Collections; using System.Collections.Generic; using UnityEngine; public class DeleteGroupCommand : ICommand { private List blocksId; private List deleteBlockCommands; public DeleteGroupCommand(List blocksId) { this.blocksId = blocksId; deleteBlockCommands = new List(); } public DeleteGroupCommand(CommandDTO commandDTO) { this.blocksId = (List)commandDTO.Parameters["blocksId"]; deleteBlockCommands = new List(); } public void execute() { deleteBlockCommands.Clear(); foreach (string id in blocksId) { DeleteBlockCommand command = new DeleteBlockCommand(id); command.execute(); deleteBlockCommands.Add(command); } } public void undo() { foreach (DeleteBlockCommand command in deleteBlockCommands) { command.undo(); } } public CommandDTO toDTO() { return new CommandDTO.CommandDTOBuilder() .SetCommandName("DeleteGroup") .AddParameter("blocksId", blocksId) .Build(); } }