diff options
author | chai <chaifix@163.com> | 2021-01-25 14:28:30 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-01-25 14:28:30 +0800 |
commit | 6eb915c129fc90c6f4c82ae097dd6ffad5239efc (patch) | |
tree | 7dd2be50edf41f36b60fac84696e731c13afe617 /Client/Assets/Scripts/XMainClient/Components |
+scripts
Diffstat (limited to 'Client/Assets/Scripts/XMainClient/Components')
35 files changed, 3483 insertions, 0 deletions
diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates.meta b/Client/Assets/Scripts/XMainClient/Components/ActionStates.meta new file mode 100644 index 00000000..6481944d --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 1e1486c08e098c44f8895d9f1115554c +folderAsset: yes +timeCreated: 1611554257 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XActionStateComponent.cs b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XActionStateComponent.cs new file mode 100644 index 00000000..89a214fe --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XActionStateComponent.cs @@ -0,0 +1,253 @@ +using System;
+using XUtliPoolLib;
+
+namespace XMainClient
+{
+ internal abstract class XActionStateComponent<T> : XComponent, IXStateTransform, IXInterface where T : XActionArgs
+ {
+ public virtual bool SyncPredicted
+ {
+ get
+ {
+ return !XSingleton<XGame>.singleton.SyncMode;
+ }
+ }
+
+ public virtual float Speed
+ {
+ get
+ {
+ throw new NotImplementedException();
+ }
+ }
+
+ public XStateDefine SelfState
+ {
+ get
+ {
+ return this._selfState;
+ }
+ }
+
+ public bool IsStopped
+ {
+ get
+ {
+ return this._bStopped;
+ }
+ }
+
+ public bool IsFinished
+ {
+ get
+ {
+ return this._bFinished || this._bStopped;
+ }
+ }
+
+ public virtual bool ShouldBePresent
+ {
+ get
+ {
+ return true;
+ }
+ }
+
+ public long Token
+ {
+ get
+ {
+ return this._stateToken;
+ }
+ }
+
+ protected long SelfToken
+ {
+ get
+ {
+ return this._selfToken;
+ }
+ }
+
+ public virtual int CollisionLayer
+ {
+ get
+ {
+ return this._entity.DefaultLayer;
+ }
+ }
+
+ public abstract string PresentCommand { get; }
+
+ public abstract string PresentName { get; }
+
+ public bool Deprecated { get; set; }
+
+ public abstract bool IsUsingCurve { get; }
+
+ protected XStateDefine _selfState = XStateDefine.XState_Idle;
+
+ private bool _bFinished = true;
+
+ private bool _bStopped = false;
+
+ private long _stateToken = 0L;
+
+ private long _selfToken = 0L;
+
+ public override void OnDetachFromHost()
+ {
+ bool flag = this.SelfState != XStateDefine.XState_Idle && this._entity.Machine.Current == this.SelfState;
+ if (flag)
+ {
+ this._entity.Machine.ForceToDefaultState(true);
+ }
+ base.OnDetachFromHost();
+ }
+
+ public bool IsPermitted(XStateDefine state)
+ {
+ bool flag = this.IsFinished && this._selfState != XStateDefine.XState_Move;
+ return flag || this.InnerPermitted(state);
+ }
+
+ public virtual void OnRejected(XStateDefine current)
+ {
+ }
+
+ public void StateUpdate(float deltaTime)
+ {
+ bool flag = this.SelfState != this._entity.Machine.Default && this.IsFinished;
+ if (flag)
+ {
+ this.Finish();
+ }
+ else
+ {
+ this.ActionUpdate(deltaTime);
+ }
+ }
+
+ private void Start()
+ {
+ this.Begin();
+ }
+
+ public void Stop(XStateDefine next)
+ {
+ bool flag = !this._bStopped;
+ if (flag)
+ {
+ this._bStopped = true;
+ this.Finish();
+ this.Cancel(next);
+ }
+ }
+
+ public virtual void OnGetPermission()
+ {
+ this._bStopped = false;
+ this._bFinished = false;
+ }
+
+ public virtual string TriggerAnim(string pre)
+ {
+ string presentCommand = this.PresentCommand;
+ bool flag = pre != presentCommand;
+ if (flag)
+ {
+ bool flag2 = this._entity.Ator != null;
+ if (flag2)
+ {
+ this._entity.Ator.SetTrigger(presentCommand);
+ }
+ }
+ return presentCommand;
+ }
+
+ protected void Finish()
+ {
+ bool flag = !this._bFinished;
+ if (flag)
+ {
+ this._bFinished = true;
+ this.Cease();
+ }
+ }
+
+ protected virtual void Cease()
+ {
+ }
+
+ protected virtual void Begin()
+ {
+ }
+
+ protected virtual void Cancel(XStateDefine next)
+ {
+ }
+
+ protected virtual void OnMount(XMount mount)
+ {
+ }
+
+ protected virtual bool SelfCheck(T args)
+ {
+ return true;
+ }
+
+ protected bool GetPermission(T e)
+ {
+ bool flag = (this._entity.Skill == null || this._entity.Skill.CanPerformAction(this.SelfState, e)) && (this._entity.Machine == null || this._entity.Machine.TryTransferToState(this));
+ bool flag2 = flag;
+ if (flag2)
+ {
+ this._stateToken = e.Token;
+ this._selfToken = XSingleton<XCommon>.singleton.UniqueToken;
+ }
+ return flag;
+ }
+
+ protected virtual bool InnerPermitted(XStateDefine state)
+ {
+ return this._entity.Machine.StatePermitted(this._selfState, state);
+ }
+
+ protected bool OnActionEvent(XEventArgs e)
+ {
+ T e2 = e as T;
+ XStateDefine last = this._entity.Machine.Current;
+ bool permission = this.GetPermission(e2);
+ if (permission)
+ {
+ this.OnGetEvent(e2, last);
+ this.Start();
+ }
+ return true;
+ }
+
+ protected bool OnMountEvent(XEventArgs e)
+ {
+ bool flag = e is XOnMountedEventArgs;
+ if (flag)
+ {
+ this.OnMount(this._entity.Mount);
+ }
+ else
+ {
+ bool flag2 = e is XOnUnMountedEventArgs;
+ if (flag2)
+ {
+ this.OnMount(null);
+ }
+ }
+ return true;
+ }
+
+ protected abstract bool OnGetEvent(T e, XStateDefine last);
+
+ protected virtual void ActionUpdate(float deltaTime)
+ {
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XActionStateComponent.cs.meta b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XActionStateComponent.cs.meta new file mode 100644 index 00000000..737bc520 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XActionStateComponent.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ebd48e1350ad3394790e65a17900c872 +timeCreated: 1611404784 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XBeHitComponent.cs b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XBeHitComponent.cs new file mode 100644 index 00000000..7b52c9f9 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XBeHitComponent.cs @@ -0,0 +1,895 @@ +using System;
+using KKSG;
+using UnityEngine;
+using XUtliPoolLib;
+
+namespace XMainClient
+{
+ internal sealed class XBeHitComponent : XActionStateComponent<XBeHitEventArgs>
+ {
+ public override uint ID
+ {
+ get
+ {
+ return XBeHitComponent.uuID;
+ }
+ }
+
+ public override bool IsUsingCurve
+ {
+ get
+ {
+ return !base.IsFinished && this._hit_data.CurveUsing;
+ }
+ }
+
+ public float TimeSpan
+ {
+ get
+ {
+ return this._total_time;
+ }
+ }
+
+ public XBeHitState CurrentStateinLogical
+ {
+ get
+ {
+ return this._current_default_state;
+ }
+ }
+
+ public bool HasFlyPresent
+ {
+ get
+ {
+ return this._bHasFlyPresent;
+ }
+ }
+
+ public bool HasRollPresent
+ {
+ get
+ {
+ return this._bHasRollPresent;
+ }
+ }
+
+ public override int CollisionLayer
+ {
+ get
+ {
+ XEntity xentity = this._entity.IsTransform ? this._entity.Transformer : this._entity;
+ return (xentity.IsPlayer || xentity.IsBoss) ? xentity.DefaultLayer : 14;
+ }
+ }
+
+ public override bool ShouldBePresent
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public override string PresentCommand
+ {
+ get
+ {
+ return "ToBeHit";
+ }
+ }
+
+ public override string PresentName
+ {
+ get
+ {
+ string result;
+ switch (this._phase)
+ {
+ case XBeHitPhase.Hit_Present:
+ result = "Present";
+ break;
+ case XBeHitPhase.Hit_Landing:
+ result = "HitLanding";
+ break;
+ case XBeHitPhase.Hit_Hard:
+ result = "Hard";
+ break;
+ case XBeHitPhase.Hit_GetUp:
+ result = "GetUp";
+ break;
+ default:
+ result = "BeHit";
+ break;
+ }
+ return result;
+ }
+ }
+
+ public new static readonly uint uuID = XSingleton<XCommon>.singleton.XHash("BeHit_Presentation");
+
+ private int _start_idx = 0;
+
+ private Vector2 _pos = Vector2.zero;
+
+ private Vector2 _des = Vector2.zero;
+
+ private XBeHitState _current_default_state = XBeHitState.Hit_Back;
+
+ private XBeHitPhase _phase = XBeHitPhase.Hit_Present;
+
+ private KKSG.XQTEState _last_set_qte = KKSG.XQTEState.QTE_None;
+
+ private float _last_offset = 0f;
+
+ private float _last_height = 0f;
+
+ private float _delta_x = 0f;
+
+ private float _delta_y = 0f;
+
+ private float _delta_z = 0f;
+
+ private float _deltaH = 0f;
+
+ private float _land_time = 0f;
+
+ private float _bounce_time = 0f;
+
+ private float _getup_time = 0f;
+
+ private float _hart_time = 0f;
+
+ private float _gravity = 0f;
+
+ private float _rticalV = 0f;
+
+ private float _factor = 0f;
+
+ private float _elapsed = 0f;
+
+ private bool _bChange_to_fly = false;
+
+ private bool _bHit_Down = false;
+
+ private bool _bHit_Bounce = false;
+
+ private bool _bLoop_Hard = false;
+
+ private bool _bHasFlyPresent = false;
+
+ private bool _bHasRollPresent = false;
+
+ private bool _landing_overrided = false;
+
+ private float _total_time = 0f;
+
+ private float _present_straight = 1f;
+
+ private float _hard_straight = 1f;
+
+ private float _height = 0f;
+
+ private float _offset = 0f;
+
+ private string[] _clips = null;
+
+ private float _clip0Length = 0f;
+
+ private XFx _hit_fx = null;
+
+ private XFx _hit_hit_fx = null;
+
+ private XFx _hit_land_fx = null;
+
+ private IXCurve _curve_h = null;
+
+ private IXCurve _curve_v = null;
+
+ private float _curve_height_scale = 1f;
+
+ private float _curve_offset_scale = 1f;
+
+ private float _curve_height_time_scale = 1f;
+
+ private float _curve_offset_time_scale = 1f;
+
+ private float _hard_time_factor = 1f;
+
+ private XHitData _hit_data = null;
+
+ private Vector3 _hit_direction = Vector3.forward;
+
+ private XEntity _hit_from = null;
+
+ public override string TriggerAnim(string pre)
+ {
+ XEntity xentity = this._entity.IsTransform ? this._entity.Transformer : this._entity;
+ bool flag = this._hit_data != null && !string.IsNullOrEmpty(this._hit_data.Fx);
+ if (flag)
+ {
+ this.PlayHitFx(this._hit_data.Fx, this._hit_data.Fx_Follow, this._hit_data.Fx_StickToGround, ref this._hit_fx);
+ }
+ bool flag2 = !string.IsNullOrEmpty(xentity.Present.PresentLib.HitFx);
+ if (flag2)
+ {
+ this.PlayHitFx(xentity.Present.PresentLib.HitFx, true, false, ref this._hit_hit_fx);
+ }
+ bool flag3 = xentity.Ator != null;
+ if (flag3)
+ {
+ xentity.Ator.Play("Present", 0);
+ }
+ return "ToBeHit";
+ }
+
+ public override void OnAttachToHost(XObject host)
+ {
+ base.OnAttachToHost(host);
+ this._selfState = XStateDefine.XState_BeHit;
+ this._clips = new string[16];
+ this._landing_overrided = false;
+ }
+
+ public override void OnDetachFromHost()
+ {
+ this.DestroyFx(ref this._hit_fx);
+ this.DestroyFx(ref this._hit_hit_fx);
+ this.DestroyFx(ref this._hit_land_fx);
+ bool flag = this._clips != null;
+ if (flag)
+ {
+ this._clips = null;
+ }
+ base.OnDetachFromHost();
+ }
+
+ public override void Attached()
+ {
+ this._bHasFlyPresent = (this._entity.Present.PresentLib.HitFly != null && this._entity.Present.PresentLib.HitFly.Length != 0);
+ this._bHasRollPresent = (this._entity.Present.PresentLib.Hit_Roll != null && this._entity.Present.PresentLib.Hit_Roll.Length != 0);
+ }
+
+ protected override void EventSubscribe()
+ {
+ base.RegisterEvent(XEventDefine.XEvent_BeHit, new XComponent.XEventHandler(base.OnActionEvent));
+ }
+
+ protected override void ActionUpdate(float deltaTime)
+ {
+ XEntity xentity = this._entity.IsTransform ? this._entity.Transformer : this._entity;
+ bool flag = base.IsFinished || xentity.Ator == null;
+ if (!flag)
+ {
+ float elapsed = this._elapsed;
+ this._elapsed += deltaTime;
+ switch (this._phase)
+ {
+ case XBeHitPhase.Hit_Present:
+ {
+ bool flag2 = (this._bChange_to_fly || this._current_default_state == XBeHitState.Hit_Fly) && xentity.BeHit.HasFlyPresent;
+ bool flag3 = flag2 && !this._landing_overrided;
+ if (flag3)
+ {
+ xentity.OverrideAnimClip("HitLanding", xentity.BeHit.SaveGetClip(12), false, false);
+ this._landing_overrided = true;
+ }
+ bool flag4 = this._elapsed > this._present_straight;
+ if (flag4)
+ {
+ this._elapsed = this._present_straight;
+ bool flag5 = flag2;
+ if (flag5)
+ {
+ xentity.Ator.SetTrigger("ToBeHit_Landing");
+ this._phase = XBeHitPhase.Hit_Landing;
+ this._bHit_Down = true;
+ this._bHit_Bounce = false;
+ bool flag6 = xentity.EngineObject.Position.y < XSingleton<XScene>.singleton.TerrainY(xentity.EngineObject.Position) + 0.25f;
+ if (flag6)
+ {
+ this.PlayHitFx("Effects/FX_Particle/Roles/Lzg_Ty/Ty_dd", true, true, ref this._hit_land_fx);
+ }
+ xentity.Ator.speed = 1f;
+ }
+ else
+ {
+ xentity.Ator.SetTrigger("ToBeHit_Hard");
+ this._phase = XBeHitPhase.Hit_Hard;
+ xentity.Ator.speed = (this._bLoop_Hard ? 1f : (this._hart_time / this._hard_straight));
+ }
+ this.TrytoTirggerQTE(false);
+ }
+ this.CalcDeltaPos(Time.deltaTime, elapsed);
+ float num = -(this._deltaH / this._present_straight) * Time.deltaTime;
+ bool flag7 = this._offset < 0f && XEntity.ValideEntity(this._hit_from);
+ if (flag7)
+ {
+ float num2 = Mathf.Sqrt(this._delta_x * this._delta_x + this._delta_z * this._delta_z);
+ float magnitude = (this._hit_from.EngineObject.Position - xentity.EngineObject.Position).magnitude;
+ bool flag8 = (double)num2 > (double)magnitude - 0.5;
+ if (flag8)
+ {
+ this._delta_x = 0f;
+ this._delta_z = 0f;
+ }
+ }
+ this._entity.ApplyMove(this._delta_x, this._delta_y + num, this._delta_z);
+ bool flag9 = flag2;
+ if (flag9)
+ {
+ this._entity.DisableGravity();
+ }
+ break;
+ }
+ case XBeHitPhase.Hit_Landing:
+ {
+ bool flag10 = !this._bHit_Bounce;
+ if (flag10)
+ {
+ bool flag11 = this._elapsed > this._present_straight + this._land_time;
+ if (flag11)
+ {
+ this._bHit_Bounce = true;
+ bool flag12 = this._elapsed <= this._present_straight + this._land_time + this._bounce_time;
+ if (flag12)
+ {
+ this.TrytoTirggerQTE(false);
+ }
+ }
+ }
+ bool bHit_Bounce = this._bHit_Bounce;
+ if (bHit_Bounce)
+ {
+ bool flag13 = this._elapsed > this._present_straight + this._land_time + this._bounce_time;
+ if (flag13)
+ {
+ xentity.Ator.SetTrigger("ToBeHit_Hard");
+ this._phase = XBeHitPhase.Hit_Hard;
+ xentity.Ator.speed = (this._bLoop_Hard ? 1f : (this._hart_time / this._hard_straight));
+ this._bHit_Bounce = false;
+ this.TrytoTirggerQTE(false);
+ }
+ }
+ break;
+ }
+ case XBeHitPhase.Hit_Hard:
+ {
+ bool flag14 = this._elapsed > this._present_straight + this._land_time + this._bounce_time + this._hard_straight;
+ if (flag14)
+ {
+ xentity.Ator.SetTrigger("ToBeHit_GetUp");
+ this._phase = XBeHitPhase.Hit_GetUp;
+ xentity.Ator.speed = 1f;
+ this.TrytoTirggerQTE(false);
+ }
+ break;
+ }
+ case XBeHitPhase.Hit_GetUp:
+ {
+ bool flag15 = this._elapsed > this._total_time - this._getup_time * 0.7f;
+ if (flag15)
+ {
+ this._bHit_Down = false;
+ }
+ bool flag16 = this._elapsed > this._total_time;
+ if (flag16)
+ {
+ xentity.Ator.speed = 1f;
+ base.Finish();
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ public bool LaidOnGround()
+ {
+ XEntity xentity = this._entity.IsTransform ? this._entity.Transformer : this._entity;
+ return xentity.Machine.Current == this._selfState && this._bHit_Down;
+ }
+
+ protected override void Cancel(XStateDefine next)
+ {
+ XEntity xentity = this._entity.IsTransform ? this._entity.Transformer : this._entity;
+ this._elapsed = 0f;
+ this._rticalV = 0f;
+ this._gravity = 0f;
+ this._deltaH = 0f;
+ bool flag = xentity.Ator != null;
+ if (flag)
+ {
+ xentity.Ator.speed = 1f;
+ }
+ this._curve_h = null;
+ this._curve_v = null;
+ this._hit_data = null;
+ this._hit_from = null;
+ this.DestroyFx(ref this._hit_fx);
+ this.DestroyFx(ref this._hit_hit_fx);
+ this.DestroyFx(ref this._hit_land_fx);
+ this.TrytoTirggerQTE(true);
+ }
+
+ protected override bool OnGetEvent(XBeHitEventArgs e, XStateDefine last)
+ {
+ this._bHit_Down = false;
+ this._bHit_Bounce = false;
+ this._hit_data = e.HitData;
+ this._hit_from = e.HitFrom;
+ this._hit_direction = XSingleton<XCommon>.singleton.Horizontal(e.HitDirection);
+ this._bChange_to_fly = e.ForceToFlyHit;
+ this._hard_time_factor = ((e.Paralyze > 0f) ? e.Paralyze : 1f);
+ return true;
+ }
+
+ public string SaveGetClip(int idx)
+ {
+ bool flag = this._clips[idx] == null;
+ if (flag)
+ {
+ switch (idx)
+ {
+ case 0:
+ case 1:
+ case 2:
+ this._clips[idx] = this._entity.Present.ActionPrefix + this._entity.Present.PresentLib.Hit_f[idx];
+ break;
+ case 3:
+ case 4:
+ case 5:
+ this._clips[idx] = this._entity.Present.ActionPrefix + this._entity.Present.PresentLib.Hit_l[idx % 3];
+ break;
+ case 6:
+ case 7:
+ case 8:
+ this._clips[idx] = this._entity.Present.ActionPrefix + this._entity.Present.PresentLib.Hit_r[idx % 3];
+ break;
+ case 9:
+ case 10:
+ case 11:
+ this._clips[idx] = this._entity.Present.ActionPrefix + this._entity.Present.PresentLib.Hit_Roll[idx % 3];
+ break;
+ case 12:
+ this._clips[idx] = this._entity.Present.ActionPrefix + this._entity.Present.PresentLib.HitFly[XFastEnumIntEqualityComparer<XBeHitPhase>.ToInt(XBeHitPhase.Hit_Landing)];
+ break;
+ case 13:
+ this._clips[idx] = this._entity.Present.ActionPrefix + this._entity.Present.PresentLib.HitFly[XFastEnumIntEqualityComparer<XBeHitPhase>.ToInt(XBeHitPhase.Hit_Present)];
+ break;
+ case 14:
+ this._clips[idx] = this._entity.Present.ActionPrefix + this._entity.Present.PresentLib.HitFly[XFastEnumIntEqualityComparer<XBeHitPhase>.ToInt(XBeHitPhase.Hit_Hard)];
+ break;
+ case 15:
+ this._clips[idx] = this._entity.Present.ActionPrefix + this._entity.Present.PresentLib.HitFly[XFastEnumIntEqualityComparer<XBeHitPhase>.ToInt(XBeHitPhase.Hit_GetUp)];
+ break;
+ }
+ }
+ return this._clips[idx];
+ }
+
+ private void Prepare()
+ {
+ this._start_idx = 0;
+ XEntity xentity = this._entity.IsTransform ? this._entity.Transformer : this._entity;
+ switch (this._current_default_state)
+ {
+ case XBeHitState.Hit_Back:
+ {
+ bool bChange_to_fly = this._bChange_to_fly;
+ if (bChange_to_fly)
+ {
+ bool flag = !xentity.BeHit.HasFlyPresent;
+ if (flag)
+ {
+ this._start_idx = 3;
+ }
+ else
+ {
+ this._start_idx = 13;
+ }
+ }
+ else
+ {
+ switch (this._hit_data.State_Animation)
+ {
+ case XBeHitState_Animation.Hit_Back_Front:
+ this._start_idx = 0;
+ break;
+ case XBeHitState_Animation.Hit_Back_Left:
+ this._start_idx = 3;
+ break;
+ case XBeHitState_Animation.Hit_Back_Right:
+ this._start_idx = 6;
+ break;
+ }
+ }
+ break;
+ }
+ case XBeHitState.Hit_Fly:
+ {
+ bool flag2 = !xentity.BeHit.HasFlyPresent;
+ if (flag2)
+ {
+ this._start_idx = 3;
+ }
+ else
+ {
+ this._start_idx = 13;
+ }
+ break;
+ }
+ case XBeHitState.Hit_Roll:
+ {
+ bool bChange_to_fly2 = this._bChange_to_fly;
+ if (bChange_to_fly2)
+ {
+ bool flag3 = !xentity.BeHit.HasFlyPresent;
+ if (flag3)
+ {
+ this._start_idx = 3;
+ }
+ else
+ {
+ this._start_idx = 13;
+ }
+ }
+ else
+ {
+ bool flag4 = !xentity.BeHit.HasRollPresent;
+ if (flag4)
+ {
+ this._start_idx = 3;
+ }
+ else
+ {
+ this._start_idx = 9;
+ }
+ }
+ break;
+ }
+ }
+ XAnimationClip xanimationClip;
+ xentity.OverrideAnimClipGetClip("PresentStraight", xentity.BeHit.SaveGetClip(this._start_idx), false, true, out xanimationClip);
+ XAnimationClip xanimationClip2;
+ xentity.OverrideAnimClipGetClip("HardStraight", xentity.BeHit.SaveGetClip(this._start_idx + 1), false, false, out xanimationClip2);
+ xentity.OverrideAnimClip("GetUp", xentity.BeHit.SaveGetClip(this._start_idx + 2), false, false);
+ this._land_time = (((this._bChange_to_fly || this._current_default_state == XBeHitState.Hit_Fly) && xentity.BeHit.HasFlyPresent) ? xentity.Present.PresentLib.HitFly_Bounce_GetUp[0] : 0f);
+ this._bounce_time = (((this._bChange_to_fly || this._current_default_state == XBeHitState.Hit_Fly) && xentity.BeHit.HasFlyPresent) ? xentity.Present.PresentLib.HitFly_Bounce_GetUp[1] : 0f);
+ this._getup_time = (((this._bChange_to_fly || this._current_default_state == XBeHitState.Hit_Fly) && xentity.BeHit.HasFlyPresent) ? xentity.Present.PresentLib.HitFly_Bounce_GetUp[2] : ((this._current_default_state == XBeHitState.Hit_Roll && xentity.BeHit.HasRollPresent) ? xentity.Present.PresentLib.HitRoll_Recover : xentity.Present.PresentLib.HitBack_Recover[0]));
+ bool flag5 = xanimationClip2 != null;
+ if (flag5)
+ {
+ this._hart_time = xanimationClip2.length;
+ this._bLoop_Hard = ((int)xanimationClip2.clip.wrapMode == 2);
+ }
+ bool flag6 = xanimationClip != null;
+ if (flag6)
+ {
+ this._clip0Length = xanimationClip.length;
+ }
+ bool flag7 = this._hit_data.CurveUsing && xentity.Present.PresentLib.HitCurves != null;
+ if (flag7)
+ {
+ IXCurve ixcurve = ((this._bChange_to_fly || this._current_default_state == XBeHitState.Hit_Fly) && xentity.BeHit.HasFlyPresent) ? XSingleton<XResourceLoaderMgr>.singleton.GetCurve(xentity.Present.CurvePrefix + xentity.Present.PresentLib.HitCurves[4]) : null;
+ IXCurve ixcurve2 = ((this._bChange_to_fly || this._current_default_state == XBeHitState.Hit_Fly) && xentity.BeHit.HasFlyPresent) ? XSingleton<XResourceLoaderMgr>.singleton.GetCurve(xentity.Present.CurvePrefix + xentity.Present.PresentLib.HitCurves[3]) : ((this._current_default_state == XBeHitState.Hit_Roll && xentity.BeHit.HasRollPresent) ? XSingleton<XResourceLoaderMgr>.singleton.GetCurve(xentity.Present.CurvePrefix + xentity.Present.PresentLib.HitCurves[5]) : ((this._current_default_state == XBeHitState.Hit_Back) ? XSingleton<XResourceLoaderMgr>.singleton.GetCurve(xentity.Present.CurvePrefix + xentity.Present.PresentLib.HitCurves[XFastEnumIntEqualityComparer<XBeHitState_Animation>.ToInt(this._hit_data.State_Animation)]) : XSingleton<XResourceLoaderMgr>.singleton.GetCurve(xentity.Present.CurvePrefix + xentity.Present.PresentLib.HitCurves[0])));
+ this._curve_h = ((ixcurve != null) ? ixcurve : null);
+ this._curve_v = ixcurve2;
+ this._curve_height_scale = ((ixcurve == null || ixcurve.GetMaxValue() == 0f) ? 1f : (this._height / ixcurve.GetMaxValue()));
+ this._curve_offset_scale = ((ixcurve2.GetMaxValue() == 0f) ? 1f : (this._offset / ixcurve2.GetMaxValue()));
+ }
+ }
+
+ protected override void Begin()
+ {
+ XEntity xentity = this._entity.IsTransform ? this._entity.Transformer : this._entity;
+ this._current_default_state = this._hit_data.State;
+ this._present_straight = (this._bChange_to_fly ? (this._hit_data.Additional_Using_Default ? XSingleton<XGlobalConfig>.singleton.Hit_PresentStraight : this._hit_data.Additional_Hit_Time_Present_Straight) : this._hit_data.Time_Present_Straight);
+ this._hard_straight = (this._bChange_to_fly ? (this._hit_data.Additional_Using_Default ? XSingleton<XGlobalConfig>.singleton.Hit_HardStraight : this._hit_data.Additional_Hit_Time_Hard_Straight) : this._hit_data.Time_Hard_Straight);
+ this._offset = (this._bChange_to_fly ? (this._hit_data.Additional_Using_Default ? XSingleton<XGlobalConfig>.singleton.Hit_Offset : this._hit_data.Additional_Hit_Offset) : this._hit_data.Offset);
+ this._height = (this._bChange_to_fly ? (this._hit_data.Additional_Using_Default ? XSingleton<XGlobalConfig>.singleton.Hit_Height : this._hit_data.Additional_Hit_Height) : this._hit_data.Height);
+ this._present_straight = (XSingleton<XGame>.singleton.SyncMode ? this._present_straight : XSingleton<XCommon>.singleton.GetFloatingValue(this._present_straight, this._hit_data.Random_Range));
+ this._offset = (XSingleton<XGame>.singleton.SyncMode ? this._offset : XSingleton<XCommon>.singleton.GetFloatingValue(this._offset, this._hit_data.Random_Range));
+ this._height = (XSingleton<XGame>.singleton.SyncMode ? this._height : XSingleton<XCommon>.singleton.GetFloatingValue(this._height, this._hit_data.Random_Range));
+ float num = 1f;
+ float num2 = 1f;
+ float num3 = 1f;
+ float num4 = 1f;
+ switch (this._current_default_state)
+ {
+ case XBeHitState.Hit_Back:
+ {
+ bool bChange_to_fly = this._bChange_to_fly;
+ if (bChange_to_fly)
+ {
+ bool flag = xentity.Present.PresentLib.HitFlyOffsetTimeScale != null;
+ if (flag)
+ {
+ num = ((xentity.Present.PresentLib.HitFlyOffsetTimeScale[0] == 0f) ? 1f : xentity.Present.PresentLib.HitFlyOffsetTimeScale[0]);
+ num2 = ((xentity.Present.PresentLib.HitFlyOffsetTimeScale[1] == 0f) ? 1f : xentity.Present.PresentLib.HitFlyOffsetTimeScale[1]);
+ num3 = ((xentity.Present.PresentLib.HitFlyOffsetTimeScale[2] == 0f) ? 1f : xentity.Present.PresentLib.HitFlyOffsetTimeScale[2]);
+ num4 = ((xentity.Present.PresentLib.HitFlyOffsetTimeScale[3] == 0f) ? 1f : xentity.Present.PresentLib.HitFlyOffsetTimeScale[3]);
+ }
+ }
+ else
+ {
+ bool flag2 = xentity.Present.PresentLib.HitBackOffsetTimeScale != null;
+ if (flag2)
+ {
+ num = ((xentity.Present.PresentLib.HitBackOffsetTimeScale[0] == 0f) ? 1f : xentity.Present.PresentLib.HitBackOffsetTimeScale[0]);
+ num3 = ((xentity.Present.PresentLib.HitBackOffsetTimeScale[1] == 0f) ? 1f : xentity.Present.PresentLib.HitBackOffsetTimeScale[1]);
+ num4 = ((xentity.Present.PresentLib.HitBackOffsetTimeScale[2] == 0f) ? 1f : xentity.Present.PresentLib.HitBackOffsetTimeScale[2]);
+ }
+ }
+ break;
+ }
+ case XBeHitState.Hit_Fly:
+ {
+ bool flag3 = xentity.Present.PresentLib.HitFlyOffsetTimeScale != null;
+ if (flag3)
+ {
+ num = ((xentity.Present.PresentLib.HitFlyOffsetTimeScale[0] == 0f) ? 1f : xentity.Present.PresentLib.HitFlyOffsetTimeScale[0]);
+ num2 = ((xentity.Present.PresentLib.HitFlyOffsetTimeScale[1] == 0f) ? 1f : xentity.Present.PresentLib.HitFlyOffsetTimeScale[1]);
+ num3 = ((xentity.Present.PresentLib.HitFlyOffsetTimeScale[2] == 0f) ? 1f : xentity.Present.PresentLib.HitFlyOffsetTimeScale[2]);
+ num4 = ((xentity.Present.PresentLib.HitFlyOffsetTimeScale[3] == 0f) ? 1f : xentity.Present.PresentLib.HitFlyOffsetTimeScale[3]);
+ }
+ break;
+ }
+ case XBeHitState.Hit_Roll:
+ {
+ bool bChange_to_fly2 = this._bChange_to_fly;
+ if (bChange_to_fly2)
+ {
+ bool flag4 = xentity.Present.PresentLib.HitFlyOffsetTimeScale != null;
+ if (flag4)
+ {
+ num = ((xentity.Present.PresentLib.HitFlyOffsetTimeScale[0] == 0f) ? 1f : xentity.Present.PresentLib.HitFlyOffsetTimeScale[0]);
+ num2 = ((xentity.Present.PresentLib.HitFlyOffsetTimeScale[1] == 0f) ? 1f : xentity.Present.PresentLib.HitFlyOffsetTimeScale[1]);
+ num3 = ((xentity.Present.PresentLib.HitFlyOffsetTimeScale[2] == 0f) ? 1f : xentity.Present.PresentLib.HitFlyOffsetTimeScale[2]);
+ num4 = ((xentity.Present.PresentLib.HitFlyOffsetTimeScale[3] == 0f) ? 1f : xentity.Present.PresentLib.HitFlyOffsetTimeScale[3]);
+ }
+ }
+ else
+ {
+ bool flag5 = xentity.Present.PresentLib.HitRollOffsetTimeScale != null;
+ if (flag5)
+ {
+ num = ((xentity.Present.PresentLib.HitRollOffsetTimeScale[0] == 0f) ? 1f : xentity.Present.PresentLib.HitRollOffsetTimeScale[0]);
+ num3 = ((xentity.Present.PresentLib.HitRollOffsetTimeScale[1] == 0f) ? 1f : xentity.Present.PresentLib.HitRollOffsetTimeScale[1]);
+ num4 = ((xentity.Present.PresentLib.HitRollOffsetTimeScale[2] == 0f) ? 1f : xentity.Present.PresentLib.HitRollOffsetTimeScale[2]);
+ }
+ }
+ break;
+ }
+ }
+ this._present_straight *= num3;
+ this._hard_straight = this._hard_straight * num4 * this._hard_time_factor;
+ bool flag6 = this._bChange_to_fly || this._current_default_state == XBeHitState.Hit_Fly;
+ if (flag6)
+ {
+ this._height *= num2;
+ }
+ this._offset *= num;
+ this.Prepare();
+ this._total_time = this._present_straight + this._land_time + this._bounce_time + this._hard_straight + this._getup_time;
+ this._pos.x = xentity.EngineObject.Position.x;
+ this._pos.y = xentity.EngineObject.Position.z;
+ Vector3 vector = xentity.EngineObject.Position + this._hit_direction * this._offset;
+ float num5 = 0f;
+ bool flag7 = XSingleton<XScene>.singleton.TryGetTerrainY(vector, out num5);
+ if (flag7)
+ {
+ this._deltaH = xentity.EngineObject.Position.y - ((xentity.Fly != null) ? (num5 + xentity.Fly.CurrentHeight) : num5);
+ }
+ else
+ {
+ this._deltaH = 0f;
+ }
+ bool flag8 = this._deltaH < 0f;
+ if (flag8)
+ {
+ this._deltaH = 0f;
+ }
+ this._des.x = vector.x;
+ this._des.y = vector.z;
+ bool curveUsing = this._hit_data.CurveUsing;
+ if (curveUsing)
+ {
+ this._curve_height_time_scale = ((this._curve_h == null) ? 1f : (this._present_straight / this._curve_h.GetTime(this._curve_h.length - 1)));
+ this._curve_offset_time_scale = this._present_straight / this._curve_v.GetTime(this._curve_v.length - 1);
+ this._last_offset = 0f;
+ this._last_height = 0f;
+ }
+ else
+ {
+ this._factor = XSingleton<XCommon>.singleton.GetSmoothFactor((this._pos - this._des).magnitude, this._present_straight, 0.01f);
+ this._rticalV = ((this._bChange_to_fly || this._current_default_state == XBeHitState.Hit_Fly) ? (this._height * 4f / this._present_straight) : 0f);
+ this._gravity = this._rticalV / this._present_straight * 2f;
+ }
+ XSingleton<XAudioMgr>.singleton.PlaySound(xentity, AudioChannel.Behit, XAudioStateDefine.XState_Audio_BeHit, false, (this._hit_from == null) ? null : new XAudioExParam(this._hit_from));
+ this._elapsed = 0f;
+ this._phase = XBeHitPhase.Hit_Present;
+ this.TrytoTirggerQTE(false);
+ bool flag9 = xentity.Ator != null;
+ if (flag9)
+ {
+ xentity.Ator.speed = this._clip0Length / this._present_straight;
+ }
+ this._entity.Machine.TriggerPresent();
+ }
+
+ private void PlayHitFx(string fx, bool follow, bool sticky, ref XFx xfx)
+ {
+ bool mobShield = this._entity.MobShield;
+ if (!mobShield)
+ {
+ XEntity xentity = this._entity.IsTransform ? this._entity.Transformer : this._entity;
+ bool flag = !xentity.IsRole && XQualitySetting.GetQuality(EFun.ELowEffect);
+ if (!flag)
+ {
+ bool flag2 = xfx != null && xfx.FxName != fx;
+ if (flag2)
+ {
+ this.DestroyFx(ref xfx);
+ }
+ bool flag3 = XEntity.FilterFx(this._entity, XFxMgr.FilterFxDis0);
+ if (!flag3)
+ {
+ bool flag4 = Time.realtimeSinceStartup - XFxMgr.lastBehitFxTime < XFxMgr.minBehitFxTime || XFxMgr.currentBeHitFx >= XFxMgr.maxBehitFx;
+ if (!flag4)
+ {
+ bool flag5 = xfx == null;
+ if (flag5)
+ {
+ xfx = XSingleton<XFxMgr>.singleton.CreateFx(fx, null, true);
+ }
+ XFxMgr.lastBehitFxTime = Time.realtimeSinceStartup;
+ XFxMgr.currentBeHitFx++;
+ Vector3 offset = sticky ? Vector3.zero : (Vector3.up * (xentity.Height * 0.5f));
+ xfx.Play(xentity.EngineObject, offset, Vector3.one, 1f, follow, sticky, "", 0f);
+ }
+ }
+ }
+ }
+ }
+
+ private void DestroyFx(ref XFx xfx)
+ {
+ bool flag = xfx != null;
+ if (flag)
+ {
+ XFxMgr.currentBeHitFx--;
+ bool flag2 = XFxMgr.currentBeHitFx < 0;
+ if (flag2)
+ {
+ XFxMgr.currentBeHitFx = 0;
+ }
+ XSingleton<XFxMgr>.singleton.DestroyFx(xfx, true);
+ xfx = null;
+ }
+ }
+
+ private void CalcDeltaPos(float deltaTime, float last_elapsed)
+ {
+ Vector2 vector = Vector2.zero;
+ bool curveUsing = this._hit_data.CurveUsing;
+ float delta_y;
+ if (curveUsing)
+ {
+ float time = this._elapsed / this._curve_offset_time_scale;
+ float time2 = this._elapsed / this._curve_height_time_scale;
+ float num = this._curve_v.Evaluate(time) * this._curve_offset_scale;
+ float num2 = (this._curve_h == null) ? 0f : (this._curve_h.Evaluate(time2) * this._curve_height_scale);
+ Vector3 vector2 = this._hit_direction * (num - this._last_offset);
+ vector.x = vector2.x;
+ vector.y = vector2.z;
+ delta_y = num2 - this._last_height;
+ this._last_height = num2;
+ this._last_offset = num;
+ }
+ else
+ {
+ XEntity xentity = this._entity.IsTransform ? this._entity.Transformer : this._entity;
+ float num3 = this._rticalV - this._gravity * last_elapsed;
+ float num4 = this._rticalV - this._gravity * this._elapsed;
+ delta_y = (num3 + num4) / 2f * deltaTime;
+ this._pos.x = xentity.EngineObject.Position.x;
+ this._pos.y = xentity.EngineObject.Position.z;
+ vector = (this._des - this._pos) * Mathf.Min(1f, this._factor * deltaTime);
+ }
+ this._delta_x = vector.x;
+ this._delta_y = delta_y;
+ this._delta_z = vector.y;
+ }
+
+ public KKSG.XQTEState GetQTESpecificPhase()
+ {
+ KKSG.XQTEState result = KKSG.XQTEState.QTE_None;
+ XEntity xentity = this._entity.IsTransform ? this._entity.Transformer : this._entity;
+ switch (this._phase)
+ {
+ case XBeHitPhase.Hit_Present:
+ switch (this._current_default_state)
+ {
+ case XBeHitState.Hit_Back:
+ result = ((this._bChange_to_fly && xentity.BeHit.HasFlyPresent) ? KKSG.XQTEState.QTE_HitFlyPresent : KKSG.XQTEState.QTE_HitBackPresent);
+ break;
+ case XBeHitState.Hit_Fly:
+ result = (xentity.BeHit.HasFlyPresent ? KKSG.XQTEState.QTE_HitFlyPresent : KKSG.XQTEState.QTE_HitBackPresent);
+ break;
+ case XBeHitState.Hit_Roll:
+ result = ((this._bChange_to_fly && xentity.BeHit.HasFlyPresent) ? KKSG.XQTEState.QTE_HitFlyPresent : (xentity.BeHit.HasRollPresent ? KKSG.XQTEState.QTE_HitRollPresent : KKSG.XQTEState.QTE_HitBackPresent));
+ break;
+ }
+ break;
+ case XBeHitPhase.Hit_Landing:
+ result = (this._bHit_Bounce ? KKSG.XQTEState.QTE_HitFlyBounce : KKSG.XQTEState.QTE_HitFlyLand);
+ break;
+ case XBeHitPhase.Hit_Hard:
+ switch (this._current_default_state)
+ {
+ case XBeHitState.Hit_Back:
+ result = ((this._bChange_to_fly && xentity.BeHit.HasFlyPresent) ? KKSG.XQTEState.QTE_HitFlyStraight : KKSG.XQTEState.QTE_HitBackStraight);
+ break;
+ case XBeHitState.Hit_Fly:
+ result = (xentity.BeHit.HasFlyPresent ? KKSG.XQTEState.QTE_HitFlyStraight : KKSG.XQTEState.QTE_HitBackStraight);
+ break;
+ case XBeHitState.Hit_Roll:
+ result = ((this._bChange_to_fly && xentity.BeHit.HasFlyPresent) ? KKSG.XQTEState.QTE_HitFlyStraight : (xentity.BeHit.HasRollPresent ? KKSG.XQTEState.QTE_HitRollStraight : KKSG.XQTEState.QTE_HitBackStraight));
+ break;
+ }
+ break;
+ case XBeHitPhase.Hit_GetUp:
+ switch (this._current_default_state)
+ {
+ case XBeHitState.Hit_Back:
+ result = ((this._bChange_to_fly && xentity.BeHit.HasFlyPresent) ? KKSG.XQTEState.QTE_HitFlyGetUp : KKSG.XQTEState.QTE_HitBackGetUp);
+ break;
+ case XBeHitState.Hit_Fly:
+ result = (xentity.BeHit.HasFlyPresent ? KKSG.XQTEState.QTE_HitFlyGetUp : KKSG.XQTEState.QTE_HitBackGetUp);
+ break;
+ case XBeHitState.Hit_Roll:
+ result = ((this._bChange_to_fly && xentity.BeHit.HasFlyPresent) ? KKSG.XQTEState.QTE_HitFlyGetUp : (xentity.BeHit.HasRollPresent ? KKSG.XQTEState.QTE_HitRollGetUp : KKSG.XQTEState.QTE_HitBackGetUp));
+ break;
+ }
+ break;
+ }
+ return result;
+ }
+
+ private void TrytoTirggerQTE(bool bEnd = false)
+ {
+ XEntity xentity = this._entity.IsTransform ? this._entity.Transformer : this._entity;
+ bool flag = !xentity.Destroying && xentity.QTE != null;
+ if (flag)
+ {
+ KKSG.XQTEState xqtestate = KKSG.XQTEState.QTE_None;
+ bool flag2 = !bEnd;
+ if (flag2)
+ {
+ xqtestate = this.GetQTESpecificPhase();
+ bool flag3 = this._last_set_qte > KKSG.XQTEState.QTE_None;
+ if (flag3)
+ {
+ XSkillQTEEventArgs @event = XEventPool<XSkillQTEEventArgs>.GetEvent();
+ @event.Firer = xentity;
+ @event.On = false;
+ @event.State = (uint)XFastEnumIntEqualityComparer<KKSG.XQTEState>.ToInt(this._last_set_qte);
+ XSingleton<XEventMgr>.singleton.FireEvent(@event);
+ }
+ this._last_set_qte = xqtestate;
+ }
+ else
+ {
+ this._last_set_qte = KKSG.XQTEState.QTE_None;
+ }
+ XSkillQTEEventArgs event2 = XEventPool<XSkillQTEEventArgs>.GetEvent();
+ event2.Firer = xentity;
+ event2.On = !bEnd;
+ event2.State = (uint)XFastEnumIntEqualityComparer<KKSG.XQTEState>.ToInt(xqtestate);
+ XSingleton<XEventMgr>.singleton.FireEvent(event2);
+ }
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XBeHitComponent.cs.meta b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XBeHitComponent.cs.meta new file mode 100644 index 00000000..0c8c2e43 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XBeHitComponent.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: cc2a9d4766bab4f4fa1c4f44f5da2700 +timeCreated: 1611404550 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XBeHitEventArgs.cs b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XBeHitEventArgs.cs new file mode 100644 index 00000000..f922183f --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XBeHitEventArgs.cs @@ -0,0 +1,35 @@ +using System;
+using UnityEngine;
+using XUtliPoolLib;
+
+namespace XMainClient
+{
+ internal class XBeHitEventArgs : XActionArgs
+ {
+ public XHitData HitData { get; set; }
+
+ public Vector3 HitDirection = Vector3.forward;
+
+ public bool ForceToFlyHit = false;
+
+ public float Paralyze = 1f;
+
+ public XEntity HitFrom = null;
+
+ public XBeHitEventArgs()
+ {
+ this._eDefine = XEventDefine.XEvent_BeHit;
+ }
+
+ public override void Recycle()
+ {
+ this.HitData = null;
+ this.HitDirection = Vector3.forward;
+ this.ForceToFlyHit = false;
+ this.Paralyze = 1f;
+ this.HitFrom = null;
+ base.Recycle();
+ XEventPool<XBeHitEventArgs>.Recycle(this);
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XBeHitEventArgs.cs.meta b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XBeHitEventArgs.cs.meta new file mode 100644 index 00000000..5b27776f --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XBeHitEventArgs.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4ffe45036c5ab5b4db40a90b75c418f5 +timeCreated: 1611403702 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XChargeComponent.cs b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XChargeComponent.cs new file mode 100644 index 00000000..c090c0cb --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XChargeComponent.cs @@ -0,0 +1,422 @@ +using System;
+using UnityEngine;
+using XUtliPoolLib;
+
+namespace XMainClient
+{
+ internal sealed class XChargeComponent : XActionStateComponent<XChargeEventArgs>
+ {
+ public override uint ID
+ {
+ get
+ {
+ return XChargeComponent.uuID;
+ }
+ }
+
+ public override float Speed
+ {
+ get
+ {
+ return this._step_speed;
+ }
+ }
+
+ public override bool IsUsingCurve
+ {
+ get
+ {
+ return !base.IsFinished && this._using_curve;
+ }
+ }
+
+ public override bool ShouldBePresent
+ {
+ get
+ {
+ return true;
+ }
+ }
+
+ public override string PresentCommand
+ {
+ get
+ {
+ bool flag = this._entity.Skill.IsCasting() && this._entity.Skill.CurrentSkill.MainCore.Soul.Logical.Association && this._entity.Skill.CurrentSkill.MainCore.Soul.Logical.MoveType;
+ string result;
+ if (flag)
+ {
+ result = "ToMove";
+ }
+ else
+ {
+ result = "ToStand";
+ }
+ return result;
+ }
+ }
+
+ public override string PresentName
+ {
+ get
+ {
+ bool flag = this._entity.Skill.IsCasting() && this._entity.Skill.CurrentSkill.MainCore.Soul.Logical.Association && this._entity.Skill.CurrentSkill.MainCore.Soul.Logical.MoveType;
+ string result;
+ if (flag)
+ {
+ result = "Move";
+ }
+ else
+ {
+ result = "Stand";
+ }
+ return result;
+ }
+ }
+
+ public new static readonly uint uuID = XSingleton<XCommon>.singleton.XHash("Charge_Move");
+
+ private float _time_scale = 1f;
+
+ private bool _gravity_disabled = false;
+
+ private bool _standon_atend = true;
+
+ private float _timeElapsed = 0f;
+
+ private float _timeSpan = 0f;
+
+ private float _land_time = 0f;
+
+ private float _height = 0f;
+
+ private float _gravity = 0f;
+
+ private float _rticalV = 0f;
+
+ private float _rotation_speed = 0f;
+
+ private float _step_speed = 0f;
+
+ private float _offset = 0f;
+
+ private float _distance = 0f;
+
+ private float _velocity = 0f;
+
+ private float _height_drop = 0f;
+
+ private XEntity _aim_to_target = null;
+
+ private Vector3 _begin_at = Vector3.zero;
+
+ private Vector3 _step_dir = Vector3.zero;
+
+ private Vector3 _curve_step_dir = Vector3.zero;
+
+ private IXCurve _curve_forward = null;
+
+ private IXCurve _curve_side = null;
+
+ private IXCurve _curve_up = null;
+
+ private bool _using_curve = false;
+
+ private bool _using_up = false;
+
+ private bool _control_towards = false;
+
+ private float _last_offset_forward = 0f;
+
+ private float _last_offset_side = 0f;
+
+ private float _last_offset_up = 0f;
+
+ public override void OnAttachToHost(XObject host)
+ {
+ base.OnAttachToHost(host);
+ this._selfState = XStateDefine.XState_Charge;
+ }
+
+ protected override void EventSubscribe()
+ {
+ base.RegisterEvent(XEventDefine.XEvent_Charge, new XComponent.XEventHandler(base.OnActionEvent));
+ }
+
+ public override void OnRejected(XStateDefine current)
+ {
+ }
+
+ protected override void ActionUpdate(float deltaTime)
+ {
+ bool flag = XSingleton<XCommon>.singleton.IsLess(this._timeElapsed, this._timeSpan);
+ if (flag)
+ {
+ Vector3 vector = Vector3.zero;
+ float num = 0f;
+ this.Calibration();
+ bool using_curve = this._using_curve;
+ if (using_curve)
+ {
+ this.GetCurveMove(ref vector, ref num, deltaTime);
+ bool flag2 = this._control_towards && this._entity.IsPlayer && XSingleton<XVirtualTab>.singleton.Feeding;
+ if (flag2)
+ {
+ vector += this._step_dir * (this._velocity * deltaTime);
+ }
+ }
+ else
+ {
+ this.GetNormalMove(ref vector, ref num, deltaTime);
+ }
+ bool flag3 = this._timeElapsed > this._timeSpan;
+ if (flag3)
+ {
+ this._timeElapsed = this._timeSpan;
+ base.Finish();
+ }
+ num -= ((this._land_time > 0f) ? (deltaTime * (this._height_drop / this._land_time)) : this._height_drop);
+ bool flag4 = this._using_up && this._timeElapsed <= this._land_time;
+ if (flag4)
+ {
+ this._gravity_disabled = true;
+ this._entity.DisableGravity();
+ }
+ else
+ {
+ this._gravity_disabled = false;
+ }
+ bool flag5 = this._land_time == 0f && this._entity.Fly != null;
+ if (flag5)
+ {
+ this._height_drop = 0f;
+ }
+ bool flag6 = this._entity.Skill.IsCasting() && this._entity.Skill.CurrentSkill.MainCore.Soul.MultipleAttackSupported;
+ if (flag6)
+ {
+ this.CalibrateByMultipleDirection(ref vector, this._entity.Skill.CurrentSkill.MainCore);
+ }
+ bool flag7 = this._entity.Buffs != null && this._entity.Buffs.IsBuffStateOn(XBuffType.XBuffType_LockFoot);
+ if (flag7)
+ {
+ vector = Vector3.zero;
+ }
+ bool flag8 = this._distance - 0.5f < vector.magnitude;
+ if (flag8)
+ {
+ vector.Set(0f, vector.y, 0f);
+ }
+ bool isDummy = this._entity.IsDummy;
+ if (isDummy)
+ {
+ vector.Set(0f, vector.y, 0f);
+ }
+ this._entity.ApplyMove(vector.x, num, vector.z);
+ }
+ else
+ {
+ bool gravity_disabled = this._gravity_disabled;
+ if (gravity_disabled)
+ {
+ this._entity.DisableGravity();
+ }
+ }
+ }
+
+ protected override void Cancel(XStateDefine next)
+ {
+ this._timeElapsed = 0f;
+ this._rticalV = 0f;
+ this._gravity = 0f;
+ this._step_speed = 0f;
+ this._curve_forward = null;
+ this._curve_side = null;
+ this._using_curve = false;
+ bool gravity_disabled = this._gravity_disabled;
+ if (gravity_disabled)
+ {
+ this._entity.DisableGravity();
+ }
+ }
+
+ protected override bool OnGetEvent(XChargeEventArgs e, XStateDefine last)
+ {
+ this._gravity_disabled = false;
+ this._using_curve = e.Data.Using_Curve;
+ this._using_up = e.Data.Using_Up;
+ this._control_towards = e.Data.Control_Towards;
+ this._land_time = 0f;
+ this._time_scale = e.TimeScale;
+ this._aim_to_target = e.AimedTarget;
+ this._rotation_speed = (e.Data.AimTarget ? 0f : e.Data.Rotation_Speed);
+ bool using_curve = this._using_curve;
+ if (using_curve)
+ {
+ IXCurve curve = XSingleton<XResourceLoaderMgr>.singleton.GetCurve(e.Data.Curve_Forward);
+ this._curve_forward = curve;
+ this._curve_side = XSingleton<XResourceLoaderMgr>.singleton.GetCurve(e.Data.Curve_Side);
+ this._timeSpan = this._curve_forward.GetTime(this._curve_forward.length - 1) * this._time_scale;
+ bool using_up = this._using_up;
+ if (using_up)
+ {
+ IXCurve curve2 = XSingleton<XResourceLoaderMgr>.singleton.GetCurve(e.Data.Curve_Up);
+ this._curve_up = curve2;
+ this._land_time = curve2.GetLandValue() * this._time_scale;
+ bool flag = this._land_time > 0f;
+ if (flag)
+ {
+ this._gravity_disabled = true;
+ this._entity.DisableGravity();
+ }
+ }
+ this._offset = (this._curve_forward.GetValue(this._curve_forward.length - 1) - this._curve_forward.GetValue(0)) * this._entity.Scale;
+ this._velocity = e.Data.Velocity;
+ }
+ else
+ {
+ this._timeSpan = e.TimeSpan * this._time_scale;
+ this._offset = e.Data.Offset;
+ this._velocity = 0f;
+ }
+ this._begin_at = this._entity.MoveObj.Position;
+ this._standon_atend = e.Data.StandOnAtEnd;
+ this.Calibration();
+ this.HeightDrop();
+ this._height = e.Height * this._entity.Scale;
+ this._timeElapsed = e.TimeGone * this._time_scale;
+ return true;
+ }
+
+ protected override void Begin()
+ {
+ bool using_curve = this._using_curve;
+ if (using_curve)
+ {
+ this._last_offset_forward = 0f;
+ this._last_offset_side = 0f;
+ this._last_offset_up = 0f;
+ }
+ else
+ {
+ this._step_speed = this._offset / this._timeSpan;
+ this._rticalV = this._height * 4f / this._timeSpan;
+ this._gravity = this._rticalV / this._timeSpan * 2f;
+ }
+ }
+
+ private void Calibration()
+ {
+ bool flag = XEntity.ValideEntity(this._aim_to_target);
+ if (flag)
+ {
+ Vector3 vector = this._aim_to_target.MoveObj.Position - this._entity.MoveObj.Position;
+ this._distance = vector.magnitude;
+ this._entity.Net.ReportRotateAction(vector.normalized, this._entity.Attributes.RotateSpeed, this._entity.Skill.IsCasting() ? this._entity.Skill.CurrentSkill.Token : 0L);
+ }
+ else
+ {
+ this._distance = float.PositiveInfinity;
+ this._aim_to_target = null;
+ }
+ this._step_dir = (this._entity.Skill.IsCasting() ? (this._control_towards ? this.GetControlTowards() : this._entity.Skill.CurrentSkill.SkillTowardsTo) : this._entity.Rotate.GetMeaningfulFaceVector3());
+ this._curve_step_dir = (this._entity.Skill.IsCasting() ? this._entity.Skill.CurrentSkill.SkillTowardsTo : this._entity.Rotate.GetMeaningfulFaceVector3());
+ }
+
+ private Vector3 GetControlTowards()
+ {
+ bool flag = this._entity.IsPlayer && XSingleton<XVirtualTab>.singleton.Feeding;
+ Vector3 result;
+ if (flag)
+ {
+ result = XSingleton<XVirtualTab>.singleton.Direction;
+ }
+ else
+ {
+ result = this._entity.Skill.CurrentSkill.SkillTowardsTo;
+ }
+ return result;
+ }
+
+ private void HeightDrop()
+ {
+ bool standon_atend = this._standon_atend;
+ if (standon_atend)
+ {
+ Vector3 pos = this._begin_at + this._offset * this._step_dir;
+ float num = 0f;
+ bool flag = XSingleton<XScene>.singleton.TryGetTerrainY(pos, out num);
+ if (flag)
+ {
+ this._height_drop = ((this._entity.Fly != null) ? 0f : (this._entity.MoveObj.Position.y - num));
+ bool flag2 = this._height_drop < 0f;
+ if (flag2)
+ {
+ this._height_drop = 0f;
+ }
+ }
+ else
+ {
+ this._height_drop = 0f;
+ }
+ }
+ else
+ {
+ this._height_drop = 0f;
+ }
+ }
+
+ private void GetNormalMove(ref Vector3 delta, ref float h, float deltaTime)
+ {
+ float num = this._rticalV - this._gravity * this._timeElapsed;
+ this._timeElapsed += deltaTime;
+ float num2 = this._rticalV - this._gravity * this._timeElapsed;
+ delta = this._step_speed * deltaTime * this._step_dir;
+ h = (num + num2) / 2f * deltaTime;
+ bool flag = this._rotation_speed != 0f && !XSingleton<XGame>.singleton.SyncMode;
+ if (flag)
+ {
+ this._entity.MoveObj.Forward = XSingleton<XCommon>.singleton.HorizontalRotateVetor3(this._entity.MoveObj.Forward, this._rotation_speed * deltaTime, true);
+ bool flag2 = this._entity.Rotate != null;
+ if (flag2)
+ {
+ this._entity.Rotate.Cancel();
+ }
+ }
+ }
+
+ private void GetCurveMove(ref Vector3 delta, ref float h, float deltaTime)
+ {
+ this._timeElapsed += deltaTime;
+ float num = this._curve_forward.Evaluate(this._timeElapsed / this._time_scale) * this._entity.Scale;
+ float num2 = num - this._last_offset_forward;
+ this._last_offset_forward = num;
+ float num3 = this._curve_side.Evaluate(this._timeElapsed / this._time_scale) * this._entity.Scale;
+ float num4 = num3 - this._last_offset_side;
+ this._last_offset_side = num3;
+ bool using_up = this._using_up;
+ if (using_up)
+ {
+ float num5 = this._curve_up.Evaluate(this._timeElapsed / this._time_scale) * this._entity.Scale;
+ h = num5 - this._last_offset_up;
+ this._last_offset_up = num5;
+ }
+ Vector3 vector = num2 * this._curve_step_dir;
+ Vector3 vector2 = XSingleton<XCommon>.singleton.Horizontal(Vector3.Cross(Vector3.up, this._entity.MoveObj.Forward));
+ Vector3 vector3 = num4 * vector2;
+ delta = vector + vector3;
+ delta.y = 0f;
+ }
+
+ private void CalibrateByMultipleDirection(ref Vector3 delta, XSkillCore core)
+ {
+ float multipleDirectionFactor = core.GetMultipleDirectionFactor();
+ bool flag = multipleDirectionFactor > 0.25f && multipleDirectionFactor < 0.75f;
+ if (flag)
+ {
+ float num = 1f - core.Soul.BackTowardsDecline;
+ float num2 = (multipleDirectionFactor - 0.25f) / 0.5f * 3.14159274f;
+ delta = delta.magnitude * (1f - Mathf.Sin(num2) * num) * delta.normalized;
+ }
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XChargeComponent.cs.meta b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XChargeComponent.cs.meta new file mode 100644 index 00000000..5f4acd25 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XChargeComponent.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5a78700d4be304f4993825bb0aa7d79a +timeCreated: 1611403791 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XChargeEventArgs.cs b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XChargeEventArgs.cs new file mode 100644 index 00000000..77860e1d --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XChargeEventArgs.cs @@ -0,0 +1,39 @@ +using System;
+using XUtliPoolLib;
+
+namespace XMainClient
+{
+ internal class XChargeEventArgs : XActionArgs
+ {
+ public XChargeData Data { get; set; }
+
+ public float Height { get; set; }
+
+ public float TimeSpan { get; set; }
+
+ public XEntity AimedTarget = null;
+
+ public float TimeScale = 1f;
+
+ public float TimeGone;
+
+ public XChargeEventArgs()
+ {
+ this._eDefine = XEventDefine.XEvent_Charge;
+ this.Data = null;
+ this.TimeGone = 0f;
+ }
+
+ public override void Recycle()
+ {
+ this.Data = null;
+ this.AimedTarget = null;
+ this.Height = 0f;
+ this.TimeSpan = 0f;
+ this.TimeScale = 1f;
+ this.TimeGone = 0f;
+ base.Recycle();
+ XEventPool<XChargeEventArgs>.Recycle(this);
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XChargeEventArgs.cs.meta b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XChargeEventArgs.cs.meta new file mode 100644 index 00000000..c341e1a5 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XChargeEventArgs.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 62d3b787308582e46aa3820f86321091 +timeCreated: 1611403842 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XDeathComponent.cs b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XDeathComponent.cs new file mode 100644 index 00000000..6ef5853f --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XDeathComponent.cs @@ -0,0 +1,335 @@ +using System;
+using UnityEngine;
+using XUtliPoolLib;
+
+namespace XMainClient
+{
+ internal sealed class XDeathComponent : XActionStateComponent<XRealDeadEventArgs>
+ {
+ public override uint ID
+ {
+ get
+ {
+ return XDeathComponent.uuID;
+ }
+ }
+
+ public float ClipLen
+ {
+ get
+ {
+ return this._clip_len;
+ }
+ set
+ {
+ this._clip_len = value;
+ }
+ }
+
+ public IXCurve CurveH
+ {
+ get
+ {
+ return this._curve_h;
+ }
+ }
+
+ public IXCurve CurveV
+ {
+ get
+ {
+ return this._curve_v;
+ }
+ }
+
+ public float LandTime
+ {
+ get
+ {
+ return this._land_time;
+ }
+ }
+
+ public float LandMax
+ {
+ get
+ {
+ return this._land_max;
+ }
+ }
+
+ public override bool IsUsingCurve
+ {
+ get
+ {
+ return !base.IsFinished;
+ }
+ }
+
+ public override string PresentCommand
+ {
+ get
+ {
+ return "ToDeath";
+ }
+ }
+
+ public override string PresentName
+ {
+ get
+ {
+ return "Death";
+ }
+ }
+
+ public override bool ShouldBePresent
+ {
+ get
+ {
+ return !this._presented;
+ }
+ }
+
+ public override int CollisionLayer
+ {
+ get
+ {
+ return LayerMask.NameToLayer("NoneEntity");
+ }
+ }
+
+ public new static readonly uint uuID = XSingleton<XCommon>.singleton.XHash("Death");
+
+ private bool _presented = false;
+
+ private float _elapsed = 0f;
+
+ private float _clip_len = 0f;
+
+ private float _last_offset = 0f;
+
+ private float _last_height = 0f;
+
+ private float _deltaH = 0f;
+
+ private float _land_time = 0f;
+
+ private float _land_max = 0f;
+
+ private Vector3 _step_dir = Vector3.forward;
+
+ private IXCurve _curve_h = null;
+
+ private IXCurve _curve_v = null;
+
+ private XEntity _killer = null;
+
+ private XFx _death_fx = null;
+
+ private uint _fade_out_token = 0u;
+
+ private uint _destory_token = 0u;
+
+ public override void OnAttachToHost(XObject host)
+ {
+ base.OnAttachToHost(host);
+ this._selfState = XStateDefine.XState_Death;
+ bool isNotEmptyObject = this._entity.EngineObject.IsNotEmptyObject;
+ if (isNotEmptyObject)
+ {
+ bool flag = string.IsNullOrEmpty(this._entity.Present.PresentLib.Death);
+ if (flag)
+ {
+ this._clip_len = 0f;
+ }
+ else
+ {
+ this._clip_len = 1f;
+ bool flag2 = this._entity.Present.PresentLib.DeathCurve != null && this._entity.Present.PresentLib.DeathCurve.Length != 0;
+ if (flag2)
+ {
+ IXCurve curve = XSingleton<XResourceLoaderMgr>.singleton.GetCurve(this._entity.Present.CurvePrefix + this._entity.Present.PresentLib.DeathCurve[0]);
+ IXCurve curve2 = XSingleton<XResourceLoaderMgr>.singleton.GetCurve(this._entity.Present.CurvePrefix + this._entity.Present.PresentLib.DeathCurve[1]);
+ this._curve_h = curve;
+ this._curve_v = curve2;
+ this._land_time = curve.GetLandValue();
+ this._land_max = curve.GetMaxValue();
+ }
+ }
+ }
+ }
+
+ public override void OnDetachFromHost()
+ {
+ base.OnDetachFromHost();
+ this._clip_len = 0f;
+ this._curve_h = null;
+ this._curve_v = null;
+ this._land_time = 0f;
+ this._land_max = 0f;
+ XSingleton<XTimerMgr>.singleton.KillTimer(this._fade_out_token);
+ XSingleton<XTimerMgr>.singleton.KillTimer(this._destory_token);
+ }
+
+ protected override void EventSubscribe()
+ {
+ base.RegisterEvent(XEventDefine.XEvent_RealDead, new XComponent.XEventHandler(base.OnActionEvent));
+ base.RegisterEvent(XEventDefine.XEvent_OnRevived, new XComponent.XEventHandler(this.OnRevive));
+ }
+
+ public override void OnRejected(XStateDefine current)
+ {
+ }
+
+ protected override void Cancel(XStateDefine next)
+ {
+ bool flag = this._death_fx != null;
+ if (flag)
+ {
+ XSingleton<XFxMgr>.singleton.DestroyFx(this._death_fx, true);
+ }
+ this._death_fx = null;
+ this._killer = null;
+ XSingleton<XTimerMgr>.singleton.KillTimer(this._fade_out_token);
+ XSingleton<XTimerMgr>.singleton.KillTimer(this._destory_token);
+ }
+
+ private bool OnRevive(XEventArgs e)
+ {
+ bool flag = this._entity.Machine.Current == XStateDefine.XState_Death;
+ if (flag)
+ {
+ this._entity.Machine.ForceToDefaultState(true);
+ }
+ this._presented = false;
+ return true;
+ }
+
+ protected override void ActionUpdate(float deltaTime)
+ {
+ bool presented = this._presented;
+ if (presented)
+ {
+ XEntity xentity = this._entity.IsTransform ? this._entity.Transformer : this._entity;
+ this._elapsed += deltaTime;
+ bool flag = xentity.Death.CurveV == null || xentity.Death.CurveH == null;
+ if (!flag)
+ {
+ float num = xentity.Death.CurveV.Evaluate(this._elapsed) * xentity.Scale;
+ float num2 = xentity.Death.CurveH.Evaluate(this._elapsed) * xentity.Scale;
+ Vector3 vector = this._step_dir * (num - this._last_offset);
+ float x = vector.x;
+ float num3 = num2 - this._last_height;
+ float z = vector.z;
+ this._last_height = num2;
+ this._last_offset = num;
+ float num4 = XSingleton<XCommon>.singleton.IsLess(this._elapsed, xentity.Death.LandTime) ? (-(this._deltaH / xentity.Death.LandTime) * deltaTime) : (-Mathf.Sqrt(x * x + z * z));
+ bool flag2 = this._elapsed < xentity.Death.LandTime;
+ if (flag2)
+ {
+ this._entity.DisableGravity();
+ }
+ this._entity.ApplyMove(x, num3 + num4, z);
+ }
+ }
+ }
+
+ public override string TriggerAnim(string pre)
+ {
+ this._presented = true;
+ this._entity.Ator.CrossFade(this.PresentName, 0f, 0, 0f);
+ return this.PresentName;
+ }
+
+ protected override bool OnGetEvent(XRealDeadEventArgs e, XStateDefine last)
+ {
+ this._killer = e.Killer;
+ XEntity xentity = this._entity.IsTransform ? this._entity.Transformer : this._entity;
+ bool flag = xentity.Death.ClipLen > 0f;
+ if (flag)
+ {
+ xentity.Death.ClipLen = xentity.OverrideAnimClipGetLength("Death", xentity.Present.ActionPrefix + xentity.Present.PresentLib.Death, false);
+ }
+ return true;
+ }
+
+ protected override void Begin()
+ {
+ XEntity xentity = this._entity.IsTransform ? this._entity.Transformer : this._entity;
+ this._entity.Net.KillIdle();
+ bool flag = !this._entity.IsRole && xentity.Death.ClipLen > 0f;
+ if (flag)
+ {
+ this._fade_out_token = XSingleton<XTimerMgr>.singleton.SetTimer(xentity.Death.ClipLen, new XTimerMgr.ElapsedEventHandler(this.OnFadeOut), null);
+ }
+ bool flag2 = !this._entity.IsPuppet && !XQualitySetting.GetQuality(EFun.ELowEffect);
+ if (flag2)
+ {
+ bool flag3 = !XEntity.FilterFx(this._entity, XFxMgr.FilterFxDis0);
+ if (flag3)
+ {
+ this._death_fx = XSingleton<XFxMgr>.singleton.CreateFx(string.IsNullOrEmpty(xentity.Present.PresentLib.DeathFx) ? "Effects/FX_Particle/NPC/xiaobing_die" : xentity.Present.PresentLib.DeathFx, null, true);
+ this._death_fx.Play(this._entity.EngineObject, Vector3.zero, Vector3.one, 1f, true, false, "", 0f);
+ }
+ }
+ XSingleton<XAudioMgr>.singleton.PlaySound(xentity, AudioChannel.Motion, XAudioStateDefine.XState_Audio_Death);
+ bool flag4 = xentity.Death.CurveV != null;
+ if (flag4)
+ {
+ this._step_dir = (XEntity.ValideEntity(this._killer) ? ((xentity.Death.LandMax > 0f) ? XSingleton<XCommon>.singleton.Horizontal(this._entity.EngineObject.Position - this._killer.EngineObject.Position) : (-this._entity.EngineObject.Forward)) : ((xentity.Death.LandMax > 0f) ? XSingleton<XCommon>.singleton.Horizontal(this._entity.EngineObject.Position - XSingleton<XEntityMgr>.singleton.Player.EngineObject.Position) : (-this._entity.EngineObject.Forward)));
+ Vector3 pos = this._entity.EngineObject.Position + xentity.Death.CurveV.Evaluate(xentity.Death.LandTime) * this._entity.Scale * this._step_dir;
+ float num = 0f;
+ bool flag5 = XSingleton<XScene>.singleton.TryGetTerrainY(pos, out num);
+ if (flag5)
+ {
+ this._deltaH = this._entity.EngineObject.Position.y - num;
+ }
+ else
+ {
+ this._deltaH = 0f;
+ }
+ bool flag6 = this._deltaH < 0f;
+ if (flag6)
+ {
+ this._deltaH = 0f;
+ }
+ }
+ this._last_offset = 0f;
+ this._last_height = 0f;
+ this._elapsed = 0f;
+ this._entity.Dying();
+ bool flag7 = !this._entity.IsRole;
+ if (flag7)
+ {
+ bool flag8 = xentity.Death.ClipLen > 0f;
+ if (flag8)
+ {
+ this._destory_token = XSingleton<XTimerMgr>.singleton.SetTimer(xentity.Death.ClipLen + 1f, new XTimerMgr.ElapsedEventHandler(this.OnDestroy), null);
+ }
+ else
+ {
+ this.OnDestroy(null);
+ }
+ }
+ }
+
+ private void OnFadeOut(object o)
+ {
+ XFadeOutEventArgs @event = XEventPool<XFadeOutEventArgs>.GetEvent();
+ @event.Out = 1f;
+ @event.Firer = this._entity;
+ XSingleton<XEventMgr>.singleton.FireEvent(@event);
+ }
+
+ private void OnDestroy(object o)
+ {
+ bool flag = this._death_fx != null;
+ if (flag)
+ {
+ XSingleton<XFxMgr>.singleton.DestroyFx(this._death_fx, true);
+ }
+ this._death_fx = null;
+ this._entity.Died();
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XDeathComponent.cs.meta b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XDeathComponent.cs.meta new file mode 100644 index 00000000..26d7ed80 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XDeathComponent.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 271830e3a36d3d5479d15a99aa3708c0 +timeCreated: 1611403470 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XFallComponent.cs b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XFallComponent.cs new file mode 100644 index 00000000..18c13f3c --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XFallComponent.cs @@ -0,0 +1,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)
+ {
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XFallComponent.cs.meta b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XFallComponent.cs.meta new file mode 100644 index 00000000..9de4ec2f --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XFallComponent.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5daac6f7d31161d42972f5b51a0d0fb5 +timeCreated: 1611403807 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XFallEventArgs.cs b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XFallEventArgs.cs new file mode 100644 index 00000000..efe6d354 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XFallEventArgs.cs @@ -0,0 +1,24 @@ +using System;
+
+namespace XMainClient
+{
+ internal class XFallEventArgs : XActionArgs
+ {
+ public float HVelocity { get; set; }
+
+ public float Gravity { get; set; }
+
+ public XFallEventArgs()
+ {
+ this._eDefine = XEventDefine.XEvent_Fall;
+ }
+
+ public override void Recycle()
+ {
+ this.HVelocity = 0f;
+ this.Gravity = 0f;
+ base.Recycle();
+ XEventPool<XFallEventArgs>.Recycle(this);
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XFallEventArgs.cs.meta b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XFallEventArgs.cs.meta new file mode 100644 index 00000000..fc2c7cc8 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XFallEventArgs.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4adc2287e8a9c124aaefe6ebcdba6bbd +timeCreated: 1611403666 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XFreezeComponent.cs b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XFreezeComponent.cs new file mode 100644 index 00000000..3a04200b --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XFreezeComponent.cs @@ -0,0 +1,229 @@ +using System;
+using KKSG;
+using UnityEngine;
+using XUtliPoolLib;
+
+namespace XMainClient
+{
+ internal sealed class XFreezeComponent : XActionStateComponent<XFreezeEventArgs>
+ {
+ public override uint ID
+ {
+ get
+ {
+ return XFreezeComponent.uuID;
+ }
+ }
+
+ public override bool IsUsingCurve
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public override string PresentCommand
+ {
+ get
+ {
+ return "ToFreezed";
+ }
+ }
+
+ public override string PresentName
+ {
+ get
+ {
+ return "Freezed";
+ }
+ }
+
+ public new static readonly uint uuID = XSingleton<XCommon>.singleton.XHash("Freezing_Presentation");
+
+ private float _freeze_time = 0f;
+
+ private bool _present = false;
+
+ private float _elapsed = 0f;
+
+ private float _height_drop = 0f;
+
+ private XFx _hit_fx = null;
+
+ private XFx _hit_freeze_fx = null;
+
+ public override void OnAttachToHost(XObject host)
+ {
+ base.OnAttachToHost(host);
+ this._selfState = XStateDefine.XState_Freeze;
+ this._freeze_time = 0f;
+ this._present = false;
+ this._elapsed = 0f;
+ bool isNotEmptyObject = this._entity.EngineObject.IsNotEmptyObject;
+ if (isNotEmptyObject)
+ {
+ this._entity.OverrideAnimClip("Freezed", this._entity.Present.PresentLib.Freeze, true, false);
+ }
+ }
+
+ public override void OnDetachFromHost()
+ {
+ this.DestroyFx(ref this._hit_fx);
+ this.DestroyFx(ref this._hit_freeze_fx);
+ base.OnDetachFromHost();
+ }
+
+ public override string TriggerAnim(string pre)
+ {
+ bool flag = this._entity.Ator != null;
+ if (flag)
+ {
+ bool present = this._present;
+ if (present)
+ {
+ this._entity.Ator.speed = 1f;
+ this._entity.Ator.SetTrigger(this.PresentCommand);
+ pre = this.PresentCommand;
+ }
+ else
+ {
+ this._entity.Ator.speed = 0f;
+ }
+ }
+ return pre;
+ }
+
+ protected override void Cancel(XStateDefine next)
+ {
+ bool flag = this._entity.Ator != null;
+ if (flag)
+ {
+ this._entity.Ator.speed = 1f;
+ }
+ this.DestroyFx(ref this._hit_fx);
+ this.DestroyFx(ref this._hit_freeze_fx);
+ this.TrytoTirggerQTE(true);
+ }
+
+ protected override void EventSubscribe()
+ {
+ base.RegisterEvent(XEventDefine.XEvent_Freeze, new XComponent.XEventHandler(base.OnActionEvent));
+ }
+
+ protected override bool OnGetEvent(XFreezeEventArgs e, XStateDefine last)
+ {
+ this._freeze_time = ((e.HitData != null) ? e.HitData.FreezeDuration : e.Duration);
+ this._present = ((e.HitData != null) ? e.HitData.FreezePresent : e.Present);
+ bool flag = e.HitData != null;
+ if (flag)
+ {
+ bool flag2 = !string.IsNullOrEmpty(e.HitData.Fx);
+ if (flag2)
+ {
+ this.PlayHitFx(e.HitData.Fx, e.HitData.Fx_Follow, ref this._hit_fx);
+ }
+ bool flag3 = this._present && !string.IsNullOrEmpty(this._entity.Present.PresentLib.FreezeFx);
+ if (flag3)
+ {
+ this.PlayHitFx(this._entity.Present.PresentLib.FreezeFx, true, ref this._hit_freeze_fx);
+ }
+ }
+ XEndureEventArgs @event = XEventPool<XEndureEventArgs>.GetEvent();
+ @event.Firer = this._entity;
+ @event.Dir = e.Dir;
+ XSingleton<XEventMgr>.singleton.FireEvent(@event);
+ return true;
+ }
+
+ protected override void Begin()
+ {
+ this._elapsed = 0f;
+ this._height_drop = this._entity.EngineObject.Position.y - ((this._entity.Fly != null) ? (XSingleton<XScene>.singleton.TerrainY(this._entity.EngineObject.Position) + this._entity.Fly.CurrentHeight) : XSingleton<XScene>.singleton.TerrainY(this._entity.EngineObject.Position));
+ bool flag = this._height_drop < 0f;
+ if (flag)
+ {
+ this._height_drop = 0f;
+ }
+ this.TrytoTirggerQTE(false);
+ bool flag2 = !XSingleton<XGame>.singleton.SyncMode && this._freeze_time <= 0f;
+ if (flag2)
+ {
+ base.Finish();
+ }
+ }
+
+ public override void OnRejected(XStateDefine current)
+ {
+ }
+
+ protected override void ActionUpdate(float deltaTime)
+ {
+ bool flag = base.IsFinished || XSingleton<XGame>.singleton.SyncMode;
+ if (!flag)
+ {
+ this._elapsed += deltaTime;
+ float num = deltaTime * (this._height_drop / this._freeze_time);
+ this._entity.ApplyMove(0f, -num, 0f);
+ bool flag2 = this._elapsed > this._freeze_time;
+ if (flag2)
+ {
+ base.Finish();
+ }
+ bool flag3 = this._entity.Ator != null && !this._present;
+ if (flag3)
+ {
+ this._entity.Ator.speed = 0f;
+ }
+ }
+ }
+
+ private void TrytoTirggerQTE(bool bEnd = false)
+ {
+ bool flag = !this._entity.Destroying && this._entity.QTE != null;
+ if (flag)
+ {
+ KKSG.XQTEState en = KKSG.XQTEState.QTE_None;
+ bool flag2 = !bEnd;
+ if (flag2)
+ {
+ en = KKSG.XQTEState.QTE_HitFreeze;
+ }
+ XSkillQTEEventArgs @event = XEventPool<XSkillQTEEventArgs>.GetEvent();
+ @event.Firer = this._entity;
+ @event.On = !bEnd;
+ @event.State = (uint)XFastEnumIntEqualityComparer<KKSG.XQTEState>.ToInt(en);
+ XSingleton<XEventMgr>.singleton.FireEvent(@event);
+ }
+ }
+
+ private void PlayHitFx(string fx, bool follow, ref XFx xfx)
+ {
+ bool flag = xfx != null && xfx.FxName != fx;
+ if (flag)
+ {
+ this.DestroyFx(ref xfx);
+ }
+ bool flag2 = XEntity.FilterFx(this._entity, XFxMgr.FilterFxDis1);
+ if (!flag2)
+ {
+ bool flag3 = xfx == null;
+ if (flag3)
+ {
+ xfx = XSingleton<XFxMgr>.singleton.CreateFx(fx, null, true);
+ }
+ xfx.Play(this._entity.EngineObject, Vector3.zero, ((this._entity.Radius > 0.5f) ? (this._entity.Radius * 2f) : 1f) * Vector3.one, 1f, follow, false, "", this._entity.Height * 0.5f);
+ }
+ }
+
+ private void DestroyFx(ref XFx xfx)
+ {
+ bool flag = xfx != null;
+ if (flag)
+ {
+ XSingleton<XFxMgr>.singleton.DestroyFx(xfx, true);
+ xfx = null;
+ }
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XFreezeComponent.cs.meta b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XFreezeComponent.cs.meta new file mode 100644 index 00000000..13581314 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XFreezeComponent.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: fdda2cef18bc8e849a60b68929791560 +timeCreated: 1611404938 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XFreezeEventArgs.cs b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XFreezeEventArgs.cs new file mode 100644 index 00000000..c9411faa --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XFreezeEventArgs.cs @@ -0,0 +1,32 @@ +using System;
+using UnityEngine;
+using XUtliPoolLib;
+
+namespace XMainClient
+{
+ internal class XFreezeEventArgs : XActionArgs
+ {
+ public XHitData HitData { get; set; }
+
+ public float Duration = 0f;
+
+ public bool Present = false;
+
+ public Vector3 Dir = Vector3.zero;
+
+ public XFreezeEventArgs()
+ {
+ this._eDefine = XEventDefine.XEvent_Freeze;
+ }
+
+ public override void Recycle()
+ {
+ this.HitData = null;
+ this.Duration = 0f;
+ this.Dir = Vector3.zero;
+ this.Present = false;
+ base.Recycle();
+ XEventPool<XFreezeEventArgs>.Recycle(this);
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XFreezeEventArgs.cs.meta b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XFreezeEventArgs.cs.meta new file mode 100644 index 00000000..230c76d9 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XFreezeEventArgs.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: aa19b044a26615a4db23e3ab2c562807 +timeCreated: 1611404301 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: 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<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);
+ }
+ }
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XIdleComponent.cs.meta b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XIdleComponent.cs.meta new file mode 100644 index 00000000..39855f15 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XIdleComponent.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 6af983d36e7cacf438cab3a92767ab22 +timeCreated: 1611403890 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XIdleEventArgs.cs b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XIdleEventArgs.cs new file mode 100644 index 00000000..15e8a7e4 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XIdleEventArgs.cs @@ -0,0 +1,18 @@ +using System;
+
+namespace XMainClient
+{
+ internal class XIdleEventArgs : XActionArgs
+ {
+ public XIdleEventArgs()
+ {
+ this._eDefine = XEventDefine.XEvent_Idle;
+ }
+
+ public override void Recycle()
+ {
+ base.Recycle();
+ XEventPool<XIdleEventArgs>.Recycle(this);
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XIdleEventArgs.cs.meta b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XIdleEventArgs.cs.meta new file mode 100644 index 00000000..b4b4392b --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XIdleEventArgs.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3c27eeb1eb3466f4ba01c6bf644b0f1a +timeCreated: 1611403601 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XJumpComponent.cs b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XJumpComponent.cs new file mode 100644 index 00000000..3954c6ca --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XJumpComponent.cs @@ -0,0 +1,130 @@ +using System;
+using UnityEngine;
+using XUtliPoolLib;
+
+namespace XMainClient
+{
+ internal sealed class XJumpComponent : XActionStateComponent<XJumpEventArgs>
+ {
+ public override uint ID
+ {
+ get
+ {
+ return XJumpComponent.uuID;
+ }
+ }
+
+ public override bool IsUsingCurve
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public override string PresentCommand
+ {
+ get
+ {
+ return "ToJump";
+ }
+ }
+
+ public override string PresentName
+ {
+ get
+ {
+ return "Jump";
+ }
+ }
+
+ public new static readonly uint uuID = XSingleton<XCommon>.singleton.XHash("Basic_Jump");
+
+ private bool _jumpState = false;
+
+ private float _hvelocity = 0f;
+
+ private float _jumpforce = 4f;
+
+ private float _gravity = -9.8f;
+
+ private float _jumptime = 0f;
+
+ protected override void EventSubscribe()
+ {
+ base.RegisterEvent(XEventDefine.XEvent_Jump, new XComponent.XEventHandler(base.OnActionEvent));
+ }
+
+ public override void OnAttachToHost(XObject host)
+ {
+ base.OnAttachToHost(host);
+ this._selfState = XStateDefine.XState_Jump;
+ }
+
+ protected override void Cancel(XStateDefine next)
+ {
+ this._jumpState = false;
+ this._jumptime = 0f;
+ }
+
+ protected override bool OnGetEvent(XJumpEventArgs e, XStateDefine last)
+ {
+ this._hvelocity = e.Hvelocity;
+ this._jumpforce = e.Vvelocity;
+ this._gravity = e.Gravity;
+ return true;
+ }
+
+ protected override void Begin()
+ {
+ this._jumpState = true;
+ this._jumptime = 0f;
+ }
+
+ protected override void ActionUpdate(float deltaTime)
+ {
+ Vector3 vector = Vector3.zero;
+ this._jumpState = !this.CollisionOnTop();
+ bool jumpState = this._jumpState;
+ if (jumpState)
+ {
+ this._jumptime += deltaTime;
+ float num = this._gravity * this._jumptime * this._jumptime / 2f;
+ num += this._jumpforce * this._jumptime;
+ bool flag = XSingleton<XCommon>.singleton.IsGreater(this._jumptime, this._jumpforce / -this._gravity);
+ if (flag)
+ {
+ this._jumpState = false;
+ this.SwithToFall();
+ }
+ vector.y += num;
+ Vector3 vector2 = XSingleton<XCommon>.singleton.Horizontal(this._entity.EngineObject.Forward);
+ vector += deltaTime * this._hvelocity * vector2;
+ this._entity.ApplyMove(vector);
+ }
+ else
+ {
+ this.SwithToFall();
+ }
+ }
+
+ public override void OnRejected(XStateDefine current)
+ {
+ }
+
+ private void SwithToFall()
+ {
+ XFallEventArgs @event = XEventPool<XFallEventArgs>.GetEvent();
+ @event.HVelocity = this._hvelocity;
+ @event.Gravity = this._gravity;
+ @event.Firer = this._host;
+ XSingleton<XEventMgr>.singleton.FireEvent(@event);
+ base.Finish();
+ }
+
+ private bool CollisionOnTop()
+ {
+ return false;
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XJumpComponent.cs.meta b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XJumpComponent.cs.meta new file mode 100644 index 00000000..2300b872 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XJumpComponent.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3f5d799d46111904d8c180391ebcf46a +timeCreated: 1611403610 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XJumpEventArgs.cs b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XJumpEventArgs.cs new file mode 100644 index 00000000..27996cb1 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XJumpEventArgs.cs @@ -0,0 +1,27 @@ +using System;
+
+namespace XMainClient
+{
+ internal class XJumpEventArgs : XActionArgs
+ {
+ public float Gravity { get; set; }
+
+ public float Hvelocity { get; set; }
+
+ public float Vvelocity { get; set; }
+
+ public XJumpEventArgs()
+ {
+ this._eDefine = XEventDefine.XEvent_Jump;
+ }
+
+ public override void Recycle()
+ {
+ this.Gravity = 0f;
+ this.Hvelocity = 0f;
+ this.Vvelocity = 0f;
+ base.Recycle();
+ XEventPool<XJumpEventArgs>.Recycle(this);
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XJumpEventArgs.cs.meta b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XJumpEventArgs.cs.meta new file mode 100644 index 00000000..d8fcc5a1 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XJumpEventArgs.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d2de48c455c705c4b8f81299a4d16c4a +timeCreated: 1611404597 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XMoveComponent.cs b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XMoveComponent.cs new file mode 100644 index 00000000..37770981 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XMoveComponent.cs @@ -0,0 +1,548 @@ +using System;
+using UnityEngine;
+using XUtliPoolLib;
+
+namespace XMainClient
+{
+ internal sealed class XMoveComponent : XActionStateComponent<XMoveEventArgs>
+ {
+ public override uint ID
+ {
+ get
+ {
+ return XMoveComponent.uuID;
+ }
+ }
+
+ public override float Speed
+ {
+ get
+ {
+ return this._begin_inertia ? 0f : this._speed;
+ }
+ }
+
+ public float AnimSpeed
+ {
+ get
+ {
+ return this._anim_speed;
+ }
+ set
+ {
+ this._anim_speed = value;
+ }
+ }
+
+ public override bool IsUsingCurve
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public override bool SyncPredicted
+ {
+ get
+ {
+ return this._entity.IsClientPredicted || base.SyncPredicted;
+ }
+ }
+
+ public override bool ShouldBePresent
+ {
+ get
+ {
+ return this._entity.Machine.Previous != XStateDefine.XState_Move;
+ }
+ }
+
+ public override string PresentCommand
+ {
+ get
+ {
+ return "ToMove";
+ }
+ }
+
+ public override string PresentName
+ {
+ get
+ {
+ return "Move";
+ }
+ }
+
+ public new static readonly uint uuID = XSingleton<XCommon>.singleton.XHash("Basic_Move");
+
+ private bool _begin_inertia = false;
+
+ private bool _stoppage = true;
+
+ private float _speed = 0f;
+
+ private float _last_speed = 0f;
+
+ private float _target_speed = 0f;
+
+ private float _anim_speed = 0f;
+
+ private float _stoppage_dir = 0f;
+
+ private float _acceleration = 0f;
+
+ private float _last_angular = 0f;
+
+ private Vector3 _move_dir = Vector3.forward;
+
+ private Vector3 _destination = Vector3.zero;
+
+ private bool _inertia = false;
+
+ private bool _overlapped = false;
+
+ private uint _track_fx_1 = 0u;
+
+ private uint _track_fx_2 = 0u;
+
+ private XTimerMgr.ElapsedEventHandler _playTrackFxCb = null;
+
+ public XMoveComponent()
+ {
+ this._playTrackFxCb = new XTimerMgr.ElapsedEventHandler(this.PlayTrackFx);
+ }
+
+ public override void OnAttachToHost(XObject host)
+ {
+ base.OnAttachToHost(host);
+ this._selfState = XStateDefine.XState_Move;
+ this._speed = 0f;
+ this._last_speed = 0f;
+ this._acceleration = 0f;
+ this.PrepareAnimations();
+ }
+
+ protected override void EventSubscribe()
+ {
+ base.RegisterEvent(XEventDefine.XEvent_Move, 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));
+ }
+
+ protected override bool InnerPermitted(XStateDefine state)
+ {
+ bool flag = !this._entity.IsPlayer && this.SyncPredicted;
+ bool result;
+ if (flag)
+ {
+ result = (state != XStateDefine.XState_Idle || this._stoppage);
+ }
+ else
+ {
+ result = (base.IsFinished || base.InnerPermitted(state));
+ }
+ return result;
+ }
+
+ protected override void Cancel(XStateDefine next)
+ {
+ bool flag = next != XStateDefine.XState_Move;
+ if (flag)
+ {
+ XEntity xentity = this._entity.IsTransform ? this._entity.Transformer : this._entity;
+ xentity.Machine.SetAnimationSpeed(1f);
+ for (int i = 0; i < xentity.Affiliates.Count; i++)
+ {
+ bool flag2 = xentity.Affiliates[i].Ator != null;
+ if (flag2)
+ {
+ xentity.Affiliates[i].Ator.speed = xentity.Ator.speed;
+ }
+ }
+ bool flag3 = xentity.IsMounted && xentity.Mount.Ator != null;
+ if (flag3)
+ {
+ xentity.Mount.Ator.speed = xentity.Ator.speed;
+ }
+ this._speed = 0f;
+ this._last_speed = 0f;
+ this._acceleration = 0f;
+ bool flag4 = this._track_fx_1 > 0u;
+ if (flag4)
+ {
+ XSingleton<XTimerMgr>.singleton.KillTimer(this._track_fx_1);
+ }
+ bool flag5 = this._track_fx_2 > 0u;
+ if (flag5)
+ {
+ XSingleton<XTimerMgr>.singleton.KillTimer(this._track_fx_2);
+ }
+ this._track_fx_1 = 0u;
+ this._track_fx_2 = 0u;
+ this._anim_speed = 0f;
+ bool flag6 = !this._entity.IsPlayer && this.SyncPredicted;
+ if (flag6)
+ {
+ this._entity.Net.ReportRotateAction(XSingleton<XCommon>.singleton.FloatToAngle(this._stoppage_dir));
+ }
+ }
+ }
+
+ protected override void Cease()
+ {
+ this._begin_inertia = false;
+ }
+
+ public override void OnRejected(XStateDefine current)
+ {
+ }
+
+ public override string TriggerAnim(string pre)
+ {
+ bool isPlayer = this._entity.IsPlayer;
+ if (isPlayer)
+ {
+ bool flag = this._track_fx_1 == 0u;
+ if (flag)
+ {
+ this._track_fx_1 = XSingleton<XTimerMgr>.singleton.SetTimer(0.144f, this._playTrackFxCb, null);
+ }
+ bool flag2 = this._track_fx_2 == 0u;
+ if (flag2)
+ {
+ this._track_fx_2 = XSingleton<XTimerMgr>.singleton.SetTimer(0.426f, this._playTrackFxCb, this);
+ }
+ }
+ string text = (base.IsFinished && this._entity.IsPlayer) ? "ToStand" : this.PresentCommand;
+ bool flag3 = pre != text;
+ if (flag3)
+ {
+ bool flag4 = this._entity.Ator != null;
+ if (flag4)
+ {
+ this._entity.Ator.SetTrigger(text);
+ }
+ }
+ return text;
+ }
+
+ protected override void ActionUpdate(float deltaTime)
+ {
+ this._last_speed = this._speed;
+ bool isFinished = base.IsFinished;
+ if (!isFinished)
+ {
+ bool flag = this._speed == 0f && this._target_speed == 0f;
+ if (flag)
+ {
+ base.Finish();
+ }
+ else
+ {
+ this._speed += deltaTime * this._acceleration;
+ bool flag2 = (this._speed - this._target_speed) * this._acceleration > 0f;
+ if (flag2)
+ {
+ this._speed = this._target_speed;
+ this._acceleration = 0f;
+ }
+ bool begin_inertia = this._begin_inertia;
+ if (!begin_inertia)
+ {
+ Vector3 movement = this._move_dir * ((this._speed + this._last_speed) * 0.5f) * deltaTime;
+ bool flag3 = this._entity.Buffs != null && this._entity.Buffs.IsBuffStateOn(XBuffType.XBuffType_LockFoot);
+ if (flag3)
+ {
+ movement = Vector3.zero;
+ }
+ this.CheckMove(ref movement);
+ bool flag4 = this._entity.IsPlayer || this._entity.IsEnemy;
+ if (flag4)
+ {
+ XSecurityStatistics xsecurityStatistics = XSecurityStatistics.TryGetStatistics(this._entity);
+ bool flag5 = xsecurityStatistics != null;
+ if (flag5)
+ {
+ xsecurityStatistics.OnMove(movement.magnitude);
+ }
+ }
+ //c 移动
+ this._entity.ApplyMove(movement);
+ }
+ }
+ this._anim_speed = this._speed;
+ }
+ }
+
+ public override void PostUpdate(float fDeltaT)
+ {
+ bool flag = this._entity.Machine.Current != XStateDefine.XState_Move;
+ if (!flag)
+ {
+ XEntity xentity = this._entity.IsTransform ? this._entity.Transformer : this._entity;
+ bool flag2 = xentity.Ator == null;
+ if (!flag2)
+ {
+ bool flag3 = XSingleton<XCommon>.singleton.IsLess(this._anim_speed, this._entity.Attributes.WalkSpeed);
+ if (flag3)
+ {
+ xentity.Machine.SetAnimationSpeed(Mathf.Max(0.5f, this._anim_speed / this._entity.Attributes.WalkSpeed));
+ }
+ else
+ {
+ bool flag4 = XSingleton<XCommon>.singleton.IsGreater(this._anim_speed, this._entity.Attributes.RunSpeed);
+ if (flag4)
+ {
+ xentity.Machine.SetAnimationSpeed(this._anim_speed / this._entity.Attributes.RunSpeed);
+ }
+ else
+ {
+ xentity.Machine.SetAnimationSpeed(1f);
+ }
+ }
+ float value = this._anim_speed / this._entity.Attributes.RunSpeed;
+ bool flag5 = xentity.IsMounted && xentity.Mount.Ator != null;
+ if (flag5)
+ {
+ bool hasTurnPresetation = xentity.Mount.HasTurnPresetation;
+ if (hasTurnPresetation)
+ {
+ float num = xentity.Rotate.Angular();
+ this._last_angular += (num - this._last_angular) * Mathf.Min(1f, fDeltaT * (float)xentity.Mount.AngularSpeed);
+ }
+ else
+ {
+ this._last_angular = 0f;
+ }
+ xentity.Ator.SetFloat("MoveFactor", value);
+ xentity.Ator.SetFloat("AngleFactor", this._last_angular);
+ for (int i = 0; i < xentity.Affiliates.Count; i++)
+ {
+ bool flag6 = xentity.Affiliates[i].Ator != null;
+ if (flag6)
+ {
+ xentity.Affiliates[i].Ator.speed = xentity.Ator.speed;
+ xentity.Affiliates[i].Ator.SetFloat("MoveFactor", value);
+ xentity.Affiliates[i].Ator.SetFloat("AngleFactor", this._last_angular);
+ }
+ }
+ bool flag7 = xentity.IsMounted && xentity.Mount.Ator != null;
+ if (flag7)
+ {
+ xentity.Mount.Ator.speed = xentity.Ator.speed;
+ xentity.Mount.Ator.SetFloat("MoveFactor", value);
+ xentity.Mount.Ator.SetFloat("AngleFactor", this._last_angular);
+ }
+ }
+ else
+ {
+ this._last_angular = 0f;
+ xentity.Ator.SetFloat("MoveFactor", value);
+ xentity.Ator.SetFloat("AngleFactor", 0f);
+ for (int j = 0; j < xentity.Affiliates.Count; j++)
+ {
+ bool flag8 = xentity.Affiliates[j].Ator != null;
+ if (flag8)
+ {
+ xentity.Affiliates[j].Ator.speed = xentity.Ator.speed;
+ xentity.Affiliates[j].Ator.SetFloat("MoveFactor", value);
+ xentity.Affiliates[j].Ator.SetFloat("AngleFactor", 0f);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ protected override bool OnGetEvent(XMoveEventArgs e, XStateDefine last)
+ {
+ this._stoppage = e.Stoppage;
+ this._stoppage_dir = e.StopTowards;
+ this._inertia = e.Inertia;
+ this._target_speed = e.Speed;
+ this._destination = e.Destination;
+ this._move_dir = this._destination - this._entity.MoveObj.Position;
+ this._move_dir.y = 0f;
+ float sqrMagnitude = this._move_dir.sqrMagnitude;
+ bool flag = sqrMagnitude == 0f || ((double)sqrMagnitude < 0.001 && this._entity.IsPlayer) || (sqrMagnitude < 0.1f && !this._entity.IsPlayer && this.SyncPredicted && this._stoppage);
+ if (flag)
+ {
+ this._move_dir = this._entity.MoveObj.Forward;
+ this._target_speed = 0f;
+ }
+ this._move_dir.Normalize();
+ bool flag2 = this._entity.Fly != null;
+ if (flag2)
+ {
+ float num = XSingleton<XScene>.singleton.TerrainY(this._destination);
+ bool flag3 = this._destination.y - num < this._entity.Fly.MinHeight;
+ if (flag3)
+ {
+ this._destination.y = num + (this._entity.Fly.MinHeight + this._entity.Fly.MaxHeight) * 0.5f;
+ }
+ }
+ bool flag4 = this._entity.IsPlayer && XSingleton<XGame>.singleton.CurrentStage.Stage == EXStage.Hall;
+ if (flag4)
+ {
+ XMoveEventArgs @event = XEventPool<XMoveEventArgs>.GetEvent();
+ @event.Speed = this._target_speed;
+ @event.Destination = this._destination;
+ @event.Inertia = this._inertia;
+ @event.Firer = XSingleton<XGame>.singleton.Doc;
+ XSingleton<XEventMgr>.singleton.FireEvent(@event);
+ }
+ return true;
+ }
+
+ protected override void Begin()
+ {
+ this._begin_inertia = false;
+ bool flag = this._target_speed != this._speed;
+ if (flag)
+ {
+ bool flag2 = this._target_speed > this._speed;
+ if (flag2)
+ {
+ this._acceleration = this._entity.Attributes.RunSpeed * 5f;
+ }
+ else
+ {
+ this._acceleration = -this._entity.Attributes.RunSpeed * 6f;
+ }
+ }
+ else
+ {
+ this._acceleration = 0f;
+ }
+ this._entity.Net.ReportRotateAction(this._move_dir);
+ this._overlapped = false;
+ Vector3 zero = Vector3.zero;
+ this.CheckMove(ref zero);
+ }
+
+ protected override void OnMount(XMount mount)
+ {
+ bool flag = mount != null;
+ if (flag)
+ {
+ this._entity.OverrideAnimClip("Walk", this._entity.Present.PresentLib.AnimLocation.Replace('/', '_') + mount.Present.PresentLib.Walk + (this._entity.IsCopilotMounted ? "_follow" : ""), true, false);
+ this._entity.OverrideAnimClip("Run", this._entity.Present.PresentLib.AnimLocation.Replace('/', '_') + mount.Present.PresentLib.Run + (this._entity.IsCopilotMounted ? "_follow" : ""), true, false);
+ bool hasTurnPresetation = mount.HasTurnPresetation;
+ if (hasTurnPresetation)
+ {
+ this._entity.OverrideAnimClip("RunLeft", this._entity.Present.PresentLib.AnimLocation.Replace('/', '_') + mount.Present.PresentLib.RunLeft + (this._entity.IsCopilotMounted ? "_follow" : ""), true, false);
+ this._entity.OverrideAnimClip("RunRight", this._entity.Present.PresentLib.AnimLocation.Replace('/', '_') + mount.Present.PresentLib.RunRight + (this._entity.IsCopilotMounted ? "_follow" : ""), true, false);
+ }
+ }
+ else
+ {
+ this.PrepareAnimations();
+ }
+ this._entity.Machine.TriggerPresent();
+ }
+
+ private void CheckMove(ref Vector3 movement)
+ {
+ bool flag = !this._overlapped;
+ if (flag)
+ {
+ this._overlapped = this.Overlapped(ref movement);
+ bool overlapped = this._overlapped;
+ if (overlapped)
+ {
+ this._target_speed = 0f;
+ bool flag2 = this._inertia && this._speed > 0f;
+ if (flag2)
+ {
+ this._acceleration = -this._entity.Attributes.RunSpeed * 6f;
+ this._begin_inertia = true;
+ }
+ else
+ {
+ this._acceleration = 0f;
+ base.Finish();
+ }
+ }
+ }
+ }
+
+ private bool Overlapped(ref Vector3 movement)
+ {
+ Vector3 vector = this._entity.MoveObj.Position + movement;
+ vector.y = 0f;
+ Vector3 destination = this._destination;
+ destination.y = 0f;
+ Vector3 vector2 = destination - vector;
+ bool flag = vector2.sqrMagnitude > 0f;
+ bool result;
+ if (flag)
+ {
+ float num = Vector3.Angle(vector2, this._move_dir);
+ bool flag2 = num >= 90f;
+ if (flag2)
+ {
+ movement = this._destination - this._entity.MoveObj.Position;
+ bool flag3 = this._entity.Fly != null;
+ if (flag3)
+ {
+ movement.y = 0f;
+ }
+ result = true;
+ }
+ else
+ {
+ result = false;
+ }
+ }
+ else
+ {
+ result = true;
+ }
+ return result;
+ }
+
+ private void PlayTrackFx(object o)
+ {
+ bool flag = string.IsNullOrEmpty(this._entity.Present.PresentLib.MoveFx);
+ if (!flag)
+ {
+ uint num = XSingleton<XTimerMgr>.singleton.SetTimer(0.533f, this._playTrackFxCb, o);
+ bool flag2 = o == null;
+ if (flag2)
+ {
+ this._track_fx_1 = num;
+ }
+ else
+ {
+ this._track_fx_2 = num;
+ }
+ XSingleton<XFxMgr>.singleton.CreateAndPlay(this._entity.Present.PresentLib.MoveFx, this._entity.MoveObj, Vector3.zero, Vector3.one, 1f, false, 0.5f, true);
+ XSingleton<XAudioMgr>.singleton.PlaySound(this._entity, AudioChannel.Motion, XAudioStateDefine.XState_Audio_Move);
+ }
+ }
+
+ 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("Walk", this._entity.Present.PresentLib.AttackWalk, true, false);
+ this._entity.OverrideAnimClip("Run", this._entity.Present.PresentLib.AttackRun, true, false);
+ this._entity.OverrideAnimClip("RunLeft", this._entity.Present.PresentLib.AttackRunLeft, true, false);
+ this._entity.OverrideAnimClip("RunRight", this._entity.Present.PresentLib.AttackRunRight, true, false);
+ }
+ else
+ {
+ this._entity.OverrideAnimClip("Walk", this._entity.Present.PresentLib.Walk, true, false);
+ this._entity.OverrideAnimClip("Run", this._entity.Present.PresentLib.Run, true, false);
+ this._entity.OverrideAnimClip("RunLeft", this._entity.Present.PresentLib.RunLeft, true, false);
+ this._entity.OverrideAnimClip("RunRight", this._entity.Present.PresentLib.RunRight, true, false);
+ }
+ }
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XMoveComponent.cs.meta b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XMoveComponent.cs.meta new file mode 100644 index 00000000..b3cd016d --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XMoveComponent.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 1463440e51231af4c92f71e5b87eb46f +timeCreated: 1611403257 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XMoveEventArgs.cs b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XMoveEventArgs.cs new file mode 100644 index 00000000..d56d8ca4 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XMoveEventArgs.cs @@ -0,0 +1,34 @@ +using System;
+using UnityEngine;
+
+namespace XMainClient
+{
+ internal class XMoveEventArgs : XActionArgs
+ {
+ public Vector3 Destination = Vector3.zero;
+
+ public float Speed = 0f;
+
+ public bool Inertia = false;
+
+ public bool Stoppage = true;
+
+ public float StopTowards = 0f;
+
+ public XMoveEventArgs()
+ {
+ this._eDefine = XEventDefine.XEvent_Move;
+ }
+
+ public override void Recycle()
+ {
+ base.Recycle();
+ this.Destination = Vector3.zero;
+ this.Speed = 0f;
+ this.Inertia = false;
+ this.Stoppage = true;
+ this.StopTowards = 0f;
+ XEventPool<XMoveEventArgs>.Recycle(this);
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XMoveEventArgs.cs.meta b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XMoveEventArgs.cs.meta new file mode 100644 index 00000000..17174164 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XMoveEventArgs.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4ec55d210f9ed30409ee715d1cf40900 +timeCreated: 1611403699 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XMoveMobEventArgs.cs b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XMoveMobEventArgs.cs new file mode 100644 index 00000000..e071bcbb --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XMoveMobEventArgs.cs @@ -0,0 +1,18 @@ +using System;
+
+namespace XMainClient
+{
+ internal class XMoveMobEventArgs : XEventArgs
+ {
+ public XMoveMobEventArgs()
+ {
+ this._eDefine = XEventDefine.XEvent_Move_Mob;
+ }
+
+ public override void Recycle()
+ {
+ base.Recycle();
+ XEventPool<XMoveMobEventArgs>.Recycle(this);
+ }
+ }
+}
diff --git a/Client/Assets/Scripts/XMainClient/Components/ActionStates/XMoveMobEventArgs.cs.meta b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XMoveMobEventArgs.cs.meta new file mode 100644 index 00000000..6b102440 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Components/ActionStates/XMoveMobEventArgs.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5d9b6dd5005db9248a0051d1db971cd2 +timeCreated: 1611403807 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: |