Represents a wrapped effect with additional time information.
Exemplo n.º 1
0
        /// <summary>
        /// Updates all effects added to this target.
        /// </summary>
        public virtual void UpdateEffects()
        {
            lock (Effects)
            {
                for (int i = EffectTimes.Count - 1; i >= 0; i--)
                {
                    EffectTimeContainer effectTime = EffectTimes[i];
                    long currentTicks = DateTime.Now.Ticks;

                    float deltaTime;
                    if (effectTime.TicksAtLastUpdate < 0)
                    {
                        effectTime.TicksAtLastUpdate = currentTicks;
                        deltaTime = 0f;
                    }
                    else
                    {
                        deltaTime = (currentTicks - effectTime.TicksAtLastUpdate) / 10000000f;
                    }

                    effectTime.TicksAtLastUpdate = currentTicks;
                    effectTime.Effect.Update(deltaTime);


                    if (effectTime.Effect.IsDone)
                    {
                        EffectTimes.RemoveAt(i);
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Removes an effect
        /// </summary>
        /// <param name="effect">The effect to remove.</param>
        public virtual void RemoveEffect(IEffect <T> effect)
        {
            EffectTimeContainer effectTimeToRemove = EffectTimes.FirstOrDefault(x => x.Effect == effect);

            if (effectTimeToRemove == null)
            {
                return;
            }

            effect.OnDetach(EffectTarget);
            EffectTimes.Remove(effectTimeToRemove);
        }