Initial commit
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
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();
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user