using CoreGame; using GAS.Runtime; using Sog; namespace CoreGame.Render { public class CueRefreshedHpShield : GameplayCueDurational { // public ClientEvent eventId = ClientEvent.OnRefreshedHpShield; public override GameplayCueDurationalSpec CreateSpec(in GameplayCueParameters param) { var spec = SptPool.Malloc(); spec.Awake(param); return spec; } public override void FreeSpec(ref GameplayCueDurationalSpec spec) { var cueRefreshedHpShieldSpec = spec as CueRefreshedHpShieldSpec; SptPool.Free(ref cueRefreshedHpShieldSpec); spec = null; } } public class CueRefreshedHpShieldSpec : GameplayCueDurationalSpec { private readonly float m_TimeSpan = 0.1f; private float timeAcc; private HpShieldData data = new(); public override void OnAdd() { if (ownerEnt.IsValid() == false) return; if (ownerEnt.hasMonster == false) return; data.mosterId = ownerEnt.blackboard.unitCfgId; data.shieldRate = 1; EventSrv.DispatchLogicEvent(ClientEvent.OnRefreshedHpShield, data); } public override void OnRemove() { if (ownerEnt.IsValid() == false) return; if (ownerEnt.hasMonster == false) return; data.mosterId = ownerEnt.blackboard.unitCfgId; data.shieldRate = 0; EventSrv.DispatchLogicEvent(ClientEvent.OnRefreshedHpShield, data); } public override void OnGameplayEffectActivate() { } public override void OnGameplayEffectDeactivate() { } public override void OnTick(Fixed64 dt) { timeAcc += dt; if (timeAcc < m_TimeSpan) { return; } timeAcc -= m_TimeSpan; data.mosterId = ownerEnt.blackboard.unitCfgId; var monsterPropDesc = MonsterPropDescMgr.Instance.GetConfig(data.mosterId); var rate = ownerEnt.property.GetProperty(PropertyDef.Calc_HpShield) / ( monsterPropDesc.ShieldValue * BattleConst.TenThousandReverse); data.shieldRate = (float)rate; EventSrv.DispatchLogicEvent(ClientEvent.OnRefreshedHpShield, data); } public override void Awake(in GameplayCueParameters param) { base.Awake(param); timeAcc = 0; } } }