示例#1
0
        protected void RawTick(TimeSpan elapsedTimePerUpdate, int updateCount = 1)
        {
            TimeSpan totalElapsedTime = TimeSpan.Zero;

            // Reset the time of the next frame
            for (int i = 0; i < updateCount && !IsExiting; i++)
            {
                UpdateTime.Update(UpdateTime.Total + elapsedTimePerUpdate, elapsedTimePerUpdate, true);
                Update(UpdateTime);
                totalElapsedTime += elapsedTimePerUpdate;
            }
        }
示例#2
0
        /// <summary>
        /// Call this method within your overriden <see cref="RawTickProducer"/> to update and draw the game yourself. <br/>
        /// As this version is manual, there are a lot of functionality purposefully skipped: <br/>
        /// clamping elapsed time to a maximum, skipping drawing when the window is minimized, <see cref="ResetElapsedTime"/>, <see cref="SuppressDraw"/>, <see cref="IsFixedTimeStep"/>, <br/>
        /// <see cref="IsDrawDesynchronized"/>, <see cref="MinimizedMinimumUpdateRate"/> / <see cref="WindowMinimumUpdateRate"/> / <see cref="TreatNotFocusedLikeMinimized"/>.
        /// </summary>
        /// <param name="elapsedTimePerUpdate">
        /// The amount of time passed between each update of the game's system,
        /// the total time passed would be <paramref name="elapsedTimePerUpdate"/> * <paramref name="updateCount"/>.
        /// </param>
        /// <param name="updateCount">
        /// The amount of updates that will be executed on the game's systems.
        /// </param>
        /// <param name="drawInterpolationFactor">
        /// See <see cref="DrawInterpolationFactor"/>
        /// </param>
        /// <param name="drawFrame">
        /// Draw a frame.
        /// </param>
        protected void RawTick(TimeSpan elapsedTimePerUpdate, int updateCount = 1, float drawInterpolationFactor = 0, bool drawFrame = true)
        {
            bool     beginDrawSuccessful = false;
            TimeSpan totalElapsedTime    = TimeSpan.Zero;

            try
            {
                beginDrawSuccessful = BeginDraw();

                // Reset the time of the next frame
                for (int i = 0; i < updateCount && !IsExiting; i++)
                {
                    UpdateTime.Update(UpdateTime.Total + elapsedTimePerUpdate, elapsedTimePerUpdate, true);
                    using (Profiler.Begin(GameProfilingKeys.GameUpdate))
                    {
                        Update(UpdateTime);
                    }
                    totalElapsedTime += elapsedTimePerUpdate;
                }

                if (drawFrame && !IsExiting && GameSystems.IsFirstUpdateDone)
                {
                    DrawInterpolationFactor = drawInterpolationFactor;
                    DrawTime.Factor         = UpdateTime.Factor;
                    DrawTime.Update(DrawTime.Total + totalElapsedTime, totalElapsedTime, true);

                    var profilingDraw = Profiler.Begin(GameProfilingKeys.GameDrawFPS);
                    var profiler      = Profiler.Begin(GameProfilingKeys.GameDraw);

                    GraphicsDevice.FrameTriangleCount = 0;
                    GraphicsDevice.FrameDrawCalls     = 0;

                    Draw(DrawTime);

                    profiler.End("Triangle count: {0}", GraphicsDevice.FrameTriangleCount);
                    profilingDraw.End("Frame = {0}, Update = {1:0.000}ms, Draw = {2:0.000}ms, FPS = {3:0.00}", DrawTime.FrameCount, UpdateTime.TimePerFrame.TotalMilliseconds, DrawTime.TimePerFrame.TotalMilliseconds, DrawTime.FramePerSecond);
                }
            }
            finally
            {
                if (beginDrawSuccessful)
                {
                    using (Profiler.Begin(GameProfilingKeys.GameEndDraw))
                    {
                        EndDraw(true);
                    }
                }

                CheckEndRun();
            }
        }
示例#3
0
 public override Task Update(float t)
 {
     m_Update_NetUser.Update(t);
     return(Task.CompletedTask);
 }