Exemple #1
0
    public void Loop()
    {
        if (_currGoal == null)
        {
            _currGoal = FindNewGoal();
            if (_currGoal == null)
            {
                return;
            }

            _currGoal.BuildPlan(actions, _ws);
        }
        else if (_currGoal.IsInterruptible())
        {
            GOAPGoal newGoal = FindNewGoal(); // 遇见更优的目标
            if (newGoal != null && /*newGoal.GoalType != _currGoal.GoalType &&*/ newGoal.Weight > _currGoal.Weight)
            {
                GOAPGoalFactory.Collect(_currGoal);
                _currGoal = newGoal;
                _currGoal.BuildPlan(actions, _ws);
            }
        }

        if (!_currGoal.UpdateGoal(_ws))
        {
            GOAPGoalFactory.Collect(_currGoal);
            _currGoal = null;
        }
    }