using System; using System.Collections.Generic; using KKSG; using UnityEngine; using XMainClient.UI; using XMainClient.UI.UICommon; using XUtliPoolLib; namespace XMainClient { internal sealed class XWoozyComponent : XComponent { public override uint ID { get { return XWoozyComponent.uuID; } } public bool OnBroken { get { return this._OnBroken; } } public bool OnRecover { get { return this._OnRecover; } } public bool InTransfer { get { return this._transfer; } } public new static readonly uint uuID = XSingleton.singleton.XHash("WoozyComponent"); private bool _OnBroken = false; private bool _OnRecover = false; private bool _OnWoozy = false; private bool _recovery = false; private bool _transfer = false; private bool _woozy_enabled = false; private XFx _fx = null; private uint _token_on = 0u; private uint _token_off = 0u; protected override void EventSubscribe() { base.RegisterEvent(XEventDefine.XEvent_ArmorBroken, new XComponent.XEventHandler(this.OnArmorBroken)); base.RegisterEvent(XEventDefine.XEvent_ArmorRecover, new XComponent.XEventHandler(this.OnArmorRecover)); base.RegisterEvent(XEventDefine.XEvent_RealDead, new XComponent.XEventHandler(this.OnDeath)); } public override void Attached() { this._woozy_enabled = this._entity.Attributes.HasWoozyStatus; } public override void OnDetachFromHost() { this.Clear(); base.OnDetachFromHost(); } public override void Update(float fDeltaT) { bool onRecover = this._OnRecover; if (onRecover) { this.RecoverArmor(); } bool onBroken = this._OnBroken; if (onBroken) { this.BrokenArmor(); } bool onWoozy = this._OnWoozy; if (onWoozy) { this.Woozy(); } this.UpdateFx(); } private bool OnArmorBroken(XEventArgs e) { this._OnBroken = true; this._transfer = true; return true; } private bool OnArmorRecover(XEventArgs e) { this._OnRecover = true; this._transfer = true; return true; } private bool OnDeath(XEventArgs e) { this.Clear(); return true; } private void Clear() { bool flag = this._fx != null; if (flag) { XSingleton.singleton.DestroyFx(this._fx, true); this._fx = null; } this._OnBroken = false; this._OnRecover = false; this._transfer = false; XSingleton.singleton.KillTimer(this._token_on); XSingleton.singleton.KillTimer(this._token_off); } private void BrokenArmor() { bool woozy_enabled = this._woozy_enabled; if (woozy_enabled) { bool flag = !XSingleton.singleton.SyncMode; if (flag) { XSingleton.singleton.Idled(this._entity); this._entity.SkillMgr.CoolDown(this._entity.SkillMgr.GetBrokenIdentity()); this._entity.Net.ReportSkillAction(null, this._entity.SkillMgr.GetBrokenIdentity(), -1); } this._OnBroken = false; this._entity.OverrideAnimClip("Idle", this._entity.Present.PresentLib.Feeble, true, false); float time = this._entity.SkillMgr.GetSkill(this._entity.SkillMgr.GetBrokenIdentity()).Soul.Time; this._token_on = XSingleton.singleton.SetTimer(time - Time.deltaTime, new XTimerMgr.ElapsedEventHandler(this.WoozyOn), null); this._entity.BeginSlowMotion(0.3f, (time > 0.3f) ? 0.3f : time, false); XCoolDownAllSkillsArgs @event = XEventPool.GetEvent(); @event.Firer = XSingleton.singleton.Doc; XSingleton.singleton.FireEvent(@event); } else { this._OnBroken = false; this.WoozyOn(null); } } private void RecoverArmor() { bool woozy_enabled = this._woozy_enabled; if (woozy_enabled) { XEntity target = null; bool flag = !XSingleton.singleton.SyncMode; if (flag) { List list = (this._entity.AI != null) ? this._entity.AI.EnmityList.GetHateEntity(false) : null; bool flag2 = list != null && list.Count > 0; if (flag2) { target = list[0]; } this._entity.SkillMgr.CoolDown(this._entity.SkillMgr.GetRecoveryIdentity()); } bool flag3 = XSingleton.singleton.SyncMode || this._entity.Net.ReportSkillAction(target, this._entity.SkillMgr.GetRecoveryIdentity(), -1); if (flag3) { XSkillCore skill = this._entity.SkillMgr.GetSkill(this._entity.SkillMgr.GetRecoveryIdentity()); float time = this._entity.SkillMgr.GetSkill(this._entity.SkillMgr.GetRecoveryIdentity()).Soul.Time; this._token_off = XSingleton.singleton.SetTimer(time - Time.deltaTime, new XTimerMgr.ElapsedEventHandler(this.WoozyOff), null); this._OnRecover = false; } bool flag4 = !this._OnRecover; if (flag4) { this._recovery = false; bool flag5 = this._fx != null; if (flag5) { XSingleton.singleton.DestroyFx(this._fx, true); this._fx = null; } } } else { this._OnRecover = false; this.WoozyOff(null); } } private void Woozy() { bool recovery = this._recovery; if (recovery) { bool flag = !XSingleton.singleton.SyncMode; if (flag) { XSingleton.singleton.Idled(this._entity); } bool flag2 = !string.IsNullOrEmpty(this._entity.Present.PresentLib.FeebleFx); if (flag2) { this.PlayFx(this._entity.Present.PresentLib.FeebleFx, true); } } else { this._entity.OverrideAnimClip("Idle", this._entity.Present.PresentLib.AttackIdle, true, false); } this._OnWoozy = false; } private void PlayFx(string fx, bool follow) { bool flag = this._fx != null && this._fx.FxName != fx; if (flag) { XSingleton.singleton.DestroyFx(this._fx, true); this._fx = null; } bool flag2 = XEntity.FilterFx(this._entity, XFxMgr.FilterFxDis1); if (!flag2) { bool flag3 = this._fx == null; if (flag3) { this._fx = XSingleton.singleton.CreateFx(fx, null, true); this._fx.Play(this._entity.EngineObject, Vector3.zero, Vector3.one, 1f, follow, false, "", 0f); } } } private void WoozyOn(object o) { this._recovery = true; bool woozy_enabled = this._woozy_enabled; if (woozy_enabled) { this._OnWoozy = true; } this._transfer = false; XWoozyOnArgs @event = XEventPool.GetEvent(); @event.Firer = this._entity; XSingleton.singleton.FireEvent(@event); @event = XEventPool.GetEvent(); @event.Firer = XSingleton.singleton.Doc; @event.Self = this._entity; XSingleton.singleton.FireEvent(@event); } private void WoozyOff(object o) { bool woozy_enabled = this._woozy_enabled; if (woozy_enabled) { this._OnWoozy = true; } this._transfer = false; XWoozyOffArgs @event = XEventPool.GetEvent(); @event.Firer = this._entity; XSingleton.singleton.FireEvent(@event); @event = XEventPool.GetEvent(); @event.Firer = XSingleton.singleton.Doc; @event.Self = this._entity; XSingleton.singleton.FireEvent(@event); } private void UpdateFx() { bool recovery = this._recovery; if (recovery) { switch (this._entity.GetQTESpecificPhase()) { case KKSG.XQTEState.QTE_HitBackPresent: case KKSG.XQTEState.QTE_HitBackStraight: case KKSG.XQTEState.QTE_HitRollPresent: case KKSG.XQTEState.QTE_HitRollStraight: { this.PlayFx(this._entity.Present.PresentLib.RecoveryHitSlowFX, true); bool flag = DlgBase.singleton.IsLoaded(); if (flag) { DlgBase.singleton.SetupSpeedFx(this._entity, true, new Color32(byte.MaxValue, 174, 0, byte.MaxValue)); } bool flag2 = DlgBase.singleton.IsLoaded(); if (flag2) { DlgBase.singleton.SetupSpeedFx(this._entity, true, new Color32(byte.MaxValue, 174, 0, byte.MaxValue)); } goto IL_1CC; } case KKSG.XQTEState.QTE_HitFlyPresent: case KKSG.XQTEState.QTE_HitFlyLand: case KKSG.XQTEState.QTE_HitFlyBounce: case KKSG.XQTEState.QTE_HitFreeze: { this.PlayFx(this._entity.Present.PresentLib.RecoveryHitStopFX, true); bool flag3 = DlgBase.singleton.IsLoaded(); if (flag3) { DlgBase.singleton.SetupSpeedFx(this._entity, true, Color.red); } bool flag4 = DlgBase.singleton.IsLoaded(); if (flag4) { DlgBase.singleton.SetupSpeedFx(this._entity, true, Color.red); } goto IL_1CC; } } this.PlayFx(this._entity.Present.PresentLib.RecoveryFX, true); bool flag5 = DlgBase.singleton.IsLoaded(); if (flag5) { DlgBase.singleton.SetupSpeedFx(this._entity, false, Color.white); } bool flag6 = DlgBase.singleton.IsLoaded(); if (flag6) { DlgBase.singleton.SetupSpeedFx(this._entity, false, Color.white); } IL_1CC:; } } } }