Beispiel #1
0
        private IEnumerator Idle(GoapFsm fsm, GoapAgent agent)
        {
            if (_actions.Count > 0)
            {
                fsm.Pop();

                var action = _actions.Peek();

                if (CurrentAction != action)
                {
                    CurrentAction = action;
                    GoalActionChanged?.Invoke();
                }

                yield return(action.CheckInRange(agent));

                if (action.InRange)
                {
                    action.Enter();
                    fsm.Push(_doAction);
                }
                else
                {
                    fsm.Push(_doAction);
                    fsm.Push(_walk);
                }
            }
            else
            {
                if (!_manualMode)
                {
                    yield return(Planer(agent));
                }
                else
                {
                    if (CurrentAction != null)
                    {
                        CurrentAction = null;
                        GoalActionChanged?.Invoke();
                    }

                    yield return(0);
                }
            }
        }
Beispiel #2
0
        private IEnumerator Walk(GoapFsm fsm, GoapAgent agent)
        {
            fsm.Pop();
            var action = _actions.Peek();

            _move.SetTarget(action.Target);

            while (_move.pathPending() && !agent.InterruptState)
            {
                yield return(0);
            }

            while (!_move.IsDone() && !agent.InterruptState)
            {
                _move.MoveUpdate();
                yield return(0);
            }

            _move.Stop();

            action.Enter();
        }
Beispiel #3
0
 public GoapFsm(GoapAgent agent)
 {
     this.agent = agent;
 }
Beispiel #4
0
 public abstract IEnumerator Update(GoapAgent agent);
Beispiel #5
0
 public abstract IEnumerator CheckInRange(GoapAgent agent);
Beispiel #6
0
 public abstract IEnumerator CheckActive(GoapAgent agent);
Beispiel #7
0
 public GoapAction(GoapAgent goapAgent, GoapActionManager goapActionManager)
 {
     InitStatus();
     this.goapAgent         = goapAgent;
     this.goapActionManager = goapActionManager;
 }