blob: ef58395538fc87b3aaff02abe7f46c18b67fe9ae (
plain)
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
|
using System;
using UnityEngine;
using XUtliPoolLib;
namespace XMainClient
{
internal sealed class XRotationComponent : XComponent
{
public override uint ID
{
get
{
return XRotationComponent.uuID;
}
}
public float To
{
get
{
return this._to;
}
}
public bool Rotating
{
get
{
return this._rotate;
}
}
public new static readonly uint uuID = XSingleton<XCommon>.singleton.XHash("Basic_Rotation");
private XStateMachine _machine = null;
private bool _rotate = false;
private float _to = 0f;
private float _from = 0f;
private float _rotateSpeed = 0f;
private Vector3 _last_towards = Vector3.zero;
protected override void EventSubscribe()
{
base.RegisterEvent(XEventDefine.XEvent_Rotation, new XComponent.XEventHandler(this.OnBasicRotate));
}
public override void OnAttachToHost(XObject host)
{
base.OnAttachToHost(host);
this._rotateSpeed = 0f;
this._machine = this._entity.Machine;
}
private bool Permission(XEventArgs e)
{
bool flag = !this._machine.State.SyncPredicted;
bool result;
if (flag)
{
result = false;
}
else
{
bool flag2 = XStateMgr.IsUnControlledState(this._machine.Current);
bool flag3 = this._entity.Skill != null && this._entity.Skill.IsCasting();
if (flag3)
{
result = (e.Token == this._entity.Skill.CurrentSkill.Token || (this._entity.Skill.CurrentSkill.MainCore.CanRotate() && !flag2));
}
else
{
result = (e.Token == this._machine.ActionToken || !flag2);
}
}
return result;
}
private bool OnBasicRotate(XEventArgs e)
{
bool flag = this.Permission(e);
bool result;
if (flag)
{
XRotationEventArgs xrotationEventArgs = e as XRotationEventArgs;
Vector3 normalized = xrotationEventArgs.TargetDir.normalized;
normalized.y = 0f;
bool flag2 = normalized.sqrMagnitude == 0f;
if (flag2)
{
result = false;
}
else
{
Vector3 forward = this._entity.MoveObj.Forward;
this._from = XSingleton<XCommon>.singleton.AngleToFloat(forward);
float num = Vector3.Angle(forward, normalized);
bool flag3 = XSingleton<XCommon>.singleton.Clockwise(forward, normalized);
if (flag3)
{
this._to = this._from + num;
}
else
{
this._to = this._from - num;
}
this._rotateSpeed = xrotationEventArgs.Palstance;
this._rotate = true;
this._last_towards = this._entity.MoveObj.Forward;
result = true;
}
}
else
{
result = false;
}
return result;
}
public override void Update(float fDeltaT)
{
bool rotate = this._rotate;
if (rotate)
{
bool flag = !XSingleton<XCommon>.singleton.IsEqual(this._from, this._to);
if (flag)
{
this._from += (this._to - this._from) * Mathf.Min(1f, fDeltaT * this._rotateSpeed);
}
else
{
this._rotate = false;
this._from = this._to;
}
this._entity.MoveObj.Rotation = Quaternion.Euler(0f, this._from, 0f);
}
}
public float Angular()
{
bool rotate = this._rotate;
float result;
if (rotate)
{
float num = Vector3.Angle(this._last_towards, this._entity.MoveObj.Forward);
bool flag = !XSingleton<XCommon>.singleton.Clockwise(this._last_towards, this._entity.MoveObj.Forward);
if (flag)
{
num = -num;
}
this._last_towards = this._entity.MoveObj.Forward;
result = ((Mathf.Abs(num) > 1f) ? ((float)((num > 0f) ? 1 : -1)) : num);
}
else
{
result = 0f;
}
return result;
}
public void Cancel()
{
this._rotate = false;
this._to = XSingleton<XCommon>.singleton.AngleToFloat(this._entity.MoveObj.Forward);
}
public float GetMeaningfulFace()
{
return (this._rotate && this._rotateSpeed > 0f) ? this._to : XSingleton<XCommon>.singleton.AngleToFloat(this._entity.MoveObj.Forward);
}
public Vector3 GetMeaningfulFaceVector3()
{
return (this._rotate && this._rotateSpeed > 0f) ? XSingleton<XCommon>.singleton.FloatToAngle(this._to) : this._entity.MoveObj.Forward;
}
public Quaternion GetMeaningfulFaceQuaternion()
{
return (this._rotate && this._rotateSpeed > 0f) ? XSingleton<XCommon>.singleton.FloatToQuaternion(this._to) : this._entity.MoveObj.Rotation;
}
}
}
|