Esempio n. 1
0
        public void StartExecution()
        {
            if (MoveNext())
            {
                if (Current == null)
                {
                    Debug.LogError($"Found null command!");

                    failedCommands.Add(null);
                    StartExecution();
                    return;
                }

                if (!Current.IsAvailable())
                {
                    StartExecution();
                    return;
                }

                Current.OnSuccess         = OnCommandCompletedHandler;
                Current.OnFail            = OnCommandFailHandler;
                Current.OnProgressChanged = OnCommandProgressChangedHandler;
                OnCommandStartedExecution?.Invoke(Current);
                Current.Execute();
            }
            else
            {
                OnAllCompleted?.Invoke(failedCommands.Count == 0);
            }
        }
 private void Initialize()
 {
     commandExecutor.Initialize(commandsToExecute);
     commandExecutor.OnCommandStartedExecution += (c) => OnCommandStartedExecution?.Invoke(c);
     commandExecutor.OnCommandCompleted        += (c) => OnCommandCompleted?.Invoke(c);
     commandExecutor.OnCommandFailed           += (c, e) => OnCommandFailed?.Invoke(c, e);
     commandExecutor.OnCommandProgressChanged  += (c, p) => OnCommandProgressChanged?.Invoke(c, p);
     commandExecutor.OnAllCompleted            += (wasErrors) => OnLoadingCompleted?.Invoke();
 }