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
|
using System;
using System.Collections.Generic;
using KKSG;
using UILib;
using XUtliPoolLib;
namespace XMainClient
{
internal class XReconnection : XSingleton<XReconnection>
{
public uint SceneID
{
get
{
return this._scene_id;
}
}
public DeathInfo PlayerDeathinfo
{
get
{
return this._player_death_info;
}
}
public RoleAllInfo PlayerInfo
{
get
{
return this._player_info;
}
}
public UnitAppearance PlayerApperance
{
get
{
return this._player_appearance;
}
}
public Dictionary<ulong, UnitAppearance> UnitsAppearance
{
get
{
return this._units_appearance;
}
}
public bool IsAutoFight
{
get
{
return this._is_auto_fight;
}
}
public bool IsLoginReconnect
{
get
{
return this._is_login_reconnect;
}
}
private uint _scene_id;
private DeathInfo _player_death_info = null;
private RoleAllInfo _player_info = null;
private UnitAppearance _player_appearance = null;
private Dictionary<ulong, UnitAppearance> _units_appearance = new Dictionary<ulong, UnitAppearance>();
private bool _is_auto_fight;
private bool _is_login_reconnect;
public void SetLoginReconnectFlag(bool flag)
{
this._is_login_reconnect = flag;
}
private bool IsValid(UnitAppearance unit)
{
return unit != null && unit.position.x >= XCommon.XEps && unit.position.z >= XCommon.XEps;
}
private bool IsPupet(uint specialstate)
{
return ((ulong)specialstate & (ulong)(1L << (XFastEnumIntEqualityComparer<UnitSpecialState>.ToInt(UnitSpecialState.Unit_Puppet) & 31))) > 0UL;
}
public void GetReconnectData(PtcG2C_ReconnectSyncNotify data)
{
this._scene_id = ((data.Data.scene == null) ? 1u : data.Data.scene.sceneid);
this._player_death_info = data.Data.deathinfo;
this._player_info = data.Data.self;
this._player_appearance = data.Data.selfAppearance;
this._is_auto_fight = data.Data.isautofight;
XSingleton<XScene>.singleton.SceneStarted = (data.Data.scene == null || data.Data.scene.isready);
this._units_appearance.Clear();
bool flag = !XSingleton<XScene>.singleton.bSpectator;
if (flag)
{
bool flag2 = this.IsValid(this._player_appearance);
if (flag2)
{
this._units_appearance.Add(this._player_appearance.uID, this._player_appearance);
}
}
for (int i = 0; i < data.Data.units.Count; i++)
{
bool flag3 = !this._units_appearance.ContainsKey(data.Data.units[i].uID);
if (flag3)
{
this._units_appearance.Add(data.Data.units[i].uID, data.Data.units[i]);
}
else
{
XSingleton<XDebug>.singleton.AddErrorLog("Reconnect have same key ", data.Data.units[i].uID.ToString(), null, null, null, null);
}
}
this.StartReconnectSync();
}
private void StartReconnectSync()
{
bool flag = XSingleton<XScene>.singleton.SceneID != this._scene_id || !XSingleton<XScene>.singleton.SceneReady;
if (flag)
{
bool bSceneLoadedRpcSend = XSingleton<XScene>.singleton.bSceneLoadedRpcSend;
if (bSceneLoadedRpcSend)
{
RpcC2G_DoEnterScene rpcC2G_DoEnterScene = new RpcC2G_DoEnterScene();
rpcC2G_DoEnterScene.oArg.sceneid = XSingleton<XScene>.singleton.SceneID;
XSingleton<XClientNetwork>.singleton.Send(rpcC2G_DoEnterScene);
}
}
else
{
this.SyncData();
}
}
private void SyncData()
{
bool syncMode = XSingleton<XGame>.singleton.SyncMode;
if (syncMode)
{
bool flag = XSingleton<XEntityMgr>.singleton.Player != null && this._player_death_info != null;
if (flag)
{
XReviveDocument specificDocument = XDocuments.GetSpecificDocument<XReviveDocument>(XReviveDocument.uuID);
specificDocument.SetReviveData((int)this._player_death_info.revivecount, (int)this._player_death_info.costrevivecount, this._player_death_info.type);
}
XSingleton<XEntityMgr>.singleton.OnReconnect();
XSingleton<XAttributeMgr>.singleton.OnReconnect();
XSingleton<XLevelDoodadMgr>.singleton.OnReconnect();
}
bool flag2 = !this.IsPupet(this._player_appearance.specialstate);
if (flag2)
{
XSingleton<XCutScene>.singleton.Stop(true);
}
bool flag3 = !XSingleton<XScene>.singleton.bSpectator;
if (flag3)
{
XSingleton<XEntityMgr>.singleton.Player.UpdateSpecialStateFromServer(this._player_appearance.specialstate, uint.MaxValue);
}
XReconnectedEventArgs @event = XEventPool<XReconnectedEventArgs>.GetEvent();
@event.Firer = XSingleton<XGame>.singleton.Doc;
@event.PlayerInfo = this._player_info;
@event.PlayUnit = this._player_appearance;
XSingleton<XEventMgr>.singleton.FireEvent(@event);
}
public void StartEnterSceneSync(List<UnitAppearance> units)
{
bool flag = units.Count == 0;
if (!flag)
{
this._units_appearance.Clear();
bool flag2 = !XSingleton<XScene>.singleton.bSpectator;
if (flag2)
{
bool flag3 = this.IsValid(this._player_appearance);
if (flag3)
{
this._units_appearance.Add(XSingleton<XEntityMgr>.singleton.Player.ID, this._player_appearance);
}
}
for (int i = 0; i < units.Count; i++)
{
bool flag4 = !this._units_appearance.ContainsKey(units[i].uID);
if (flag4)
{
this._units_appearance.Add(units[i].uID, units[i]);
}
else
{
XSingleton<XDebug>.singleton.AddErrorLog("Reconnect have same key ", units[i].uID.ToString(), null, null, null, null);
}
}
bool syncMode = XSingleton<XGame>.singleton.SyncMode;
if (syncMode)
{
XSingleton<XEntityMgr>.singleton.OnReconnect();
}
}
}
public void SetPlayerInfo(RoleAllInfo info)
{
this._player_info = info;
}
public void StartLoginReconnectSync(LoginReconnectEnterSceneData data, List<UnitAppearance> units)
{
bool flag = data == null;
if (!flag)
{
this._scene_id = XSingleton<XScene>.singleton.SceneID;
this._player_death_info = data.deathinfo;
this._player_appearance = data.selfAppearance;
this._is_auto_fight = data.isautofight;
XSingleton<XScene>.singleton.SceneStarted = true;
bool flag2 = XSingleton<XEntityMgr>.singleton.Player != null && data.deathinfo != null;
if (flag2)
{
XReviveDocument specificDocument = XDocuments.GetSpecificDocument<XReviveDocument>(XReviveDocument.uuID);
specificDocument.SetReviveData((int)data.deathinfo.revivecount, (int)data.deathinfo.costrevivecount, data.deathinfo.type);
}
this._units_appearance.Clear();
bool flag3 = !XSingleton<XScene>.singleton.bSpectator;
if (flag3)
{
bool flag4 = this.IsValid(this._player_appearance);
if (flag4)
{
this._units_appearance.Add(this._player_appearance.uID, this._player_appearance);
}
}
for (int i = 0; i < units.Count; i++)
{
bool flag5 = !this._units_appearance.ContainsKey(units[i].uID);
if (flag5)
{
this._units_appearance.Add(units[i].uID, units[i]);
}
else
{
XSingleton<XDebug>.singleton.AddErrorLog("Reconnect have same key ", units[i].uID.ToString(), null, null, null, null);
}
}
this.SyncData();
}
}
private bool OnReconnectFail(IXUIButton button)
{
XSingleton<XClientNetwork>.singleton.Close(NetErrCode.Net_NoError);
XSingleton<XLoginDocument>.singleton.AuthorizationSignOut();
return true;
}
}
}
|