using CoreGame; using GAS.Runtime; using Sog; namespace CoreGame.Render { public class CueCdUiEvent : GameplayCueDurational { public int slotId = 1; public CDUIType type = CDUIType.None; public override GameplayCueDurationalSpec CreateSpec(in GameplayCueParameters param) { var spec = SptPool.Malloc(); spec.Awake(param); return spec; } public override void FreeSpec(ref GameplayCueDurationalSpec spec) { var cameraShakeCueSpec = spec as CueCdUiEventSpec; SptPool.Free(ref cameraShakeCueSpec); spec = null; } } public class CueCdUiEventSpec : GameplayCueDurationalSpec { private readonly float m_TimeSpan = 0.1f; private float timeAcc; private CDUIData data = new(); public override void OnAdd() { if (ownerEnt.isLocalPlayer) { Fixed64 max = initData.sourceGeSpec.Duration; data.slot = cue.slotId; data.type = cue.type; data.lastCd = max; data.totalCd = max; EventSrv.DispatchLogicEvent(ClientEvent.OnUICDChange, data); } } public override void OnRemove() { if (ownerEnt.isLocalPlayer) { Fixed64 max = initData.sourceGeSpec.Duration; data.slot = cue.slotId; data.type = cue.type; data.lastCd = 0; data.totalCd = max; EventSrv.DispatchLogicEvent(ClientEvent.OnUICDChange, 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; if (ownerEnt.isLocalPlayer) { Fixed64 value = initData.sourceGeSpec.DurationRemaining(); Fixed64 max = initData.sourceGeSpec.Duration; data.slot = cue.slotId; data.type = cue.type; data.lastCd = value; data.totalCd = max; EventSrv.DispatchLogicEvent(ClientEvent.OnUICDChange, data); } } public override void Awake(in GameplayCueParameters param) { base.Awake(param); timeAcc = 0; } } }