private IEnumerator ExecuteReadyActionsCoroutine() { while (InitActions.Count > 0) { InitAction action = InitActions[0]; if (action.CanBegin()) { action.Initialize(this, m_eventDispatcher); InitActions.RemoveAt(0); action.Begin(); if (m_runAsCoroutine) { yield return(m_coroutineOwner.StartCoroutine(action.Perform())); } else { CoroutineHelper.RunCoroutineToCompletion(action.Perform()); } yield return(null); } else if (action.completed) { InitActions.RemoveAt(0); } } }
private void RecursiveValidateAction(InitAction action, Type dependencyType, string breadcrumbs) { if (action.TopologicalDependencies.Contains(dependencyType.ToString())) { string message = "[ValidateDependencies] Found Circular Dependency: " + breadcrumbs; Log.LogFatal(this, message); throw new ApplicationException(message); } foreach (string antecedentName in action.TopologicalDependencies) { List <InitAction> initActions = InitActions; Predicate <InitAction> match = (InitAction a) => a.GetType().ToString() == antecedentName; InitAction initAction = initActions.Find(match); if (initAction == null) { CompletedInitAction completedInitAction = m_completedActions.Find((CompletedInitAction a) => a.TopologicalIdentifier.Equals(antecedentName)); if (completedInitAction == null) { string message = "[ValidateDependencies] Missing Dependency: " + breadcrumbs + " -> " + antecedentName; Log.LogFatal(this, message); throw new ApplicationException(message); } break; } RecursiveValidateAction(initAction, dependencyType, breadcrumbs + " -> " + initAction.ActionName); } }
private void ValidateDependencies() { for (int i = 0; i < InitActions.Count; i++) { InitAction initAction = InitActions[i]; RecursiveValidateAction(initAction, initAction.GetType(), initAction.ActionName); } }
private bool OnInitActionComplete(ActionCompleteEvent evt) { InitAction initAction = evt.Action as InitAction; if (initAction != null) { m_completedActions.AddIfUnique(new CompletedInitAction(initAction.TopologicalIdentifier, initAction.TopologicalDependencies)); } if (CheckAllComplete()) { OnAllInitComplete(); } return(false); }
public void AddInitAction(InitAction action) { InitActions.Add(action); }