/// <summary> /// Query the timeline and provide it a timestep to increment by. Any actions which /// have a time between the current and new time will be performed. /// </summary> /// <param name="timeStep"></param> public void QueryTimeline(float timeStep) { // Ensure the simulation is playing but not paused if (playing && !paused) { float start = currentTime; float end = start + timeStep; currentTime = end; // Find actions to execute for (int i = 0; i < actions.Count; i++) { ITimelineAction action = actions[i]; // Does the action fall within the executed period of time? float time = action.GetTimeOfAction(); if (time >= start && time <= end) { action.Execute(); } } // Check for finish CheckFinishState(); } }
/// <summary> /// Add an action to the timeline. /// </summary> /// <param name="action"></param> /// <returns></returns> public bool AddAction(ITimelineAction action) { int id = action.GetActionID(); foreach (ITimelineAction a in actions) { if (a.GetActionID() == id) { return(false); } } actions.Add(action); return(true); }
/// <summary> /// Remove an action from the timeline. /// </summary> /// <param name="action"></param> /// <returns></returns> public bool RemoveAction(ITimelineAction action) { return(actions.Remove(action)); }