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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
|
using System;
using System.Collections.Generic;
using KKSG;
using XMainClient.UI;
using XMainClient.UI.UICommon;
using XUtliPoolLib;
namespace XMainClient
{
internal class XTitleDocument : XDocComponent
{
public TitleDlg TitleView { get; set; }
public static uint TitleMaxLevel { get; private set; }
public bool bEnableTitleLevelUp
{
get
{
return this.m_enableTitleLevelUp;
}
set
{
this.m_enableTitleLevelUp = value;
XSingleton<XGameSysMgr>.singleton.RecalculateRedPointState(XSysDefine.XSys_Title, true);
}
}
public bool bAvaibleTitleIcon
{
get
{
return XSingleton<XGameSysMgr>.singleton.IsSystemOpen(XFastEnumIntEqualityComparer<XSysDefine>.ToInt(XSysDefine.XSys_Title));
}
}
public override uint ID
{
get
{
return XTitleDocument.uuID;
}
}
public uint CurrentTitleID
{
get
{
return XSingleton<XAttributeMgr>.singleton.XPlayerData.TitleID;
}
}
public TitleTable.RowData CurrentTitle
{
get
{
return XTitleDocument.GetTitle(this.CurrentTitleID);
}
}
public bool IsMax
{
get
{
return XTitleDocument.TitleMaxLevel <= this.CurrentTitleID;
}
}
public TitleTable.RowData NextTitle
{
get
{
bool flag = this.CurrentTitleID >= XTitleDocument.TitleMaxLevel;
TitleTable.RowData result;
if (flag)
{
result = null;
}
else
{
result = XTitleDocument.GetTitle(this.CurrentTitleID + 1u);
}
return result;
}
}
public new static readonly uint uuID = XSingleton<XCommon>.singleton.XHash("XTitleDocument");
public static XTableAsyncLoader AsyncLoader = new XTableAsyncLoader();
private static TitleTable m_TitleTable = new TitleTable();
public static int TITLE_FRAME_RATE = 10;
private static Dictionary<uint, Dictionary<uint, TitleTable.RowData>> m_cacheTitles = new Dictionary<uint, Dictionary<uint, TitleTable.RowData>>();
private bool m_enableTitleLevelUp = false;
public static string GetTitleWithFormat(uint titleID, string name)
{
string text = name;
bool flag = titleID > 0u;
if (flag)
{
TitleTable.RowData title = XTitleDocument.GetTitle(titleID);
bool flag2 = title != null;
if (flag2)
{
text = XSingleton<XCommon>.singleton.StringCombine(XLabelSymbolHelper.FormatAnimation(title.RankAtlas, title.RankIcon, 10), text);
}
}
return text;
}
public static TitleTable.RowData GetTitle(uint titleID)
{
Dictionary<uint, TitleTable.RowData> dictionary;
bool flag = XTitleDocument.m_cacheTitles.TryGetValue(XItemDrawerParam.DefaultProfession, out dictionary);
if (flag)
{
TitleTable.RowData result;
bool flag2 = dictionary.TryGetValue(titleID, out result);
if (flag2)
{
return result;
}
}
return null;
}
public bool TryGetTitle(uint titleID, out TitleTable.RowData rowData)
{
rowData = XTitleDocument.GetTitle(titleID);
return rowData != null;
}
protected override void OnReconnected(XReconnectedEventArgs arg)
{
}
public static void Execute(OnLoadedCallback callback = null)
{
XTitleDocument.AsyncLoader.AddTask("Table/TitleTable", XTitleDocument.m_TitleTable, false);
XTitleDocument.AsyncLoader.Execute(callback);
XTitleDocument.m_cacheTitles.Clear();
}
public static void OnTableLoaded()
{
int i = 0;
int num = XTitleDocument.m_TitleTable.Table.Length;
while (i < num)
{
Dictionary<uint, TitleTable.RowData> dictionary;
bool flag = !XTitleDocument.m_cacheTitles.TryGetValue(XTitleDocument.m_TitleTable.Table[i].BasicProfession, out dictionary);
if (flag)
{
dictionary = new Dictionary<uint, TitleTable.RowData>();
XTitleDocument.m_cacheTitles.Add(XTitleDocument.m_TitleTable.Table[i].BasicProfession, dictionary);
}
dictionary.Add(XTitleDocument.m_TitleTable.Table[i].RankID, XTitleDocument.m_TitleTable.Table[i]);
XTitleDocument.TitleMaxLevel = Math.Max(XTitleDocument.m_TitleTable.Table[i].RankID, XTitleDocument.TitleMaxLevel);
i++;
}
}
protected override void EventSubscribe()
{
base.EventSubscribe();
base.RegisterEvent(XEventDefine.XEvent_VirtualItemChanged, new XComponent.XEventHandler(this.OnVirtualItemChanged));
base.RegisterEvent(XEventDefine.XEvent_ItemChangeFinished, new XComponent.XEventHandler(this.OnVirtualItemChanged));
base.RegisterEvent(XEventDefine.XEvent_AttributeChange, new XComponent.XEventHandler(this.OnAttributeChange));
}
private bool OnAttributeChange(XEventArgs e)
{
bool flag = !this.bAvaibleTitleIcon;
bool result;
if (flag)
{
result = false;
}
else
{
XAttrChangeEventArgs xattrChangeEventArgs = e as XAttrChangeEventArgs;
bool flag2 = xattrChangeEventArgs.AttrKey == XAttributeDefine.XAttr_POWER_POINT_Basic;
if (flag2)
{
this.RefreshTitleLevelUp();
}
result = true;
}
return result;
}
private bool OnVirtualItemChanged(XEventArgs args)
{
bool flag = !this.bAvaibleTitleIcon;
bool result;
if (flag)
{
result = false;
}
else
{
this.RefreshTitleLevelUp();
result = true;
}
return result;
}
public void RefreshTitleLevelUp()
{
TitleTable.RowData nextTitle = this.NextTitle;
bool bEnableTitleLevelUp = true;
bool flag = nextTitle == null || nextTitle.NeedPowerPoint > XSingleton<XAttributeMgr>.singleton.XPlayerData.GetAttr(XAttributeDefine.XAttr_POWER_POINT_Basic);
if (flag)
{
bEnableTitleLevelUp = false;
}
else
{
int i = 0;
int count = nextTitle.NeedItem.Count;
while (i < count)
{
int num = (int)XBagDocument.BagDoc.GetItemCount((int)nextTitle.NeedItem[i, 0]);
bool flag2 = (long)num < (long)((ulong)nextTitle.NeedItem[i, 1]);
if (flag2)
{
bEnableTitleLevelUp = false;
break;
}
i++;
}
}
this.bEnableTitleLevelUp = bEnableTitleLevelUp;
bool flag3 = this.TitleView != null && this.TitleView.IsVisible();
if (flag3)
{
this.TitleView.Refresh();
}
}
public void GetTitleLevelUp()
{
bool flag = !this.bEnableTitleLevelUp;
if (!flag)
{
RpcC2G_TitleLevelUp rpc = new RpcC2G_TitleLevelUp();
XSingleton<XClientNetwork>.singleton.Send(rpc);
}
}
public void OnGetTitleLevelUp(TitleLevelUpRes oRes)
{
bool flag = oRes.errorcode > ErrorCode.ERR_SUCCESS;
if (flag)
{
XSingleton<UiUtility>.singleton.ShowSystemTip(oRes.errorcode, "fece00");
}
else
{
XSingleton<XAttributeMgr>.singleton.XPlayerData.TitleID = oRes.titleID;
XTitleInfoChange @event = XEventPool<XTitleInfoChange>.GetEvent();
@event.Firer = XSingleton<XEntityMgr>.singleton.Player;
XSingleton<XEventMgr>.singleton.FireEvent(@event);
this.RefreshTitleLevelUp();
bool flag2 = oRes.titleID > 0u && !DlgBase<TitleShareDlg, TitleShareBehaviour>.singleton.IsVisible();
if (flag2)
{
DlgBase<TitleShareDlg, TitleShareBehaviour>.singleton.SetVisibleWithAnimation(true, null);
}
}
}
public void TitleLevelChange(uint titleID)
{
bool flag = XSingleton<XAttributeMgr>.singleton.XPlayerData.TitleID != titleID;
if (flag)
{
XSingleton<XAttributeMgr>.singleton.XPlayerData.TitleID = titleID;
XTitleInfoChange @event = XEventPool<XTitleInfoChange>.GetEvent();
@event.Firer = XSingleton<XEntityMgr>.singleton.Player;
XSingleton<XEventMgr>.singleton.FireEvent(@event);
this.RefreshTitleLevelUp();
bool flag2 = titleID > 0u && !DlgBase<TitleShareDlg, TitleShareBehaviour>.singleton.IsVisible();
if (flag2)
{
DlgBase<TitleShareDlg, TitleShareBehaviour>.singleton.SetVisibleWithAnimation(true, null);
}
}
}
}
}
|