void ProcessUnits(bool checkstopwatch) { // remove any invalid units FogOfWarUnit.registeredUnits.RemoveAll(u => u == null); double millisecondfrequency = 1000.0 / System.Diagnostics.Stopwatch.Frequency; for (; _currentUnitProcessing < FogOfWarUnit.registeredUnits.Count; ++_currentUnitProcessing) { if (!FogOfWarUnit.registeredUnits[_currentUnitProcessing].isActiveAndEnabled || FogOfWarUnit.registeredUnits[_currentUnitProcessing].team != team) { continue; } FogOfWarShape shape = FogOfWarUnit.registeredUnits[_currentUnitProcessing].GetShape(this, physics, plane); if (multithreaded && updateAutomatically) { _threadPool.Run(() => _drawer.Draw(shape)); } else { _drawer.Draw(shape); } // do the timer check here so that at least one unit will be processed! if (checkstopwatch && _stopwatch.ElapsedTicks * millisecondfrequency >= maxMillisecondsPerFrame) { ++_currentUnitProcessing; break; } } }
void ProcessUnits(System.Diagnostics.Stopwatch stopwatch) { // if we are not updating units and all units have finished processing if (!updateUnits && _currentUnitProcessing >= FogOfWarUnit.registeredUnits.Count) { return; } // remove any invalid units FogOfWarUnit.registeredUnits.RemoveAll(u => u == null); double millisecondfrequency = 1000.0 / System.Diagnostics.Stopwatch.Frequency; for (; _currentUnitProcessing < FogOfWarUnit.registeredUnits.Count; ++_currentUnitProcessing) { if (!FogOfWarUnit.registeredUnits[_currentUnitProcessing].isActiveAndEnabled || FogOfWarUnit.registeredUnits[_currentUnitProcessing].team != team) { continue; } FogOfWarShape shape = FogOfWarUnit.registeredUnits[_currentUnitProcessing].GetShape(this, physics, plane); if (multithreaded) { _threadPool.Run(() => _drawer.Draw(shape, true)); } else { _drawer.Draw(shape, false); } // do the timer check here so that at least one unit will be processed if (stopwatch != null && _stopwatch.ElapsedTicks * millisecondfrequency >= maxMillisecondsPerFrame) { ++_currentUnitProcessing; break; } } }