protected virtual void Awake() { ReGoapNode <T, W> .Warmup(NodeWarmupCount); ReGoapState <T, W> .Warmup(StatesWarmupCount); ReGoapLogger.Level = LogLevel; if (Instance != null) { Destroy(this); var errorString = "[GoapPlannerManager] Trying to instantiate a new manager but there can be only one per scene."; ReGoapLogger.LogError(errorString); throw new UnityException(errorString); } Instance = this; doneWorks = new List <ReGoapPlanWork <T, W> >(); ReGoapPlannerThread <T, W> .WorksQueue = new Queue <ReGoapPlanWork <T, W> >(); planners = new ReGoapPlannerThread <T, W> [ThreadsCount]; threads = new Thread[ThreadsCount]; if (MultiThread) { ReGoapLogger.Log(String.Format("[GoapPlannerManager] Running in multi-thread mode ({0} threads).", ThreadsCount)); for (int i = 0; i < ThreadsCount; i++) { planners[i] = new ReGoapPlannerThread <T, W>(PlannerSettings, OnDonePlan); var thread = new Thread(planners[i].MainLoop); thread.Start(); threads[i] = thread; } } // no threads run else { ReGoapLogger.Log("[GoapPlannerManager] Running in single-thread mode."); planners[0] = new ReGoapPlannerThread <T, W>(PlannerSettings, OnDonePlan); } }