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); } } }
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(); }
public GoapFsm(GoapAgent agent) { this.agent = agent; }
public abstract IEnumerator Update(GoapAgent agent);
public abstract IEnumerator CheckInRange(GoapAgent agent);
public abstract IEnumerator CheckActive(GoapAgent agent);
public GoapAction(GoapAgent goapAgent, GoapActionManager goapActionManager) { InitStatus(); this.goapAgent = goapAgent; this.goapActionManager = goapActionManager; }