public void UpdateEffects(double timeElapsed)
{
List<ICellEffect> effectsToRemove = new List<ICellEffect>();
foreach (var effectData in _effects.Values)
{
List<Cell> cellsToRemove = new List<Cell>();
effectData.Effect.Update(timeElapsed);
foreach (var cell in effectData.Cells)
{
effectData.Effect.Apply(cell);
if (effectData.Effect.IsFinished && effectData.Effect.RemoveOnFinished)
cellsToRemove.Add(cell);
}
foreach (var cell in cellsToRemove)
{
effectData.Effect.Clear(cell);
effectData.Cells.Remove(cell);
_effectCells.Remove(cell);
cell.Effect = null;
}
if (effectData.Cells.Count == 0)
effectsToRemove.Add(effectData.Effect);
}
foreach (var effect in effectsToRemove)
_effects.Remove(effect);
}