summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/XActionGeneratorComponent.cs
blob: 6c3b1fdef23c0a84606f030c17baf8443b3b64d2 (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
using System;
using UnityEngine;
using XUtliPoolLib;

namespace XMainClient
{
	internal class XActionGeneratorComponent : XComponent
	{
		public override uint ID
		{
			get
			{
				return XActionGeneratorComponent.uuID;
			}
		}

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

		private bool _feed = false;

		public override void PostUpdate(float fDeltaT)
		{
			this.UpdateGesture();
			bool hasNpc = XSingleton<XInput>.singleton.HasNpc;
			if (hasNpc)
			{
				bool flag = !XSingleton<XScene>.singleton.GameCamera.IsCloseUp;
				if (flag)
				{
					XNpc xnpc = XSingleton<XInput>.singleton.LastNpc as XNpc;
					bool flag2 = xnpc != null;
					if (flag2)
					{
						XNavigationEventArgs @event = XEventPool<XNavigationEventArgs>.GetEvent();
						@event.Firer = this._entity;
						@event.Dest = xnpc.EngineObject.Position;
						XSingleton<XEventMgr>.singleton.FireEvent(@event);
					}
				}
			}
		}

		private void UpdateGesture()
		{
			bool feeding = XSingleton<XVirtualTab>.singleton.Feeding;
			if (feeding)
			{
				bool isCloseUp = XSingleton<XScene>.singleton.GameCamera.IsCloseUp;
				if (!isCloseUp)
				{
					this._entity.Net.ReportMoveAction(XSingleton<XVirtualTab>.singleton.Direction, 0.0);
					this._feed = true;
				}
			}
			else
			{
				bool feed = this._feed;
				if (feed)
				{
					this._entity.Net.ReportMoveAction(Vector3.zero, 0.0);
					this._feed = false;
				}
			}
		}
	}
}