Exemple #1
0
        public void CheckWorkers()
        {
            ReGoapPlanWork <T, W>?checkWork = null;

            if (WorksQueue.Count > 0)
            {
                lock (WorksQueue)
                {
                    checkWork = WorksQueue.Dequeue();
                }
            }
            if (checkWork != null)
            {
                var work = checkWork.Value;
                planner.Plan(work.Agent, work.BlacklistGoal, work.Actions,
                             (newGoal) => onDonePlan(this, work, newGoal));
            }
        }
Exemple #2
0
        protected virtual bool CalculateNewGoal(bool forceStart = false)
        {
            if (IsPlanning)
            {
                return(false);
            }
            if (!forceStart && (Time.time - lastCalculationTime <= CalculationDelay))
            {
                return(false);
            }
            lastCalculationTime = Time.time;

            interruptOnNextTransistion = false;
            UpdatePossibleGoals();
            //var watch = System.Diagnostics.Stopwatch.StartNew();
            CurrentReGoapPlanWorker = ReGoapPlannerManager <T, W> .Instance.Plan(this, BlackListGoalOnFailure?currentGoal : null,
                                                                                 currentGoal != null?currentGoal.GetPlan() : null, OnDonePlanning);

            return(true);
        }