Files
JuegoSim/Assets/_Project/Scripts/Code/CommandLayer/Commands/DeleteGroupCommand.cs
T
2026-07-21 08:56:10 +03:00

51 lines
1.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DeleteGroupCommand : ICommand
{
private List<string> blocksId;
private List<DeleteBlockCommand> deleteBlockCommands;
public DeleteGroupCommand(List<string> blocksId)
{
this.blocksId = blocksId;
deleteBlockCommands = new List<DeleteBlockCommand>();
}
public DeleteGroupCommand(CommandDTO commandDTO)
{
this.blocksId = (List<string>)commandDTO.Parameters["blocksId"];
deleteBlockCommands = new List<DeleteBlockCommand>();
}
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();
}
}