private IEnumerator RepeatEvent(ILevelEvent ev, int repeats, float delay)
    {
        Assert.IsTrue(repeats > 0);
        while (repeats > 0)
        {
            yield return(new WaitForSeconds(delay));

            ev.DoEvent(this);
            repeats--;
        }
    }
    private void Update()
    {
        float levelTime = Time.time - m_levelStartTime;

        while (m_timelineIterator < Timeline.Count &&
               levelTime >= Timeline[m_timelineIterator].eventTime)
        {
            TimelineEvent timelineEntry = Timeline[m_timelineIterator];
            ILevelEvent   levelEvent    = (timelineEntry.Event as ILevelEvent);
            levelEvent.DoEvent(this);
            if (timelineEntry.repeatAdditionalTimes > 0)
            {
                StartCoroutine(RepeatEvent(levelEvent, timelineEntry.repeatAdditionalTimes,
                                           timelineEntry.repeatDelay));
            }
            m_timelineIterator++;
        }

        //for (int i = activeEnemies.Count - 1; i > 0; i--)
        //{
        //    if (toDeactivate.Contains(activeEnemies[i]))
        //    {
        //        activeEnemies[i].pooled.returnToPool();
        //        activeEnemies.RemoveAt(i);
        //    }
        //}
        //toDeactivate.Clear();

        //foreach (var enemy in activeEnemies)
        //{
        //    var t = enemy.transform.position;
        //    UpdateEnemyPosition(enemy, Time.time - enemy.SpawnTime);
        //    if (Vector3.Distance(enemy.transform.position, t) > 0.5f)
        //    {
        //        Debug.LogError("discontinuity");
        //    }
        //}
    }