Ejemplo n.º 1
0
        protected virtual void OnDonePlanning(IReGoapGoal <T, W> newGoal)
        {
            CurrentReGoapPlanWorker = null;
            if (newGoal == null)
            {
                if (currentGoal == null)
                {
                    ReGoapLogger.LogWarning("GoapAgent " + this + " could not find a plan.");
                }
                return;
            }

            if (currentActionState != null)
            {
                currentActionState.Action.Exit(null);
            }
            currentActionState = null;
            currentGoal        = newGoal;
            var plan = currentGoal.GetPlan();

            startingPlan = plan.ToList();
            ClearPlanValues();
            foreach (var actionState in startingPlan)
            {
                actionState.Action.PostPlanCalculations(this);
            }
            currentGoal.Run(WarnGoalEnd);
            PushAction();
        }
Ejemplo n.º 2
0
 public virtual void WarnGoalEnd(IReGoapGoal <T, W> goal)
 {
     if (goal != currentGoal)
     {
         ReGoapLogger.LogWarning(string.Format("[GoapAgent] Goal {0} warned for end but is not current goal.", goal));
         return;
     }
     CalculateNewGoal();
 }
Ejemplo n.º 3
0
 public virtual void WarnActionFailure(IReGoapAction <T, W> thisAction)
 {
     if (currentActionState != null && thisAction != currentActionState.Action)
     {
         ReGoapLogger.LogWarning(string.Format("[GoapAgent] Action {0} warned for failure but is not current action.", thisAction));
         return;
     }
     if (BlackListGoalOnFailure)
     {
         goalBlacklist[currentGoal] = Time.time + currentGoal.GetErrorDelay();
     }
     CalculateNewGoal(true);
 }