示例#1
0
        /// <summary>
        /// Creates the action tree for a goal
        /// </summary>
        /// <param name="goal">Starting point</param>
        void CreateTree(GoapGoal goal)
        {
            List <GoapAction> actions = GetMatchingGoalChilds(goal);

            goal.SetChilds(actions);

            editorDirty = true;
        }
示例#2
0
 /// <summary>
 /// Draws the given goal
 /// </summary>
 /// <param name="goal"></param>
 private void DrawGoal(GoapGoal goal)
 {
     EditorGUILayout.LabelField(goal.GetType().Name);
     //EditorGUILayout.BeginVertical("Box");
     foreach (GoapAction child in goal.childs)
     {
         DrawAction(child);
     }
     //EditorGUILayout.EndVertical();
 }
示例#3
0
        /// <summary>
        /// Returns a list of all actions that have the same goal
        /// </summary>
        /// <param name="parent">The parent goal</param>
        /// <returns>A list of (new) matching goals</returns>
        List <GoapAction> GetMatchingGoalChilds(GoapGoal parent)
        {
            List <GoapAction> matches = new List <GoapAction>();

            foreach (GoapAction action in possibleActions)
            {
                if (action.goal == parent.key)
                {
                    GoapAction tAction = action.Clone();

                    tAction.SetChilds(GetMatchingActionChilds(tAction));

                    matches.Add(tAction);
                }
            }

            return(matches);
        }