SadConsole.Effects.EffectsChain.Update C# (CSharp) Method

Update() public method

public Update ( double gameTimeSeconds ) : void
gameTimeSeconds double
return void
        public override void Update(double gameTimeSeconds)
        {
            if (_enabled)
            {
                _timeElapsed += gameTimeSeconds;

                if (_delayFinished)
                {
                    // Check to see if we are in a chain delay, if so, we wait x seconds until we move on to the next chained effect.
                    if (!_inChainDelay)
                    {
                        // Process the effect
                        _activeEffect.Update(gameTimeSeconds);

                        // If the effect finished, we move on to the next effect
                        if (_activeEffect.IsFinished)
                        {
                            _activeIndex++;

                            if (_activeIndex != Effects.Count)
                            {
                                _activeEffect = Effects[_activeIndex];

                                // When moving to the next effect, check and see if we have a delay. If so, flag and wait.
                                if (DelayBetweenEffects != 0f)
                                {
                                    _inChainDelay = true;
                                    _timeElapsed = 0d;
                                }
                            }
                            else
                            {
                                _activeIndex = -1;
                                _activeEffect = null;

                                IsFinished = true;
                            }
                        }

                        // No effect to process? End this chain, which sets enabled = false.
                        if (_activeEffect == null)
                        {
                            if (!Repeat)
                                End();
                            else
                            {
                                _inChainDelay = true;
                                _timeElapsed = 0d;
                                IsFinished = false;
                            }
                        }
                    }
                    else
                    {
                        if (_timeElapsed >= DelayBetweenEffects)
                        {
                            _inChainDelay = false;

                            // If we do not have another effect to move on to and repeat is enabled, start over.
                            // We can only do this if the effects have ended with repeat, otherwise End() is called which instantly disables the chain
                            if (_activeEffect == null && Repeat)
                                Restart();
                        }
                    }
                }
                else
                {
                    if (_timeElapsed >= _startDelay)
                        _delayFinished = true;
                }
            }
        }