You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.2 KiB
76 lines
2.2 KiB
using GAS.Runtime;
|
|
using Sog;
|
|
|
|
namespace CoreGame.Render
|
|
{
|
|
public class CueRendererFadeOut : GameplayCueDurational
|
|
{
|
|
public override GameplayCueDurationalSpec CreateSpec(in GameplayCueParameters param)
|
|
{
|
|
var spec = SptPool<CueRendererFadeOutSpec>.Malloc();
|
|
spec.Awake(param);
|
|
return spec;
|
|
}
|
|
|
|
public override void FreeSpec(ref GameplayCueDurationalSpec spec)
|
|
{
|
|
var cueRendererFadeOutSpec = spec as CueRendererFadeOutSpec;
|
|
SptPool<CueRendererFadeOutSpec>.Free(ref cueRendererFadeOutSpec);
|
|
spec = null;
|
|
}
|
|
}
|
|
|
|
public class CueRendererFadeOutSpec : GameplayCueDurationalSpec<CueRendererFadeOut>
|
|
{
|
|
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<ChangeBodyAllSpriteInverseAlpha>();
|
|
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;
|
|
}
|
|
}
|
|
}
|