Beispiel #1
0
    void CreatePlan(GOAPGoal goal)
    {
        GOAPPlan plan = BuildPlan(goal);

        if (plan == null)
        {
            if (Owner.debugGOAP)
            {
                Debug.Log(Time.timeSinceLevelLoad + " BUILD PLAN - " + goal.ToString() + " FAILED !!! " + Owner.WorldState.ToString(), Owner);
            }
            goal.SetDisableTime();
            return;
        }

        if (CurrentGoal != null)
        {
            CurrentGoal.Deactivate();
            CurrentGoal = null;
        }

        if (Owner.debugGOAP)
        {
            Debug.Log(Time.timeSinceLevelLoad + " BUILD " + goal.ToString() + " - " + plan.ToString() + " " + Owner.WorldState.ToString(), Owner);
            foreach (KeyValuePair <E_GOAPGoals, GOAPGoal> pair in Goals)
            {
                if (pair.Value != goal && pair.Value.GoalRelevancy > 0)
                {
                    Debug.Log(pair.Value.ToString());
                }
            }
        }

        CurrentGoal = goal;
        CurrentGoal.Activate(plan);
    }
Beispiel #2
0
    void FindNewGoal()
    {
        if (CurrentGoal != null)
        {
            CurrentGoal.Deactivate();
            CurrentGoal = null;
        }

        while (CurrentGoal == null)
        {
            GOAPGoal newGoal = GetMostImportantGoal(0);

            if (newGoal == null)
            {
                break;
            }

            if (Owner.debugGOAP)
            {
                Debug.Log("Find new goal " + newGoal.ToString() + "WorldState - " + Owner.WorldState.ToString());
            }

            CreatePlan(newGoal);

            if (CurrentGoal == null)
            {
                newGoal.SetDisableTime();
            }
        }
    }