void fastForwardFireBoltActions(FireBoltActionList actions, float targetTime, FireBoltActionList executingActions) { //complete and remove from executing all actions that will be done by targetTime List <FireBoltAction> removeList = new List <FireBoltAction>(); foreach (FireBoltAction action in executingActions) { if (actionComplete(action, targetTime)) { action.Skip(); removeList.Add(action); } } foreach (FireBoltAction action in removeList) { executingActions.Remove(action); } //iterate over action queue, //skipping to end of actions that will be completed at target time //appending to executing queue actions that will still be in progress at target time while (actions.NextActionIndex < actions.Count && actions[actions.NextActionIndex].StartTick() <= targetTime) { FireBoltAction action = actions[actions.NextActionIndex]; actions.NextActionIndex++; if (action.Init()) { if (!actionComplete(action, targetTime)) { executingActions.Add(action); } else { action.Skip(); } } } }
/// <summary> /// appends and removes from the executing lists based on the time and the last action /// appended from the full list of actions /// </summary> /// <param name="actions">action list of either story or discourse actions. both will be update each frame</param> /// <param name="executingActions">executing list for story or discourse actions. should match first parameter</param> /// <param name="referenceTime">current story or discourse time. also should match the lists</param> void updateFireBoltActions(FireBoltActionList actions, FireBoltActionList executingActions, float referenceTime) { //stop things that should be finished now and remove them from the executing list List <FireBoltAction> removeList = new List <FireBoltAction>(); foreach (FireBoltAction action in executingActions) { if (actionComplete(action, referenceTime) || action.StartTick() > referenceTime) { action.Stop(); removeList.Add(action); } } foreach (FireBoltAction action in removeList) { executingActions.Remove(action); } //go through the full action list until the next action shouldn't have started yet while (actions.NextActionIndex < actions.Count && actions[actions.NextActionIndex].StartTick() <= referenceTime) { FireBoltAction action = actions[actions.NextActionIndex]; actions.NextActionIndex++; if (action.Init()) { if (actionComplete(action, referenceTime)) { action.Skip(); //if the new action should have already completed, run the skip on it } else { executingActions.Add(action); } } } }