protected sealed override bool Arrived(GOAPAStarNode node, GOAPAStarNode finish) { if (node == null) { return(false); } return(_goal.IsFinished(node.nodeWS)); }
public void OnUpdate() { if (_curGoal != null) { if (_curGoal.IsAborted() || _curGoal.IsFinished(WorldState) || _plan.IsAborted()) { _curGoal.OnExit(WorldState); if (onGoalExit != null) { onGoalExit.Invoke(false); } _curGoal = null; } } GOAPGoal topGoal = FindTopGoal(); if (topGoal == null /*|| topGoal.IsAborted()*/ || topGoal.IsFinished(WorldState)) { // 如果topGoal不合理 if (_curGoal != null) { _plan.OnUpdate(); } return; } // 如果是新的topGoal if (_curGoal != topGoal) { if (_curGoal != null) { _curGoal.OnExit(WorldState); if (onGoalExit != null) { onGoalExit.Invoke(true); } } _curGoal = topGoal; foreach (var action in _actions) { action.BeforeBuildPlan(_curGoal); } _plan.Build(WorldState, _curGoal); _curGoal.OnEnter(WorldState); } else if (_plan.IsEmpty()) // TopGoal不变 { _plan.Build(WorldState, _curGoal); } _plan.OnUpdate(); }