public void executeEvent(TimelineEvent e) { if (myQProcessingEvent) { Debug.LogError("Never execute an event from inside a do()"); return; } myEvents.Add(e); myQProcessingEvent = true; e.Do(this); myQProcessingEvent = false; _executeDelay = e.Act(); }
public void reprocessEvents(List <TimelineEvent> events) { theTimeline.StopAllCoroutines(); myEvents.Clear(); myPendingEvents.Clear(); QReprocessingEvents = true; while (events.Count > 0) { TimelineEvent e = events.Pop(0); myEvents.Add(e); e.Do(this); //if ( PlayerList.playerAtPosition(0) != null ) //Debug.Log("e: "+e.Id + "," + e.PlayerPosition+" stack=" + string.Join(",", PlayerList.playerAtPosition(0).StateStack.Select(s => s.ToString()).ToArray())); } QReprocessingEvents = false; StartCoroutine(processEvents()); this.ExecuteLater(0.1f, OnEventsReprocessed); }
IEnumerator processEvents() { while (true) { if (_executeDelay > 0) { yield return(new WaitForSeconds(_executeDelay)); _executeDelay = 0; } if (myPendingEvents.Count > 0) { myQReady = false; TimelineEvent e = myPendingEvents.Pop(0); myEvents.Add(e); myQProcessingEvent = true; try { e.Do(this); } catch (Exception exception) { Debug.LogException(exception); } myQProcessingEvent = false; float delay = e.Act(); if (delay > 0) { yield return(new WaitForSeconds(delay)); } } else { myQReady = true; } yield return(new WaitForEndOfFrame()); } }