summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/XNewItemTipsMgr.cs
blob: f2f9fd9320555c14cf6a12822ec7ca25b1d60a3f (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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
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);
		}
	}
}