summaryrefslogtreecommitdiff
path: root/WorldlineKeepers/Assets/Scripts/Tools/Commands/CommandGroup.cs
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2023-05-16 16:03:51 +0800
committerchai <215380520@qq.com>2023-05-16 16:03:51 +0800
commit2afbb545027568fccc85853e18af02a7c6b2929e (patch)
tree3827873af133fe9f81041e4babbfd0d54a53f9d1 /WorldlineKeepers/Assets/Scripts/Tools/Commands/CommandGroup.cs
parent88f739ea0f3440152082f34707e79328a71aabed (diff)
*misc
Diffstat (limited to 'WorldlineKeepers/Assets/Scripts/Tools/Commands/CommandGroup.cs')
-rw-r--r--WorldlineKeepers/Assets/Scripts/Tools/Commands/CommandGroup.cs96
1 files changed, 96 insertions, 0 deletions
diff --git a/WorldlineKeepers/Assets/Scripts/Tools/Commands/CommandGroup.cs b/WorldlineKeepers/Assets/Scripts/Tools/Commands/CommandGroup.cs
new file mode 100644
index 0000000..8e53888
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Tools/Commands/CommandGroup.cs
@@ -0,0 +1,96 @@
+using System.Collections;
+using System.Collections.Generic;
+using System.ComponentModel.Design;
+using System.Diagnostics.Tracing;
+using System.Linq;
+using UnityEngine;
+using UnityEngine.AI;
+using UnityEngine.UIElements;
+
+namespace WK
+{
+ //http://warmcat.org/chai/blog/?p=2343
+
+ public abstract class CommandsGroup
+ {
+
+ public abstract class Command
+ {
+ public CommandID ID;
+ public Command(CommandID id)
+ {
+ this.ID = id;
+ }
+ /// <summary>
+ /// 执行命令
+ /// </summary>
+ public abstract void Execute();
+ /// <summary>
+ /// 注册命令的参数
+ /// </summary>
+ /// <param name="_param"></param>
+ public abstract void Register(params object[] _param);
+ }
+
+ protected List<Command> commandQueue = new List<Command>();
+ protected void AddCommand(Command cmd)
+ {
+ commandQueue.Add(cmd);
+ }
+
+ public CommandsGroup()
+ {
+ SetupCommands();
+ }
+
+ /// <summary>
+ /// 填充 commandQueue
+ /// </summary>
+ protected abstract void SetupCommands();
+
+ public void Execute()
+ {
+ foreach (Command e in commandQueue)
+ {
+ e.Execute();
+ }
+ }
+
+ public void RegisterParams(params object[] data)
+ {
+ if (data.Length < 1)
+ return;
+ CommandID id = (CommandID)data[0];
+ int len = data.Length;
+ foreach (Command e in commandQueue)
+ {
+ if (e.ID == id)
+ {
+ e.Register(data.Skip(1).Take(len - 1));
+ break;
+ }
+ }
+ }
+ }
+
+ /*
+ /// <summary>
+ /// 主场景打开时执行的命令集合
+ /// </summary>
+ class MainSceneLoadCommandsGroup : CommandsGroup
+ {
+ public MainSceneLoadCommandsGroup() : base()
+ {
+ // 设置需要执行的命令
+
+ AddCommand(new OpenPanelCommand());
+ // 其他命令
+ //AddCommand(new MessageBox());
+ //AddCommand(new OpenChest());
+ //...
+ }
+ }
+
+ */
+
+}