Esempio n. 1
0
 public FogOfWarThread(FogOfWarThreadPool pool)
 {
     threadPool = pool;
     state      = FogOfWarThreadState.Running;
     _thread    = new Thread(ThreadRun);
     _thread.Start();
 }
Esempio n. 2
0
        void Update()
        {
            if (!updateAutomatically)
            {
                return;
            }

            // prepare threads
            if (multithreaded)
            {
                if (_threadPool == null)
                {
                    _threadPool = new FogOfWarThreadPool();
                }
                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();
        }