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
|
using System;
using UnityEngine;
using XUtliPoolLib;
namespace XMainClient
{
internal sealed class XDeathComponent : XActionStateComponent<XRealDeadEventArgs>
{
public override uint ID
{
get
{
return XDeathComponent.uuID;
}
}
public float ClipLen
{
get
{
return this._clip_len;
}
set
{
this._clip_len = value;
}
}
public IXCurve CurveH
{
get
{
return this._curve_h;
}
}
public IXCurve CurveV
{
get
{
return this._curve_v;
}
}
public float LandTime
{
get
{
return this._land_time;
}
}
public float LandMax
{
get
{
return this._land_max;
}
}
public override bool IsUsingCurve
{
get
{
return !base.IsFinished;
}
}
public override string PresentCommand
{
get
{
return "ToDeath";
}
}
public override string PresentName
{
get
{
return "Death";
}
}
public override bool ShouldBePresent
{
get
{
return !this._presented;
}
}
public override int CollisionLayer
{
get
{
return LayerMask.NameToLayer("NoneEntity");
}
}
public new static readonly uint uuID = XSingleton<XCommon>.singleton.XHash("Death");
private bool _presented = false;
private float _elapsed = 0f;
private float _clip_len = 0f;
private float _last_offset = 0f;
private float _last_height = 0f;
private float _deltaH = 0f;
private float _land_time = 0f;
private float _land_max = 0f;
private Vector3 _step_dir = Vector3.forward;
private IXCurve _curve_h = null;
private IXCurve _curve_v = null;
private XEntity _killer = null;
private XFx _death_fx = null;
private uint _fade_out_token = 0u;
private uint _destory_token = 0u;
public override void OnAttachToHost(XObject host)
{
base.OnAttachToHost(host);
this._selfState = XStateDefine.XState_Death;
bool isNotEmptyObject = this._entity.EngineObject.IsNotEmptyObject;
if (isNotEmptyObject)
{
bool flag = string.IsNullOrEmpty(this._entity.Present.PresentLib.Death);
if (flag)
{
this._clip_len = 0f;
}
else
{
this._clip_len = 1f;
bool flag2 = this._entity.Present.PresentLib.DeathCurve != null && this._entity.Present.PresentLib.DeathCurve.Length != 0;
if (flag2)
{
IXCurve curve = XSingleton<XResourceLoaderMgr>.singleton.GetCurve(this._entity.Present.CurvePrefix + this._entity.Present.PresentLib.DeathCurve[0]);
IXCurve curve2 = XSingleton<XResourceLoaderMgr>.singleton.GetCurve(this._entity.Present.CurvePrefix + this._entity.Present.PresentLib.DeathCurve[1]);
this._curve_h = curve;
this._curve_v = curve2;
this._land_time = curve.GetLandValue();
this._land_max = curve.GetMaxValue();
}
}
}
}
public override void OnDetachFromHost()
{
base.OnDetachFromHost();
this._clip_len = 0f;
this._curve_h = null;
this._curve_v = null;
this._land_time = 0f;
this._land_max = 0f;
XSingleton<XTimerMgr>.singleton.KillTimer(this._fade_out_token);
XSingleton<XTimerMgr>.singleton.KillTimer(this._destory_token);
}
protected override void EventSubscribe()
{
base.RegisterEvent(XEventDefine.XEvent_RealDead, new XComponent.XEventHandler(base.OnActionEvent));
base.RegisterEvent(XEventDefine.XEvent_OnRevived, new XComponent.XEventHandler(this.OnRevive));
}
public override void OnRejected(XStateDefine current)
{
}
protected override void Cancel(XStateDefine next)
{
bool flag = this._death_fx != null;
if (flag)
{
XSingleton<XFxMgr>.singleton.DestroyFx(this._death_fx, true);
}
this._death_fx = null;
this._killer = null;
XSingleton<XTimerMgr>.singleton.KillTimer(this._fade_out_token);
XSingleton<XTimerMgr>.singleton.KillTimer(this._destory_token);
}
private bool OnRevive(XEventArgs e)
{
bool flag = this._entity.Machine.Current == XStateDefine.XState_Death;
if (flag)
{
this._entity.Machine.ForceToDefaultState(true);
}
this._presented = false;
return true;
}
protected override void ActionUpdate(float deltaTime)
{
bool presented = this._presented;
if (presented)
{
XEntity xentity = this._entity.IsTransform ? this._entity.Transformer : this._entity;
this._elapsed += deltaTime;
bool flag = xentity.Death.CurveV == null || xentity.Death.CurveH == null;
if (!flag)
{
float num = xentity.Death.CurveV.Evaluate(this._elapsed) * xentity.Scale;
float num2 = xentity.Death.CurveH.Evaluate(this._elapsed) * xentity.Scale;
Vector3 vector = this._step_dir * (num - this._last_offset);
float x = vector.x;
float num3 = num2 - this._last_height;
float z = vector.z;
this._last_height = num2;
this._last_offset = num;
float num4 = XSingleton<XCommon>.singleton.IsLess(this._elapsed, xentity.Death.LandTime) ? (-(this._deltaH / xentity.Death.LandTime) * deltaTime) : (-Mathf.Sqrt(x * x + z * z));
bool flag2 = this._elapsed < xentity.Death.LandTime;
if (flag2)
{
this._entity.DisableGravity();
}
this._entity.ApplyMove(x, num3 + num4, z);
}
}
}
public override string TriggerAnim(string pre)
{
this._presented = true;
this._entity.Ator.CrossFade(this.PresentName, 0f, 0, 0f);
return this.PresentName;
}
protected override bool OnGetEvent(XRealDeadEventArgs e, XStateDefine last)
{
this._killer = e.Killer;
XEntity xentity = this._entity.IsTransform ? this._entity.Transformer : this._entity;
bool flag = xentity.Death.ClipLen > 0f;
if (flag)
{
xentity.Death.ClipLen = xentity.OverrideAnimClipGetLength("Death", xentity.Present.ActionPrefix + xentity.Present.PresentLib.Death, false);
}
return true;
}
protected override void Begin()
{
XEntity xentity = this._entity.IsTransform ? this._entity.Transformer : this._entity;
this._entity.Net.KillIdle();
bool flag = !this._entity.IsRole && xentity.Death.ClipLen > 0f;
if (flag)
{
this._fade_out_token = XSingleton<XTimerMgr>.singleton.SetTimer(xentity.Death.ClipLen, new XTimerMgr.ElapsedEventHandler(this.OnFadeOut), null);
}
bool flag2 = !this._entity.IsPuppet && !XQualitySetting.GetQuality(EFun.ELowEffect);
if (flag2)
{
bool flag3 = !XEntity.FilterFx(this._entity, XFxMgr.FilterFxDis0);
if (flag3)
{
this._death_fx = XSingleton<XFxMgr>.singleton.CreateFx(string.IsNullOrEmpty(xentity.Present.PresentLib.DeathFx) ? "Effects/FX_Particle/NPC/xiaobing_die" : xentity.Present.PresentLib.DeathFx, null, true);
this._death_fx.Play(this._entity.EngineObject, Vector3.zero, Vector3.one, 1f, true, false, "", 0f);
}
}
XSingleton<XAudioMgr>.singleton.PlaySound(xentity, AudioChannel.Motion, XAudioStateDefine.XState_Audio_Death);
bool flag4 = xentity.Death.CurveV != null;
if (flag4)
{
this._step_dir = (XEntity.ValideEntity(this._killer) ? ((xentity.Death.LandMax > 0f) ? XSingleton<XCommon>.singleton.Horizontal(this._entity.EngineObject.Position - this._killer.EngineObject.Position) : (-this._entity.EngineObject.Forward)) : ((xentity.Death.LandMax > 0f) ? XSingleton<XCommon>.singleton.Horizontal(this._entity.EngineObject.Position - XSingleton<XEntityMgr>.singleton.Player.EngineObject.Position) : (-this._entity.EngineObject.Forward)));
Vector3 pos = this._entity.EngineObject.Position + xentity.Death.CurveV.Evaluate(xentity.Death.LandTime) * this._entity.Scale * this._step_dir;
float num = 0f;
bool flag5 = XSingleton<XScene>.singleton.TryGetTerrainY(pos, out num);
if (flag5)
{
this._deltaH = this._entity.EngineObject.Position.y - num;
}
else
{
this._deltaH = 0f;
}
bool flag6 = this._deltaH < 0f;
if (flag6)
{
this._deltaH = 0f;
}
}
this._last_offset = 0f;
this._last_height = 0f;
this._elapsed = 0f;
this._entity.Dying();
bool flag7 = !this._entity.IsRole;
if (flag7)
{
bool flag8 = xentity.Death.ClipLen > 0f;
if (flag8)
{
this._destory_token = XSingleton<XTimerMgr>.singleton.SetTimer(xentity.Death.ClipLen + 1f, new XTimerMgr.ElapsedEventHandler(this.OnDestroy), null);
}
else
{
this.OnDestroy(null);
}
}
}
private void OnFadeOut(object o)
{
XFadeOutEventArgs @event = XEventPool<XFadeOutEventArgs>.GetEvent();
@event.Out = 1f;
@event.Firer = this._entity;
XSingleton<XEventMgr>.singleton.FireEvent(@event);
}
private void OnDestroy(object o)
{
bool flag = this._death_fx != null;
if (flag)
{
XSingleton<XFxMgr>.singleton.DestroyFx(this._death_fx, true);
}
this._death_fx = null;
this._entity.Died();
}
}
}
|