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
|
using System;
using UnityEngine;
using XUtliPoolLib;
namespace XMainClient
{
internal class XActionSender : XSingleton<XActionSender>
{
private PtcC2G_MoveOperationReq _dir_movePtc = new PtcC2G_MoveOperationReq();
private PtcC2G_MoveOperationReq _des_movePtc = new PtcC2G_MoveOperationReq();
private PtcC2G_CastSkill skillPtc = new PtcC2G_CastSkill();
private long _dir_tick = 0L;
private long _des_tick = 0L;
private long _stub = 0L;
public void SendMoveAction(XEntity entity, float face, float speed, bool inertia)
{
bool flag = !entity.IsPlayer || XSingleton<XInput>.singleton.Freezed;
if (!flag)
{
bool flag2 = face < 0f;
if (flag2)
{
face += 360f;
}
uint num = (uint)Mathf.Floor(face + 0.5f);
uint num2 = (uint)Mathf.Floor(speed * 10f + 0.5f);
num |= num2 << 16;
if (inertia)
{
num |= 2147483648u;
}
this._dir_movePtc.Data.PosXZ = (int)Mathf.Floor(entity.MoveObj.Position.z * 100f + 0.5f);
this._dir_movePtc.Data.PosXZ |= (int)Mathf.Floor(entity.MoveObj.Position.x * 100f + 0.5f) << 16;
this._dir_movePtc.Data.Common = (int)num;
long num3 = this._stub + 1L;
this._stub = num3;
this._dir_tick = num3;
}
}
public void SendMoveAction(XEntity entity, Vector3 des, float speed, bool inertia, bool force2server = false)
{
bool flag = !entity.IsPlayer || (!force2server && XSingleton<XInput>.singleton.Freezed);
if (!flag)
{
Vector3 dir = XSingleton<XCommon>.singleton.Horizontal(des - entity.MoveObj.Position);
dir.y = 0f;
float num = (dir.sqrMagnitude > 0f) ? XSingleton<XCommon>.singleton.AngleToFloat(dir) : XSingleton<XCommon>.singleton.AngleToFloat(entity.MoveObj.Forward);
bool flag2 = num < 0f;
if (flag2)
{
num += 360f;
}
uint num2 = (uint)Mathf.Floor(num + 0.5f);
uint num3 = (uint)Mathf.Floor(speed * 10f + 0.5f);
num2 |= num3 << 16;
if (inertia)
{
num2 |= 2147483648u;
}
this._des_movePtc.Data.PosXZ = (int)Mathf.Floor(entity.MoveObj.Position.z * 100f + 0.5f);
this._des_movePtc.Data.PosXZ |= (int)Mathf.Floor(entity.MoveObj.Position.x * 100f + 0.5f) << 16;
this._des_movePtc.Data.DesXZ = (int)Mathf.Floor(des.z * 100f + 0.5f);
this._des_movePtc.Data.DesXZ |= (int)Mathf.Floor(des.x * 100f + 0.5f) << 16;
this._des_movePtc.Data.Common = (int)num2;
long num4 = this._stub + 1L;
this._stub = num4;
this._des_tick = num4;
}
}
public void Empty()
{
this._des_tick = 0L;
this._dir_tick = 0L;
}
public void Flush(bool immediately = false)
{
bool flag = immediately || this.SyncPass();
if (flag)
{
bool flag2 = this._des_tick != 0L && this._dir_tick != 0L;
if (flag2)
{
bool flag3 = this._des_tick < this._dir_tick;
if (flag3)
{
XSingleton<XClientNetwork>.singleton.Send(this._des_movePtc);
XSingleton<XClientNetwork>.singleton.Send(this._dir_movePtc);
}
else
{
XSingleton<XClientNetwork>.singleton.Send(this._dir_movePtc);
XSingleton<XClientNetwork>.singleton.Send(this._des_movePtc);
}
}
else
{
bool flag4 = this._des_tick != 0L;
if (flag4)
{
XSingleton<XClientNetwork>.singleton.Send(this._des_movePtc);
}
bool flag5 = this._dir_tick != 0L;
if (flag5)
{
XSingleton<XClientNetwork>.singleton.Send(this._dir_movePtc);
}
}
this.Empty();
}
}
public void SendSkillAction(XEntity entity, XEntity target, uint id, int slot)
{
bool flag = !entity.IsPlayer;
if (!flag)
{
XSkillCore skill = entity.SkillMgr.GetSkill(id);
this.ResetSkillPtc();
this.skillPtc.Data.SkillID = id;
this.skillPtc.Data.Target = (XEntity.ValideEntity(target) ? target.ID : 0UL);
bool flag2 = slot != -1;
if (flag2)
{
this.skillPtc.Data.Slot = slot;
}
bool feeding = XSingleton<XVirtualTab>.singleton.Feeding;
if (feeding)
{
this.skillPtc.Data.ManualFace = (int)(XSingleton<XCommon>.singleton.AngleToFloat(XSingleton<XVirtualTab>.singleton.Direction) * 10f);
}
XSingleton<XClientNetwork>.singleton.Send(this.skillPtc);
}
}
public void SendSkillAction(XEntity entity, XEntity target, int slot)
{
bool flag = !entity.IsPlayer;
if (!flag)
{
this.ResetSkillPtc();
this.skillPtc.Data.Target = (XEntity.ValideEntity(target) ? target.ID : 0UL);
this.skillPtc.Data.Slot = slot;
bool feeding = XSingleton<XVirtualTab>.singleton.Feeding;
if (feeding)
{
this.skillPtc.Data.ManualFace = (int)(XSingleton<XCommon>.singleton.AngleToFloat(XSingleton<XVirtualTab>.singleton.Direction) * 10f);
}
XSingleton<XClientNetwork>.singleton.Send(this.skillPtc);
}
}
private bool SyncPass()
{
return XSingleton<XScene>.singleton.IsViewGridScene ? (Time.frameCount % (Application.targetFrameRate / 10) == 0) : ((Time.frameCount & 1) == 0);
}
private void ResetSkillPtc()
{
this.skillPtc.Data.SkillIDSpecified = false;
this.skillPtc.Data.SlotSpecified = false;
this.skillPtc.Data.TargetSpecified = false;
this.skillPtc.Data.ManualFaceSpecified = false;
}
}
}
|