summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/XNewItemTipsMgr.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-01-25 14:28:30 +0800
committerchai <chaifix@163.com>2021-01-25 14:28:30 +0800
commit6eb915c129fc90c6f4c82ae097dd6ffad5239efc (patch)
tree7dd2be50edf41f36b60fac84696e731c13afe617 /Client/Assets/Scripts/XMainClient/XNewItemTipsMgr.cs
+scripts
Diffstat (limited to 'Client/Assets/Scripts/XMainClient/XNewItemTipsMgr.cs')
-rw-r--r--Client/Assets/Scripts/XMainClient/XNewItemTipsMgr.cs111
1 files changed, 111 insertions, 0 deletions
diff --git a/Client/Assets/Scripts/XMainClient/XNewItemTipsMgr.cs b/Client/Assets/Scripts/XMainClient/XNewItemTipsMgr.cs
new file mode 100644
index 00000000..f2f9fd93
--- /dev/null
+++ b/Client/Assets/Scripts/XMainClient/XNewItemTipsMgr.cs
@@ -0,0 +1,111 @@
+using System;
+using System.Collections.Generic;
+
+namespace XMainClient
+{
+ internal class XNewItemTipsMgr
+ {
+ public HashSet<ulong> NewItems
+ {
+ get
+ {
+ return this._NewItems;
+ }
+ }
+
+ public XItemFilter Filter
+ {
+ get
+ {
+ return this._Filter;
+ }
+ }
+
+ public bool bCanClear { get; set; }
+
+ public bool bHasNew
+ {
+ get
+ {
+ return this._NewItems.Count > 0;
+ }
+ }
+
+ private HashSet<ulong> _NewItems = new HashSet<ulong>();
+
+ private XItemFilter _Filter = new XItemFilter();
+
+ public void ClearItemType()
+ {
+ this.Clear();
+ this._Filter.Clear();
+ this.bCanClear = false;
+ }
+
+ public bool AddItem(XItem item, bool bDontSave = false)
+ {
+ bool flag = this._Filter.Contains(item.Type);
+ bool result;
+ if (flag)
+ {
+ bool flag2 = !bDontSave;
+ if (flag2)
+ {
+ this._NewItems.Add(item.uid);
+ }
+ result = true;
+ }
+ else
+ {
+ result = false;
+ }
+ return result;
+ }
+
+ public bool AddItems(List<XItem> items, bool bDontSave = false)
+ {
+ bool flag = false;
+ for (int i = 0; i < items.Count; i++)
+ {
+ flag = (this.AddItem(items[i], bDontSave) || flag);
+ }
+ return flag;
+ }
+
+ public bool RemoveItem(ulong uid, ItemType type, bool bConsiderFilter = false)
+ {
+ bool flag = this._Filter.Contains(type);
+ return flag && (this._NewItems.Remove(uid) || bConsiderFilter);
+ }
+
+ public bool RemoveItems(List<ulong> items, List<ItemType> types, bool bConsiderFilter = true)
+ {
+ bool flag = false;
+ for (int i = 0; i < items.Count; i++)
+ {
+ flag = (this.RemoveItem(items[i], types[i], bConsiderFilter) || flag);
+ }
+ return flag;
+ }
+
+ public void TryClear()
+ {
+ bool bCanClear = this.bCanClear;
+ if (bCanClear)
+ {
+ this.Clear();
+ }
+ }
+
+ public void Clear()
+ {
+ this._NewItems.Clear();
+ this.bCanClear = false;
+ }
+
+ public bool IsNew(ulong uid)
+ {
+ return this._NewItems.Contains(uid);
+ }
+ }
+}