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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
|
using System;
using System.Collections.Generic;
using KKSG;
using MiniJSON;
using UnityEngine;
using XMainClient.UI;
using XMainClient.UI.UICommon;
using XUpdater;
using XUtliPoolLib;
namespace XMainClient
{
internal class XGuildDocument : XDocComponent
{
public override uint ID
{
get
{
return XGuildDocument.uuID;
}
}
public static XGuildConfig GuildConfig
{
get
{
return XGuildDocument._GuildConfig;
}
}
public static XGuildPP GuildPP
{
get
{
return XGuildDocument._GuildPP;
}
}
public static bool InGuild
{
get
{
XGuildDocument specificDocument = XDocuments.GetSpecificDocument<XGuildDocument>(XGuildDocument.uuID);
return specificDocument.bInGuild;
}
}
public XGuildBasicData BasicData
{
get
{
return this.m_BasicData;
}
}
public ulong UID
{
get
{
return this.m_BasicData.uid;
}
}
public GuildPosition Position
{
get
{
return this.m_Position;
}
}
public uint Level
{
get
{
return this.m_BasicData.level;
}
}
public uint CurSkillUpCount
{
get
{
return 0u;
}
}
public uint MaxSkillUpCount
{
get
{
bool flag = !this.bInGuild;
uint result;
if (flag)
{
result = 0u;
}
else
{
result = XGuildDocument.GuildConfig.GetDataByLevel(this.Level).StudySkillTimes;
}
return result;
}
}
public string PortraitSprite
{
get
{
return XGuildDocument.GetPortraitName(this.m_BasicData.portraitIndex);
}
}
public uint CurrentCanUseExp
{
get
{
return 0u;
}
}
public uint CurrentTotalExp
{
get
{
bool flag = !this.bInGuild;
uint result;
if (flag)
{
result = 0u;
}
else
{
result = XGuildDocument.GuildConfig.GetBaseExp(this.Level) + this.m_BasicData.exp;
}
return result;
}
}
public uint CurrentLevelTotalExp
{
get
{
bool flag = !this.bInGuild;
uint result;
if (flag)
{
result = 0u;
}
else
{
result = XGuildDocument.GuildConfig.GetBaseExp(this.Level) + this.m_BasicData.exp;
}
return result;
}
}
public bool bInGuild
{
get
{
return this.UID > 0UL;
}
}
public new static readonly uint uuID = XSingleton<XCommon>.singleton.XHash("GuildDocument");
public static XTableAsyncLoader AsyncLoader = new XTableAsyncLoader();
private static GuildPermissionTable m_PermissionTable = new GuildPermissionTable();
private static GuildConfigTable m_ConfigTable = new GuildConfigTable();
private static Guildintroduce m_IntroduceTable = new Guildintroduce();
private static XGuildConfig _GuildConfig = new XGuildConfig();
private static XGuildPP _GuildPP = new XGuildPP();
private XGuildBasicData m_BasicData = new XGuildBasicData();
private bool _bInited = false;
private GuildPosition m_Position;
private float m_fEnterTime = 0f;
public GuildBindStatus qqGroupBindStatus;
public string qqGroupName;
public static string GetPortraitName(int index)
{
return "ghicon_" + index.ToString();
}
public bool SetID(ulong id)
{
bool flag = !this._bInited || this.m_BasicData.uid != id;
this.m_BasicData.uid = id;
bool flag2 = flag;
if (flag2)
{
bool bInGuild = this.bInGuild;
if (bInGuild)
{
try
{
}
catch
{
}
}
}
return flag;
}
public bool SetLevel(uint newLevel)
{
bool result = this.m_BasicData.level != 0u && this.m_BasicData.level != newLevel && this.m_BasicData.uid > 0UL;
this.m_BasicData.level = newLevel;
return result;
}
public bool SetPosition(GuildPosition newPos)
{
bool result = this.m_Position != GuildPosition.GPOS_COUNT && this.m_Position != newPos && this.m_BasicData.uid > 0UL;
this.m_Position = newPos;
return result;
}
public Guildintroduce.RowData GetIntroduce(string helpName)
{
return XGuildDocument.m_IntroduceTable.GetByHelpName(helpName);
}
public static void Execute(OnLoadedCallback callback = null)
{
XGuildDocument.AsyncLoader.AddTask("Table/GuildPermission", XGuildDocument.m_PermissionTable, false);
XGuildDocument.AsyncLoader.AddTask("Table/GuildConfig", XGuildDocument.m_ConfigTable, false);
XGuildDocument.AsyncLoader.AddTask("Table/GuildIntroduce", XGuildDocument.m_IntroduceTable, false);
XGuildDocument.AsyncLoader.Execute(callback);
}
public override void OnAttachToHost(XObject host)
{
base.OnAttachToHost(host);
this._bInited = false;
this.m_Position = GuildPosition.GPOS_COUNT;
this.m_BasicData.uid = 0UL;
this.m_BasicData.level = 0u;
}
protected override void EventSubscribe()
{
base.EventSubscribe();
base.RegisterEvent(XEventDefine.XEvent_InGuildStateChanged, new XComponent.XEventHandler(this.OnInGuildStateChanged));
base.RegisterEvent(XEventDefine.XEvent_GuildPositionChanged, new XComponent.XEventHandler(this.OnGuildPositionChanged));
}
protected bool OnInGuildStateChanged(XEventArgs args)
{
XInGuildStateChangedEventArgs xinGuildStateChangedEventArgs = args as XInGuildStateChangedEventArgs;
bool bRoleInit = xinGuildStateChangedEventArgs.bRoleInit;
bool result;
if (bRoleInit)
{
result = true;
}
else
{
bool flag = !xinGuildStateChangedEventArgs.bIsEnter;
if (flag)
{
XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("GUILD_EXIT_GUILD"), "fece00");
}
else
{
XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("GUILD_JOIN_GUILD"), "fece00");
}
result = true;
}
return result;
}
protected bool OnGuildPositionChanged(XEventArgs args)
{
XSingleton<UiUtility>.singleton.ShowModalDialog(XStringDefineProxy.GetString("GUILD_POSITION_CHANGED", new object[]
{
XGuildDocument.GuildPP.GetPositionName(this.m_Position, false)
}), XStringDefineProxy.GetString(XStringDefine.COMMON_OK));
return true;
}
public void InitData(PtcM2C_LoginGuildInfo data)
{
bool flag = this.SetID(data.Data.gid);
bool flag2 = this.SetPosition((GuildPosition)data.Data.position);
this.m_BasicData.portraitIndex = (int)data.Data.icon;
bool flag3 = this.SetLevel((uint)data.Data.level);
this.m_BasicData.guildName = data.Data.name;
this.QueryWXGroup();
this.QueryQQGroup();
bool flag4 = flag;
if (flag4)
{
XInGuildStateChangedEventArgs @event = XEventPool<XInGuildStateChangedEventArgs>.GetEvent();
@event.bIsEnter = this.bInGuild;
@event.bRoleInit = !this._bInited;
@event.Firer = XSingleton<XGame>.singleton.Doc;
XSingleton<XEventMgr>.singleton.FireEvent(@event);
}
bool flag5 = flag2;
if (flag5)
{
XGuildPositionChangedEventArgs event2 = XEventPool<XGuildPositionChangedEventArgs>.GetEvent();
event2.position = this.m_Position;
event2.Firer = XSingleton<XGame>.singleton.Doc;
XSingleton<XEventMgr>.singleton.FireEvent(event2);
}
bool flag6 = flag3;
if (flag6)
{
XGuildLevelChangedEventArgs event3 = XEventPool<XGuildLevelChangedEventArgs>.GetEvent();
event3.level = this.m_BasicData.level;
event3.Firer = XSingleton<XGame>.singleton.Doc;
XSingleton<XEventMgr>.singleton.FireEvent(event3);
}
XGuildInfoChange event4 = XEventPool<XGuildInfoChange>.GetEvent();
event4.Firer = XSingleton<XEntityMgr>.singleton.Player;
XSingleton<XEventMgr>.singleton.FireEvent(event4);
XGuildInfoChange event5 = XEventPool<XGuildInfoChange>.GetEvent();
event5.Firer = XSingleton<XGame>.singleton.Doc;
XSingleton<XEventMgr>.singleton.FireEvent(event5);
this._bInited = true;
}
public static void OnTableLoaded()
{
XGuildDocument.GuildPP.InitTable(XGuildDocument.m_PermissionTable);
XGuildDocument.GuildConfig.Init(XGuildDocument.m_ConfigTable);
}
private bool _CanEnter()
{
float time = Time.time;
bool flag = time - this.m_fEnterTime > 3f;
bool result;
if (flag)
{
this.m_fEnterTime = time;
result = true;
}
else
{
result = false;
}
return result;
}
public GuildSceneState TryEnterGuildScene()
{
bool bInGuild = this.bInGuild;
GuildSceneState result;
if (bInGuild)
{
SceneType sceneType = XSingleton<XScene>.singleton.SceneType;
bool flag = sceneType == SceneType.SCENE_GUILD_HALL;
if (flag)
{
result = GuildSceneState.GSS_InGuildScene;
}
else
{
bool flag2 = !this._CanEnter();
if (flag2)
{
result = GuildSceneState.GSS_NotGuildScene;
}
else
{
HomePlantDocument.Doc.GardenId = this.UID;
PtcC2G_EnterSceneReq ptcC2G_EnterSceneReq = new PtcC2G_EnterSceneReq();
ptcC2G_EnterSceneReq.Data.sceneID = (uint)XSingleton<XGlobalConfig>.singleton.GetInt("GuildHallSceneID");
ptcC2G_EnterSceneReq.Data.roleID = this.UID;
XSingleton<XClientNetwork>.singleton.Send(ptcC2G_EnterSceneReq);
result = GuildSceneState.GSS_NotGuildScene;
}
}
}
else
{
bool flag3 = !DlgBase<XGuildListView, XGuildListBehaviour>.singleton.IsVisible();
if (flag3)
{
DlgBase<XGuildListView, XGuildListBehaviour>.singleton.SetVisibleWithAnimation(true, null);
}
result = GuildSceneState.GSS_NoPermission;
}
return result;
}
public void TryShowGuildHallUI()
{
bool bInGuild = this.bInGuild;
if (bInGuild)
{
DlgBase<XGuildHallView, XGuildHallBehaviour>.singleton.SetVisibleWithAnimation(true, null);
}
else
{
bool flag = !DlgBase<XGuildListView, XGuildListBehaviour>.singleton.IsVisible();
if (flag)
{
DlgBase<XGuildListView, XGuildListBehaviour>.singleton.SetVisibleWithAnimation(true, null);
}
}
}
protected override void OnReconnected(XReconnectedEventArgs arg)
{
}
public override void OnEnterSceneFinally()
{
bool flag = XSingleton<XScene>.singleton.SceneType == SceneType.SCENE_GUILD_HALL;
if (flag)
{
HomePlantDocument doc = HomePlantDocument.Doc;
doc.ClearFarmInfo();
doc.HomeSprite.ClearInfo();
HomePlantDocument.Doc.GardenId = this.UID;
doc.FetchPlantInfo(0u);
}
base.OnEnterSceneFinally();
}
public bool IHavePermission(GuildPermission pem)
{
return XGuildDocument.GuildPP.HasPermission(this.m_Position, pem);
}
public bool CheckPermission(GuildPermission pem)
{
bool flag = !this.CheckInGuild();
bool result;
if (flag)
{
result = false;
}
else
{
bool flag2 = this.IHavePermission(pem);
if (flag2)
{
result = true;
}
else
{
XSingleton<UiUtility>.singleton.ShowSystemTip(ErrorCode.ERR_GUILD_NO_PERMISSION, "fece00");
result = false;
}
}
return result;
}
public bool CheckUnlockLevel(XSysDefine sys)
{
bool flag = !this.CheckInGuild();
bool result;
if (flag)
{
result = false;
}
else
{
uint unlockLevel = XGuildDocument.GuildConfig.GetUnlockLevel(sys);
bool flag2 = this.Level >= unlockLevel;
if (flag2)
{
result = true;
}
else
{
XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("OPEN_AT_GUILD_LEVEL", new object[]
{
unlockLevel
}), "fece00");
result = false;
}
}
return result;
}
public bool IsSysUnlocked(XSysDefine sys)
{
bool flag = !this.bInGuild;
bool result;
if (flag)
{
result = false;
}
else
{
uint unlockLevel = XGuildDocument.GuildConfig.GetUnlockLevel(sys);
bool flag2 = this.Level >= unlockLevel;
result = flag2;
}
return result;
}
public bool CheckInGuild()
{
bool bInGuild = this.bInGuild;
bool result;
if (bInGuild)
{
result = true;
}
else
{
XSingleton<UiUtility>.singleton.ShowSystemTip(ErrorCode.ERR_GUILD_NOT_IN_GUILD, "fece00");
result = false;
}
return result;
}
public static void OnGuildHyperLinkClick(string param)
{
bool flag = XSingleton<XGame>.singleton.CurrentStage.Stage != EXStage.Hall;
if (!flag)
{
ulong id = 0UL;
bool flag2 = XLabelSymbolHelper.ParseGuildParam(param, ref id);
if (flag2)
{
bool flag3 = XSingleton<XGameSysMgr>.singleton.IsSystemOpened(XSysDefine.XSys_Guild);
if (flag3)
{
XGuildViewDocument specificDocument = XDocuments.GetSpecificDocument<XGuildViewDocument>(XGuildViewDocument.uuID);
specificDocument.View(id);
}
else
{
XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("GUILD_LOG_CANNOT_JOIN"), "fece00");
}
}
}
}
public void QueryWXGroup()
{
bool flag = XSingleton<XLoginDocument>.singleton.Channel != XAuthorizationChannel.XAuthorization_WeChat || !XSingleton<XGameSysMgr>.singleton.IsSystemOpened(XSysDefine.XSys_Guild_Bind_Group);
if (!flag)
{
XSingleton<PDatabase>.singleton.wxGroupCallbackType = WXGroupCallBackType.Guild;
Dictionary<string, string> dictionary = new Dictionary<string, string>();
dictionary["unionID"] = this.UID.ToString();
dictionary["openIdList"] = XSingleton<XLoginDocument>.singleton.OpenID;
string param = Json.Serialize(dictionary);
XSingleton<XUpdater.XUpdater>.singleton.XPlatform.QueryWXGroup(param);
}
}
public void QueryQQGroup()
{
bool flag = XSingleton<XLoginDocument>.singleton.Channel != XAuthorizationChannel.XAuthorization_QQ || !XSingleton<XGameSysMgr>.singleton.IsSystemOpened(XSysDefine.XSys_Guild_Bind_Group);
if (!flag)
{
RpcC2M_GetGuildBindInfo rpcC2M_GetGuildBindInfo = new RpcC2M_GetGuildBindInfo();
rpcC2M_GetGuildBindInfo.oArg.token = XSingleton<XLoginDocument>.singleton.TokenCache;
XSingleton<XClientNetwork>.singleton.Send(rpcC2M_GetGuildBindInfo);
XSingleton<XDebug>.singleton.AddLog("[QQGroup QueryQQGroup]token:" + XSingleton<XLoginDocument>.singleton.TokenCache, null, null, null, null, null, XDebugColor.XDebug_None);
}
}
public void OnGetQQGroupBindInfo(GetGuildBindInfoReq oArg, GetGuildBindInfoRes oRes)
{
bool flag = oRes.result > ErrorCode.ERR_SUCCESS;
if (!flag)
{
this.qqGroupBindStatus = oRes.bind_status;
this.qqGroupName = oRes.group_name;
bool flag2 = DlgBase<XGuildHallView, XGuildHallBehaviour>.singleton.IsVisible();
if (flag2)
{
DlgBase<XGuildHallView, XGuildHallBehaviour>.singleton.RefreshQQGroupBtn();
}
}
}
public void BindQQGroup()
{
bool flag = XSingleton<XLoginDocument>.singleton.Channel != XAuthorizationChannel.XAuthorization_QQ || !XSingleton<XGameSysMgr>.singleton.IsSystemOpened(XSysDefine.XSys_Guild_Bind_Group);
if (!flag)
{
RpcC2M_GuildBindGroup rpcC2M_GuildBindGroup = new RpcC2M_GuildBindGroup();
rpcC2M_GuildBindGroup.oArg.token = XSingleton<XLoginDocument>.singleton.TokenCache;
XSingleton<XClientNetwork>.singleton.Send(rpcC2M_GuildBindGroup);
XSingleton<XDebug>.singleton.AddLog("[QQGroup BindQQGroup]token:" + XSingleton<XLoginDocument>.singleton.TokenCache, null, null, null, null, null, XDebugColor.XDebug_None);
}
}
public void OnBindQQGroup(GuildBindGroupReq oArg, GuildBindGroupRes oRes)
{
bool flag = oRes.result > ErrorCode.ERR_SUCCESS;
if (flag)
{
XSingleton<UiUtility>.singleton.ShowErrorCode(oRes.result);
}
else
{
XSingleton<UiUtility>.singleton.ShowSystemTip(XSingleton<XStringTable>.singleton.GetString("GUILD_BIN_QQ_GROUP_SUC"), "fece00");
this.qqGroupName = oRes.group_name;
this.qqGroupBindStatus = GuildBindStatus.GBS_Owner;
bool flag2 = DlgBase<XGuildHallView, XGuildHallBehaviour>.singleton.IsVisible();
if (flag2)
{
DlgBase<XGuildHallView, XGuildHallBehaviour>.singleton.RefreshQQGroupBtn();
}
}
}
public void JoinQQGroup()
{
bool flag = XSingleton<XLoginDocument>.singleton.Channel != XAuthorizationChannel.XAuthorization_QQ || !XSingleton<XGameSysMgr>.singleton.IsSystemOpened(XSysDefine.XSys_Guild_Bind_Group);
if (!flag)
{
RpcC2M_GuildJoinBindGroup rpcC2M_GuildJoinBindGroup = new RpcC2M_GuildJoinBindGroup();
rpcC2M_GuildJoinBindGroup.oArg.token = XSingleton<XLoginDocument>.singleton.TokenCache;
XSingleton<XClientNetwork>.singleton.Send(rpcC2M_GuildJoinBindGroup);
XSingleton<XDebug>.singleton.AddLog("[QQGroup JoinQQGroup]token:" + XSingleton<XLoginDocument>.singleton.TokenCache, null, null, null, null, null, XDebugColor.XDebug_None);
}
}
public void OnJoinBindQQGroup(GuildJoinBindGroupReq oArg, GuildJoinBindGroupRes oRes)
{
bool flag = oRes.result > ErrorCode.ERR_SUCCESS;
if (flag)
{
XSingleton<UiUtility>.singleton.ShowErrorCode(oRes.result);
}
else
{
XSingleton<UiUtility>.singleton.ShowSystemTip(XSingleton<XStringTable>.singleton.GetString("GUILD_JOIN_QQ_GROUP_SUC"), "fece00");
this.qqGroupBindStatus = GuildBindStatus.GBS_Member;
bool flag2 = DlgBase<XGuildHallView, XGuildHallBehaviour>.singleton.IsVisible();
if (flag2)
{
DlgBase<XGuildHallView, XGuildHallBehaviour>.singleton.RefreshQQGroupBtn();
}
}
}
public void UnbindQQGroup()
{
bool flag = XSingleton<XLoginDocument>.singleton.Channel != XAuthorizationChannel.XAuthorization_QQ || !XSingleton<XGameSysMgr>.singleton.IsSystemOpened(XSysDefine.XSys_Guild_Bind_Group);
if (!flag)
{
RpcC2M_GuildUnBindGroup rpcC2M_GuildUnBindGroup = new RpcC2M_GuildUnBindGroup();
rpcC2M_GuildUnBindGroup.oArg.token = XSingleton<XLoginDocument>.singleton.TokenCache;
XSingleton<XClientNetwork>.singleton.Send(rpcC2M_GuildUnBindGroup);
XSingleton<XDebug>.singleton.AddLog("[QQGroup UnbindQQGroup]token:" + XSingleton<XLoginDocument>.singleton.TokenCache, null, null, null, null, null, XDebugColor.XDebug_None);
}
}
public void OnUnbindQQGroup(GuildUnBindGroupReq oArg, GuildUnBindGroupRes oRes)
{
bool flag = oRes.result > ErrorCode.ERR_SUCCESS;
if (flag)
{
XSingleton<UiUtility>.singleton.ShowErrorCode(oRes.result);
}
else
{
XSingleton<UiUtility>.singleton.ShowSystemTip(XSingleton<XStringTable>.singleton.GetString("GUILD_UNBIND_QQ_GROUP_SUC"), "fece00");
this.qqGroupBindStatus = GuildBindStatus.GBS_NotBind;
bool flag2 = DlgBase<XGuildHallView, XGuildHallBehaviour>.singleton.IsVisible();
if (flag2)
{
DlgBase<XGuildHallView, XGuildHallBehaviour>.singleton.RefreshQQGroupBtn();
}
}
}
}
}
|