public sealed override void OnPlay(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent) { // Evaluate Loop Count only when hitting start; // LoopCount < 0 means infinite mode // LoopCount == 0 means no spawn m_LoopMaxCount = vfxValues.GetInt(loopCountPropertyID); m_WaitingForTotalTime = vfxValues.GetFloat(loopDurationPropertyID); m_LoopCurrentIndex = 0; if (m_LoopMaxCount == m_LoopCurrentIndex) { state.playing = false; } }
public sealed override void OnUpdate(VFXSpawnerState state, VFXExpressionValues vfxValues, VisualEffect vfxComponent) { if (m_RemainingLoops == int.MinValue) { m_RemainingLoops = vfxValues.GetInt(numLoopsPropertyID); } if (state.totalTime > vfxValues.GetFloat(loopDurationPropertyID)) { if (!m_Waiting) { m_WaitTTL = vfxValues.GetFloat(delayPropertyID); m_Waiting = true; } else { m_WaitTTL -= state.deltaTime; if (m_WaitTTL < 0.0f) { m_Waiting = false; state.totalTime = 0.0f; if (m_RemainingLoops > 0) // if positive, remove one from count { m_RemainingLoops--; } if (m_RemainingLoops != 0) // if 0, stop forever { state.playing = true; // Re-enable the spawn context } m_RemainingLoops = Math.Max(-1, m_RemainingLoops); // sustain at -1 if in infinite mode } else { state.playing = false; // Stop the Spawn context for the duration of the delay } } } }