From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../XMainClient/XActionGeneratorComponent.cs | 66 ++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XActionGeneratorComponent.cs (limited to 'Client/Assets/Scripts/XMainClient/XActionGeneratorComponent.cs') diff --git a/Client/Assets/Scripts/XMainClient/XActionGeneratorComponent.cs b/Client/Assets/Scripts/XMainClient/XActionGeneratorComponent.cs new file mode 100644 index 00000000..6c3b1fde --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XActionGeneratorComponent.cs @@ -0,0 +1,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.singleton.XHash("Action_Generator"); + + private bool _feed = false; + + public override void PostUpdate(float fDeltaT) + { + this.UpdateGesture(); + bool hasNpc = XSingleton.singleton.HasNpc; + if (hasNpc) + { + bool flag = !XSingleton.singleton.GameCamera.IsCloseUp; + if (flag) + { + XNpc xnpc = XSingleton.singleton.LastNpc as XNpc; + bool flag2 = xnpc != null; + if (flag2) + { + XNavigationEventArgs @event = XEventPool.GetEvent(); + @event.Firer = this._entity; + @event.Dest = xnpc.EngineObject.Position; + XSingleton.singleton.FireEvent(@event); + } + } + } + } + + private void UpdateGesture() + { + bool feeding = XSingleton.singleton.Feeding; + if (feeding) + { + bool isCloseUp = XSingleton.singleton.GameCamera.IsCloseUp; + if (!isCloseUp) + { + this._entity.Net.ReportMoveAction(XSingleton.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; + } + } + } + } +} -- cgit v1.1-26-g67d0