blob: e5450ee7835a10e7c7f5071d544a6bb5fa1e584e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace WK
{
public abstract class Command
{
public abstract void Execute();
}
/// <summary>
/// 保存一些列cmd并在需要时按顺序执行
/// </summary>
public class CommandList
{
private List<Command> m_Commands = new List<Command>();
public void AddCommand(Command cmd)
{
if (cmd == null)
{
return;
}
m_Commands.Add(cmd);
}
public void RemoveCommand(Command cmd)
{
if (cmd == null)
{
return;
}
m_Commands.Remove(cmd);
}
public void Execute()
{
for (int i = 0; i < m_Commands.Count; ++i)
{
m_Commands[i].Execute();
}
}
}
}
|