// called in another thread private void OnDonePlan(ReGoapPlannerThread <T, W> plannerThread, ReGoapPlanWork <T, W> work, IReGoapGoal <T, W> newGoal) { work.NewGoal = newGoal; lock (doneWorks) { doneWorks.Add(work); } if (work.NewGoal != null && ReGoapLogger.Level == ReGoapLogger.DebugLevel.Full) { ReGoapLogger.Log("[GoapPlannerManager] Done calculating plan, actions list:"); var i = 0; foreach (var action in work.NewGoal.GetPlan()) { ReGoapLogger.Log(string.Format("{0}: {1}", i++, action.Action)); } } }
protected virtual bool CalculateNewGoal(bool forceStart = false) { if (IsPlanning) { return(false); } if (!forceStart && (Time.time - lastCalculationTime <= CalculationDelay)) { return(false); } lastCalculationTime = Time.time; interruptOnNextTransition = false; UpdatePossibleGoals(); //var watch = System.Diagnostics.Stopwatch.StartNew(); startedPlanning = true; currentReGoapPlanWorker = ReGoapPlannerManager <T, W> .Instance.Plan(this, BlackListGoalOnFailure?currentGoal : null, currentGoal != null?currentGoal.GetPlan() : null, OnDonePlanning); return(true); }