blob: 18c13f3cf4d3a8989f151798f43d4617d4a35105 (
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
|
using System;
using UnityEngine;
using XUtliPoolLib;
namespace XMainClient
{
internal sealed class XFallComponent : XActionStateComponent<XFallEventArgs>
{
public override uint ID
{
get
{
return XFallComponent.uuID;
}
}
public override bool IsUsingCurve
{
get
{
return false;
}
}
public override bool ShouldBePresent
{
get
{
bool isDead = this._entity.IsDead;
return !isDead && base.ShouldBePresent;
}
}
public override string PresentCommand
{
get
{
return "ToFall";
}
}
public override string PresentName
{
get
{
return "Fall";
}
}
public new static readonly uint uuID = XSingleton<XCommon>.singleton.XHash("Basic_Fall");
private float _hvelocity = 0f;
private float _gravity = -9.8f;
private float _elapsed = 0f;
protected override void EventSubscribe()
{
base.RegisterEvent(XEventDefine.XEvent_Fall, new XComponent.XEventHandler(base.OnActionEvent));
}
public override void OnAttachToHost(XObject host)
{
base.OnAttachToHost(host);
this._selfState = XStateDefine.XState_Fall;
}
protected override void Cancel(XStateDefine next)
{
}
protected override bool OnGetEvent(XFallEventArgs e, XStateDefine last)
{
this._hvelocity = e.HVelocity;
this._gravity = e.Gravity;
return true;
}
protected override void Begin()
{
this._elapsed = 0f;
}
protected override void ActionUpdate(float deltaTime)
{
bool flag = !this._entity.StandOn;
if (flag)
{
Vector3 vector = Vector3.zero;
this._elapsed += deltaTime;
this._hvelocity += (0f - this._hvelocity) * Mathf.Min(1f, deltaTime * 4f);
float num = this._gravity * this._elapsed;
vector.y += num * deltaTime;
Vector3 vector2 = XSingleton<XCommon>.singleton.Horizontal(this._entity.EngineObject.Forward);
vector += deltaTime * this._hvelocity * vector2;
this._entity.ApplyMove(vector);
}
else
{
base.Finish();
}
}
public override void OnRejected(XStateDefine current)
{
}
}
}
|