From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- Client/Assets/Scripts/XMainClient/XEventBlocker.cs | 78 ++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XEventBlocker.cs (limited to 'Client/Assets/Scripts/XMainClient/XEventBlocker.cs') 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 where T : XEventArgs + { + public XEventBlocker.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.singleton.FireEvent(this.m_EventPool[i]); + } + this.m_EventPool.Clear(); + } + } + } + + private List m_EventPool = new List(); + + 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; + } + } +} -- cgit v1.1-26-g67d0