Ejemplo n.º 1
0
        internal static void Frame()
        {
            ++FrameCount;

            // Check for a changing time scale
            if (s_newTimeScale.HasValue)
            {
                float old = s_timeScale;
                s_timeScale = s_newTimeScale.Value;
                TimeScaleChanged?.Invoke(old, s_timeScale);
                s_newTimeScale = null;
            }

            // Update the timing values
            LastElapsedTime = ElapsedTime;
            ElapsedTime     = s_timer.Elapsed;
            RealDeltaTime   = ElapsedTime - s_lastTime;
            DeltaTime       = TimeSpan.FromTicks((long)(RealDeltaTime.Ticks * s_timeScale));
            s_lastTime      = ElapsedTime;

            // Update the FPS history and re-calculate (small bump to prevent division by zero)
            RawFPS = s_fpsHistory[s_currIndex] = 1000f / ((float)RealDeltaTime.TotalMilliseconds + 0.01f);
            float last = s_fpsHistory[s_nextIndex];

            if (FrameCount > FPS_HISTORY_SIZE)
            {
                FPS = s_fpsHistory.Average();
            }
            else
            {
                FPS = s_fpsHistory.Sum() / FrameCount;
            }
            s_currIndex = s_nextIndex;
        }
Ejemplo n.º 2
0
 public void SendTimeScaleChangedEvent()
 {
     TimeScaleChanged.Invoke();
 }