예제 #1
0
        private void CreatePerformState()
        {
            _performState = (fsm, fsmGameObject) =>
            {
                // all actions done, plan over...
                if (_plan.Count == 0)
                {
                    _dataProvider.PlanFinished();
                    fsm.PopState();
                    fsm.PushState(_idleState);
                    return;
                }

                // if action done (in other words, has exited)
                var action = _plan.Peek();
                if (action.IsDone())
                {
                    _plan.Pop();
                    return;
                }

                // action go!
                if (!action.Go(this))
                {
                    _dataProvider.PlanAborted(action);
                    fsm.PopState();
                    fsm.PushState(_idleState);
                }
            };
        }