using GAS.Runtime; using Sog; namespace CoreGame.Render { public class CueRendererFadeOut : GameplayCueDurational { public override GameplayCueDurationalSpec CreateSpec(in GameplayCueParameters param) { var spec = SptPool.Malloc(); spec.Awake(param); return spec; } public override void FreeSpec(ref GameplayCueDurationalSpec spec) { var cueRendererFadeOutSpec = spec as CueRendererFadeOutSpec; SptPool.Free(ref cueRendererFadeOutSpec); spec = null; } } public class CueRendererFadeOutSpec : GameplayCueDurationalSpec { private readonly float m_TimeSpan = 0.1f; private Fixed64 m_TimeAcc; private ChangeBodyAllSpriteInverseAlpha _changeBodyAllSpriteInverseAlpha; private Fixed64 m_FadeOutStep; public override void OnAdd() { if (ownerEnt.IsValid() == false) return; var bp = ownerEnt.bindPointProxy; var mainTrans = bp?.GetBindPoint(BindPointType.Main); _changeBodyAllSpriteInverseAlpha = mainTrans?.GetComponent(); m_FadeOutStep = m_TimeSpan / duration; } public override void OnRemove() { } public override void OnGameplayEffectActivate() { } public override void OnGameplayEffectDeactivate() { } public override void OnTick(Fixed64 dt) { m_TimeAcc += dt; if (m_TimeAcc < m_TimeSpan) { return; } m_TimeAcc -= m_TimeSpan; if (_changeBodyAllSpriteInverseAlpha != null) { _changeBodyAllSpriteInverseAlpha.alpha += m_FadeOutStep; _changeBodyAllSpriteInverseAlpha.OnDidApplyAnimationProperties(); } } public override void Awake(in GameplayCueParameters param) { base.Awake(in param); m_TimeAcc = 0f; _changeBodyAllSpriteInverseAlpha = null; m_FadeOutStep = 0f; } } }