summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/Components/ActionStates/XIdleComponent.cs
blob: 6835cb961acc652ebb229a396a6793ccb7143f92 (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
using System;
using XUtliPoolLib;

namespace XMainClient
{
	internal sealed class XIdleComponent : XActionStateComponent<XIdleEventArgs>
	{
		public override uint ID
		{
			get
			{
				return XIdleComponent.uuID;
			}
		}

		public override bool SyncPredicted
		{
			get
			{
				bool isViewGridScene = XSingleton<XScene>.singleton.IsViewGridScene;
				bool result;
				if (isViewGridScene)
				{
					result = true;
				}
				else
				{
					bool syncMode = XSingleton<XGame>.singleton.SyncMode;
					if (syncMode)
					{
						bool flag = this._entity.Skill != null && this._entity.Skill.IsCasting();
						result = (!flag && this._entity.IsPlayer && !this._entity.IsPassive);
					}
					else
					{
						result = true;
					}
				}
				return result;
			}
		}

		public override bool IsUsingCurve
		{
			get
			{
				return false;
			}
		}

		public override string PresentCommand
		{
			get
			{
				return "ToStand";
			}
		}

		public override string PresentName
		{
			get
			{
				return "Stand";
			}
		}

		public new static readonly uint uuID = XSingleton<XCommon>.singleton.XHash("Basic_Idle");

		public override void OnAttachToHost(XObject host)
		{
			base.OnAttachToHost(host);
			this._selfState = XStateDefine.XState_Idle;
			this.PrepareAnimations();
		}

		protected override void EventSubscribe()
		{
			base.RegisterEvent(XEventDefine.XEvent_Idle, new XComponent.XEventHandler(base.OnActionEvent));
			base.RegisterEvent(XEventDefine.XEvent_OnMounted, new XComponent.XEventHandler(base.OnMountEvent));
			base.RegisterEvent(XEventDefine.XEvent_OnUnMounted, new XComponent.XEventHandler(base.OnMountEvent));
		}

		public override void OnRejected(XStateDefine current)
		{
		}

		protected override bool OnGetEvent(XIdleEventArgs e, XStateDefine last)
		{
			return true;
		}

		protected override void OnMount(XMount mount)
		{
			bool flag = mount != null;
			if (flag)
			{
				this._entity.OverrideAnimClip("Idle", this._entity.Present.PresentLib.AnimLocation.Replace('/', '_') + mount.Present.PresentLib.Idle + (this._entity.IsCopilotMounted ? "_follow" : ""), true, false);
			}
			else
			{
				this.PrepareAnimations();
			}
		}

		private void PrepareAnimations()
		{
			bool isNotEmptyObject = this._entity.EngineObject.IsNotEmptyObject;
			if (isNotEmptyObject)
			{
				bool flag = XSingleton<XGame>.singleton.CurrentStage.Stage == EXStage.World && !string.IsNullOrEmpty(this._entity.Present.PresentLib.AttackIdle);
				if (flag)
				{
					this._entity.OverrideAnimClip("Idle", this._entity.Present.PresentLib.AttackIdle, true, false);
				}
				else
				{
					this._entity.OverrideAnimClip("Idle", this._entity.Present.PresentLib.Idle, true, false);
				}
			}
		}
	}
}