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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
using System;
using System.Collections.Generic;
using UnityEngine;
namespace XUtliPoolLib
{
public class XRedpointMgr : XRedpointForbidMgr, IXRedpointMgr, IXRedpointRelationMgr, IXRedpointForbidMgr
{
protected Dictionary<int, XRedpointMgr.stRedpointGameObject[]> mSysGameObjectListDic = new Dictionary<int, XRedpointMgr.stRedpointGameObject[]>();
protected struct stRedpointGameObject
{
public static readonly XRedpointMgr.stRedpointGameObject Empty;
public GameObject go;
public SetRedpointUIHandler callback;
}
public void AddSysRedpointUI(int sys, GameObject go, SetRedpointUIHandler callback = null)
{
bool flag = null == go;
if (!flag)
{
XRedpointMgr.stRedpointGameObject[] array = null;
bool flag2 = this.mSysGameObjectListDic.TryGetValue(sys, out array);
if (flag2)
{
bool flag3 = this._InsertObject(ref array, go, callback);
if (flag3)
{
this.mSysGameObjectListDic[sys] = array;
}
}
else
{
array = new XRedpointMgr.stRedpointGameObject[4];
array[0].go = go;
array[0].callback = callback;
this.mSysGameObjectListDic[sys] = array;
}
go.SetActive(base._GetSysRedpointState(sys));
}
}
public void RemoveSysRedpointUI(int sys, GameObject go)
{
bool flag = null == go;
if (!flag)
{
XRedpointMgr.stRedpointGameObject[] array = null;
bool flag2 = this.mSysGameObjectListDic.TryGetValue(sys, out array);
if (flag2)
{
this._DeleteObject(ref array, go);
}
}
}
public void RemoveAllSysRedpointsUI(int sys)
{
this.mSysGameObjectListDic.Remove(sys);
}
public void ClearAllSysRedpointsUI()
{
this.mSysGameObjectListDic.Clear();
}
public void SetSysRedpointState(int sys, bool redpoint, bool immediately = false)
{
bool flag = true;
bool flag3;
bool flag2 = this.mSysRedpointStateDic.TryGetValue(sys, out flag3);
if (flag2)
{
flag = (flag3 != redpoint);
}
this.mSysRedpointStateDic[sys] = redpoint;
bool flag4 = flag;
if (flag4)
{
if (immediately)
{
this._RefreshSysRedpointUI(sys, redpoint);
this._RecalculateRedPointParentStates(sys, immediately);
}
else
{
this.mDirtySysList.Add(sys);
}
}
}
public override void RefreshAllSysRedpoints()
{
foreach (int sys in this.mDirtySysList)
{
this._RefreshSysRedpointUI(sys, base._GetSysRedpointState(sys));
}
this.mDirtySysList.Clear();
}
public override void RecalculateRedPointSelfState(int sys, bool bImmUpdateUI = true)
{
bool flag = false;
int[] array = null;
bool flag2 = this.mParentChildRelationDic.TryGetValue(sys, out array);
if (flag2)
{
int num = 0;
while (num < array.Length && array[num] == 0 && !flag)
{
flag = (flag || base._GetSysRedpointState(array[num]));
num++;
}
}
bool flag3 = flag != base._GetSysRedpointState(sys);
if (flag3)
{
this.mSysRedpointStateDic[sys] = flag;
if (bImmUpdateUI)
{
this._RefreshSysRedpointUI(sys, flag);
}
else
{
this.mDirtySysList.Add(sys);
}
}
}
protected void _RecalculateRedPointParentStates(int child, bool bImmUpdateUI = true)
{
bool flag = base._GetSysRedpointState(child);
bool flag2 = flag;
if (flag2)
{
int[] array = null;
bool flag3 = this.mChildParentRelationDic.TryGetValue(child, out array);
if (flag3)
{
int num = 0;
while (num < array.Length && array[num] != 0)
{
this.SetSysRedpointState(array[num], true, bImmUpdateUI);
num++;
}
}
}
}
protected override void _RefreshSysRedpointUI(int sys, bool redpoint)
{
bool flag = redpoint;
if (flag)
{
bool flag2 = this.mForbidHashSet.Contains(sys);
if (flag2)
{
redpoint = false;
}
}
XRedpointMgr.stRedpointGameObject[] array = null;
bool flag3 = this.mSysGameObjectListDic.TryGetValue(sys, out array);
if (flag3)
{
int num = 0;
while (num < array.Length && null != array[num].go)
{
bool flag4 = array[num].callback == null;
if (flag4)
{
array[num].go.SetActive(redpoint);
}
else
{
array[num].callback(array[num].go);
}
num++;
}
}
this.mDirtySysList.Remove(sys);
}
protected bool _InsertObject(ref XRedpointMgr.stRedpointGameObject[] array, GameObject go, SetRedpointUIHandler callback)
{
for (int i = 0; i < array.Length; i++)
{
bool flag = null == array[i].go || array[i].go == go;
if (flag)
{
array[i].go = go;
array[i].callback = callback;
return false;
}
}
XRedpointMgr.stRedpointGameObject[] array2 = new XRedpointMgr.stRedpointGameObject[array.Length << 1];
array.CopyTo(array2, 0);
array2[array.Length].go = go;
array2[array.Length].callback = callback;
array = array2;
return true;
}
protected void _DeleteObject(ref XRedpointMgr.stRedpointGameObject[] array, GameObject parent)
{
for (int i = 0; i < array.Length; i++)
{
bool flag = array[i].go == parent;
if (flag)
{
XRedpointMgr.stRedpointGameObject stRedpointGameObject = default(XRedpointMgr.stRedpointGameObject);
bool flag2 = i + 1 < array.Length;
if (flag2)
{
for (int j = array.Length - 1; j > i; j--)
{
bool flag3 = null != array[j].go;
if (flag3)
{
stRedpointGameObject = array[j];
array[j] = default(XRedpointMgr.stRedpointGameObject);
break;
}
}
}
array[i] = stRedpointGameObject;
}
}
}
}
}
|