Exemplo n.º 1
0
        /// <summary>
        /// Updates data on this goal and all childs
        /// </summary>
        /// <param name="data"></param>
        public void Update(FactSet data)
        {
            UpdateMultiplier(data);

            foreach (GoapAction child in childs)
            {
                child.Update(data);
            }
        }
Exemplo n.º 2
0
        public virtual void Awake()
        {
            goals           = new Dictionary <string, GoapGoal>();
            possibleActions = new List <GoapAction>();
            removeActions   = new List <GoapAction>();
            addActions      = new List <GoapAction>();

            factSet = new FactSet();
        }
Exemplo n.º 3
0
 /// <summary>
 /// Checks if all preconditions are true
 /// </summary>
 /// <param name="data">The dataset it needs to be compared to</param>
 /// <returns>True if all preconditions are true</returns>
 protected bool CheckPreconditions(FactSet data)
 {
     foreach (string key in preconditions.Keys)
     {
         if (!data.CheckFact(key, preconditions[key]))
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 4
0
        /// <summary>
        /// Updates this action, caches all the data
        /// </summary>
        /// <param name="data"></param>
        public virtual void Update(FactSet data)
        {
            UpdateTarget();
            UpdatePosition();

            preconditionsValid        = CheckPreconditions(data);
            proceduralConditionsValid = CheckProceduralPreconditions(data);

            foreach (GoapAction child in childs)
            {
                child.Update(data);
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Checks the procedural conditions of this action
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 protected virtual bool CheckProceduralPreconditions(FactSet data)
 {
     return(target != null && !isBlocked);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Creates a new copy of a dataset
 /// </summary>
 /// <param name="copy"></param>
 public FactSet(FactSet copy)
 {
     data = copy.data;
 }
Exemplo n.º 7
0
 /// <summary>
 /// Implement to update the multiplier of this goal
 /// </summary>
 /// <param name="data"></param>
 public virtual void UpdateMultiplier(FactSet data)
 {
 }