summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/XEventBlocker.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Client/Assets/Scripts/XMainClient/XEventBlocker.cs')
-rw-r--r--Client/Assets/Scripts/XMainClient/XEventBlocker.cs78
1 files changed, 78 insertions, 0 deletions
diff --git a/Client/Assets/Scripts/XMainClient/XEventBlocker.cs b/Client/Assets/Scripts/XMainClient/XEventBlocker.cs
new file mode 100644
index 00000000..a38bce1f
--- /dev/null
+++ b/Client/Assets/Scripts/XMainClient/XEventBlocker.cs
@@ -0,0 +1,78 @@
+using System;
+using System.Collections.Generic;
+using XUtliPoolLib;
+
+namespace XMainClient
+{
+ internal class XEventBlocker<T> where T : XEventArgs
+ {
+ public XEventBlocker<T>.XEventHandler EventHandler { get; set; }
+
+ public bool bBlockReceiver
+ {
+ get
+ {
+ return this.m_bBlockReceiver;
+ }
+ set
+ {
+ this.m_bBlockReceiver = value;
+ bool flag = !this.m_bBlockReceiver;
+ if (flag)
+ {
+ for (int i = 0; i < this.m_EventPool.Count; i++)
+ {
+ bool flag2 = this.EventHandler != null;
+ if (flag2)
+ {
+ this.EventHandler(this.m_EventPool[i]);
+ }
+ this.m_EventPool[i].Recycle();
+ }
+ this.m_EventPool.Clear();
+ }
+ }
+ }
+
+ public bool bBlockSender
+ {
+ get
+ {
+ return this.m_bBlockSender;
+ }
+ set
+ {
+ this.m_bBlockSender = value;
+ bool flag = !this.m_bBlockSender;
+ if (flag)
+ {
+ for (int i = 0; i < this.m_EventPool.Count; i++)
+ {
+ XSingleton<XEventMgr>.singleton.FireEvent(this.m_EventPool[i]);
+ }
+ this.m_EventPool.Clear();
+ }
+ }
+ }
+
+ private List<T> m_EventPool = new List<T>();
+
+ private bool m_bBlockReceiver = false;
+
+ private bool m_bBlockSender = false;
+
+ public delegate bool XEventHandler(XEventArgs e);
+
+ public void AddEvent(T e)
+ {
+ this.m_EventPool.Add(e);
+ }
+
+ public void ClearEvents()
+ {
+ this.m_EventPool.Clear();
+ this.m_bBlockReceiver = false;
+ this.m_bBlockSender = false;
+ }
+ }
+}