// FUNCTIONS //////////////////////////////////////////////////////////////////////////////// public FogThread(FogPool pool) { Pool = pool; State = ThreadState.RUNNING; _Thread = new Thread(ThreadRun); _Thread.Start(); }
public void StartGenerate(LevelConstructor levelConstructor, TileGeneration startTile) { _levelConstructor = levelConstructor; _fogZPosition = startTile.GetPosition().z - startTile.GetSize().z *_startOfsetPosition; _fogStep = startTile.GetSize().z; _pool = FindObjectOfType <FogPool>(); GenerateFog(); StartCoroutine(NextGnerateFog()); }
//////////////////////////////////////////////////////////////////////////////// void Update() { if (!UpdateAutomatically) { return; } // prepare threads if (MultiThreaded) { if (_ThreadPool == null) { _ThreadPool = new FogPool(); } Threads = Mathf.Clamp(Threads, 2, 8); _ThreadPool.MaxThreads = Threads; _ThreadPool.Clean(); } else if (_ThreadPool != null) { _ThreadPool.StopAllThreads(); _ThreadPool = null; } _StopWatch.Reset(); _StopWatch.Start(); // draw shapes ProcessUnits(true); // compile final texture _TimeSinceLastUpdate += Time.deltaTime; CompileFinalTexture(ref _TimeSinceLastUpdate, true); _StopWatch.Stop(); }