private void EndActionParallel(ActionParallel actionParallel) { actionParallel.isRunning = false; ActionEnd[] actionEnds = actionParallel.Ends(this.actions, isSkipping); foreach (ActionEnd actionEnd in actionEnds) { ProcessActionEnd(actionEnd, actions.IndexOf(actionParallel)); } }
/** * <summary>Creates a new instance of the 'ActionList: Run in parallel' Action</summary> * <param name = "actionEnds">An array of data about what output sockets the Action has</param> * <returns>The generated Action</returns> */ public static ActionParallel CreateNew(ActionEnd[] actionEnds) { ActionParallel newAction = (ActionParallel)CreateInstance <ActionParallel>(); newAction.endings = new List <ActionEnd>(); foreach (ActionEnd actionEnd in actionEnds) { newAction.endings.Add(new ActionEnd(actionEnd)); } return(newAction); }
public override void Reset (ActionList actionList) { triggersToWait = 0; int ownIndex = actionList.actions.IndexOf (this); if (ownIndex == 0) { ACDebug.LogWarning ("The Action '" + category.ToString () + ": " + title + "' should not be first in an ActionList, as it will prevent others from running!"); return; } for (int i=0; i<actionList.actions.Count; i++) { Action otherAction = actionList.actions[i]; if (otherAction != this) { if (otherAction is ActionCheck) { ActionCheck actionCheck = (ActionCheck) otherAction; if ((actionCheck.resultActionFail == ResultAction.Skip && actionCheck.skipActionFail == ownIndex) || (actionCheck.resultActionFail == ResultAction.Continue && ownIndex == i+1)) { triggersToWait ++; } else if ((actionCheck.resultActionTrue == ResultAction.Skip && actionCheck.skipActionTrue == ownIndex) || (actionCheck.resultActionTrue == ResultAction.Continue && ownIndex == i+1)) { triggersToWait ++; } } else if (otherAction is ActionCheckMultiple) { ActionCheckMultiple actionCheckMultiple = (ActionCheckMultiple) otherAction; foreach (ActionEnd ending in actionCheckMultiple.endings) { if ((ending.resultAction == ResultAction.Skip && ending.skipAction == ownIndex) || (ending.resultAction == ResultAction.Continue && ownIndex == i+1)) { triggersToWait ++; break; } } } else if (otherAction is ActionParallel) { ActionParallel actionParallel = (ActionParallel) otherAction; foreach (ActionEnd ending in actionParallel.endings) { if ((ending.resultAction == ResultAction.Skip && ending.skipAction == ownIndex) || (ending.resultAction == ResultAction.Continue && ownIndex == i+1)) { triggersToWait ++; break; } } } else { if ((otherAction.endAction == ResultAction.Skip && otherAction.skipAction == ownIndex) || (otherAction.endAction == ResultAction.Continue && ownIndex == i+1)) { triggersToWait ++; } } } } base.Reset (actionList); }
private void EndActionParallel(ActionParallel actionParallel) { actionParallel.isRunning = false; ActionEnd[] actionEnds = actionParallel.Ends (this.actions, isSkipping); foreach (ActionEnd actionEnd in actionEnds) { ProcessActionEnd (actionEnd, actions.IndexOf (actionParallel)); } }
private IEnumerator RunAction(Action action) { if (isChangingScene) { ACDebug.Log("Cannot run Action while changing scene, will resume once loading is complete.", this, action); while (isChangingScene) { yield return(null); } } action.AssignParentList(this); if (useParameters) { action.AssignValues(parameters); } else { action.AssignValues(null); } if (isSkipping) { skipIteractions++; action.Skip(); PrintActionComment(action); } else { if (action is ActionRunActionList) { ActionRunActionList actionRunActionList = (ActionRunActionList)action; actionRunActionList.isSkippable = IsSkippable(); } action.isRunning = false; float waitTime = action.Run(); PrintActionComment(action); if (action is ActionParallel) { } else if (!Mathf.Approximately(waitTime, 0f)) { while (action.isRunning) { if (isChangingScene) { ACDebug.Log("Cannot continue Action while changing scene, will resume once loading is complete.", this, action); while (isChangingScene) { yield return(null); } } bool runInRealtime = (this is RuntimeActionList && actionListType == ActionListType.PauseGameplay && !unfreezePauseMenus && KickStarter.playerMenus.ArePauseMenusOn(null)); if (waitTime < 0) { if (!runInRealtime && Time.timeScale <= 0f) { WaitForEndOfFrame delay = new WaitForEndOfFrame(); while (Time.timeScale <= 0f) { yield return(delay); } } else { yield return(new WaitForEndOfFrame()); } } else if (runInRealtime) { float endTime = Time.realtimeSinceStartup + waitTime; while (Time.realtimeSinceStartup < endTime) { yield return(null); } } else { yield return(new WaitForSeconds(waitTime)); } if (!action.isRunning) { // In rare cases (once an actionlist is reset) isRunning may be false but this while loop will still run ResetList(); break; } waitTime = action.Run(); } } } if (KickStarter.actionListManager.IsListRunning(this)) { ActionParallel actionParallel = action as ActionParallel; if (actionParallel != null) { EndActionParallel(actionParallel); } else { EndAction(action); } } }