コード例 #1
0
        public Flow Do(Flow Execute)
        {
            m_Actions.Add(new FlowAction(Execute));

            if (m_CurrentAction == null)
            {
                m_CurrentAction = m_Actions[0];
            }

            return(this);
        }
コード例 #2
0
        // Interface
        public void Execute()
        {
            if (!IsCompleted)
            {
                if (m_CancelCondition.IsSatisfied())
                {
                    IsCompleted = true;
                    _Reset();
                    return;
                }

                if (!m_CurrentAction.IsExecuted)
                {
                    m_CurrentAction.Execute();
                }

                if (m_CurrentAction.IsExecuted &&
                    m_CurrentAction != m_Actions[m_Actions.Count - 1])
                {
                    m_CurrentAction = m_Actions[m_Actions.FindIndex(A => A == m_CurrentAction) + 1];
                }

                if (m_CurrentAction.IsExecuted && m_CurrentAction == m_Actions[m_Actions.Count - 1])
                {
                    if (m_LoopCondition.IsSatisfied())
                    {
                        m_FlowCompletion?.Invoke();
                        IsCompleted = true;
                    }
                    else
                    {
                        m_CurrentAction = m_Actions[0];
                        _Reset();
                    }
                }
            }
        }