From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Assets/Scripts/XUtliPoolLib/XEngineCommand.cs | 84 ++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XEngineCommand.cs (limited to 'Client/Assets/Scripts/XUtliPoolLib/XEngineCommand.cs') diff --git a/Client/Assets/Scripts/XUtliPoolLib/XEngineCommand.cs b/Client/Assets/Scripts/XUtliPoolLib/XEngineCommand.cs new file mode 100644 index 00000000..42208a5d --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XEngineCommand.cs @@ -0,0 +1,84 @@ +using System; + +namespace XUtliPoolLib +{ + public class XEngineCommand : IQueueObject + { + public IQueueObject next { get; set; } + + public XGameObject gameObject = null; + + public ExecuteCommandHandler handler = null; + + public CanExecuteHandler canExecute = null; + + public XObjAsyncData data = null; + + public int objID = -1; + + public int commandID = -1; + + public static int globalCommandID = 0; + + public DebugHandler debugHandler = null; + + public int id = -1; + + public static int debugid = 0; + + public static bool debug = false; + + public bool IsValid() + { + return this.gameObject != null && this.gameObject.objID == this.objID; + } + + public void Execute() + { + bool flag = this.handler != null; + if (flag) + { + this.handler(this.gameObject, this); + } + } + + public void Reset() + { + this.objID = -1; + this.commandID = -1; + this.gameObject = null; + this.handler = null; + this.canExecute = null; + this.data = null; + this.id = -1; + this.debugHandler = null; + } + + public bool CanExecute() + { + bool flag = this.gameObject != null && this.gameObject.IsLoaded; + bool result; + if (flag) + { + bool flag2 = this.canExecute != null; + result = (!flag2 || this.canExecute(this.gameObject, this)); + } + else + { + result = false; + } + return result; + } + + public static int GetCommandID() + { + int result = XEngineCommand.globalCommandID++; + bool flag = XEngineCommand.globalCommandID > 1000000; + if (flag) + { + XEngineCommand.globalCommandID = 0; + } + return result; + } + } +} -- cgit v1.1-26-g67d0