summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XUtliPoolLib/XEngineCommand.cs
blob: 42208a5d110844809107cfc09ef046ab7b41c700 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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;
		}
	}
}