From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Components/ActionStates/XIdleComponent.cs | 122 +++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/Components/ActionStates/XIdleComponent.cs (limited to 'Client/Assets/Scripts/XMainClient/Components/ActionStates/XIdleComponent.cs') diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XIdleComponent.cs b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XIdleComponent.cs new file mode 100644 index 00000000..6835cb96 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XIdleComponent.cs @@ -0,0 +1,122 @@ +using System; +using XUtliPoolLib; + +namespace XMainClient +{ + internal sealed class XIdleComponent : XActionStateComponent + { + public override uint ID + { + get + { + return XIdleComponent.uuID; + } + } + + public override bool SyncPredicted + { + get + { + bool isViewGridScene = XSingleton.singleton.IsViewGridScene; + bool result; + if (isViewGridScene) + { + result = true; + } + else + { + bool syncMode = XSingleton.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.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.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); + } + } + } + } +} -- cgit v1.1-26-g67d0