Tick() public method

public Tick ( ) : void
return void
Ejemplo n.º 1
0
        static void TickInner(OrderManager orderManager)
        {
            int t  = Environment.TickCount;
            int dt = t - orderManager.LastTickTime;

            if (dt >= Settings.Game.Timestep)
            {
                using (new PerfSample("tick_time"))
                {
                    orderManager.LastTickTime += Settings.Game.Timestep;
                    Ui.Tick();
                    var world = orderManager.world;
                    if (orderManager.GameStarted)
                    {
                        ++Viewport.TicksSinceLastMove;
                    }

                    Sound.Tick();
                    Sync.CheckSyncUnchanged(world, orderManager.TickImmediate);

                    if (world != null)
                    {
                        var isNetTick = LocalTick % NetTickScale == 0;

                        if (!isNetTick || orderManager.IsReadyForNextFrame)
                        {
                            ++orderManager.LocalFrameNumber;

                            Log.Write("debug", "--Tick: {0} ({1})", LocalTick, isNetTick ? "net" : "local");

                            if (isNetTick)
                            {
                                orderManager.Tick();
                            }

                            Sync.CheckSyncUnchanged(world, () =>
                            {
                                world.OrderGenerator.Tick(world);
                                world.Selection.Tick(world);
                            });

                            world.Tick();

                            PerfHistory.Tick();
                        }
                        else
                        if (orderManager.NetFrameNumber == 0)
                        {
                            orderManager.LastTickTime = Environment.TickCount;
                        }

                        Sync.CheckSyncUnchanged(world, () => world.TickRender(worldRenderer));

                        cursorFrame += 0.5f;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        static void InnerLogicTick(OrderManager orderManager)
        {
            var tick = RunTime;

            var world = orderManager.World;

            if (Ui.LastTickTime.ShouldAdvance(tick))
            {
                Ui.LastTickTime.AdvanceTickTime(tick);
                Sync.RunUnsynced(Settings.Debug.SyncCheckUnsyncedCode, world, Ui.Tick);
                Cursor.Tick();
            }

            if (orderManager.LastTickTime.ShouldAdvance(tick))
            {
                using (new PerfSample("tick_time"))
                {
                    orderManager.LastTickTime.AdvanceTickTime(tick);

                    Sound.Tick();

                    Sync.RunUnsynced(Settings.Debug.SyncCheckUnsyncedCode, world, orderManager.TickImmediate);

                    if (world == null)
                    {
                        return;
                    }

                    if (orderManager.TryTick())
                    {
                        Sync.RunUnsynced(Settings.Debug.SyncCheckUnsyncedCode, world, () =>
                        {
                            world.OrderGenerator.Tick(world);
                        });

                        world.Tick();

                        PerfHistory.Tick();
                    }

                    // Wait until we have done our first world Tick before TickRendering
                    if (orderManager.LocalFrameNumber > 0)
                    {
                        Sync.RunUnsynced(Settings.Debug.SyncCheckUnsyncedCode, world, () => world.TickRender(worldRenderer));
                    }
                }

                benchmark?.Tick(LocalTick);
            }
        }
Ejemplo n.º 3
0
        static void InnerLogicTick(OrderManager orderManager)
        {
            var tick = RunTime;

            var world = orderManager.World;

            var uiTickDelta = tick - Ui.LastTickTime;

            if (uiTickDelta >= Timestep)
            {
                // Explained below for the world tick calculation
                var integralTickTimestep = (uiTickDelta / Timestep) * Timestep;
                Ui.LastTickTime += integralTickTimestep >= TimestepJankThreshold ? integralTickTimestep : Timestep;

                Sync.CheckSyncUnchanged(world, Ui.Tick);
            }

            var worldTimestep  = world == null ? Timestep : world.Timestep;
            var worldTickDelta = tick - orderManager.LastTickTime;

            if (worldTimestep != 0 && worldTickDelta >= worldTimestep)
            {
                using (new PerfSample("tick_time"))
                {
                    // Tick the world to advance the world time to match real time:
                    //    If dt < TickJankThreshold then we should try and catch up by repeatedly ticking
                    //    If dt >= TickJankThreshold then we should accept the jank and progress at the normal rate
                    // dt is rounded down to an integer tick count in order to preserve fractional tick components.
                    var integralTickTimestep = (worldTickDelta / worldTimestep) * worldTimestep;
                    orderManager.LastTickTime += integralTickTimestep >= TimestepJankThreshold ? integralTickTimestep : worldTimestep;

                    Sound.Tick();
                    Sync.CheckSyncUnchanged(world, orderManager.TickImmediate);

                    if (world == null)
                    {
                        return;
                    }

                    var isNetTick = LocalTick % NetTickScale == 0;

                    if (!isNetTick || orderManager.IsReadyForNextFrame)
                    {
                        ++orderManager.LocalFrameNumber;

                        Log.Write("debug", "--Tick: {0} ({1})", LocalTick, isNetTick ? "net" : "local");

                        if (BenchmarkMode)
                        {
                            Log.Write("cpu", "{0};{1}".F(LocalTick, PerfHistory.Items["tick_time"].LastValue));
                        }

                        if (isNetTick)
                        {
                            orderManager.Tick();
                        }

                        Sync.CheckSyncUnchanged(world, () =>
                        {
                            world.OrderGenerator.Tick(world);
                            world.Selection.Tick(world);
                        });

                        world.Tick();

                        PerfHistory.Tick();
                    }
                    else if (orderManager.NetFrameNumber == 0)
                    {
                        orderManager.LastTickTime = RunTime;
                    }

                    // Wait until we have done our first world Tick before TickRendering
                    if (orderManager.LocalFrameNumber > 0)
                    {
                        Sync.CheckSyncUnchanged(world, () => world.TickRender(worldRenderer));
                    }
                }
            }
        }
Ejemplo n.º 4
0
        static void InnerLogicTick(OrderManager orderManager)
        {
            var tick = RunTime;

            var world = orderManager.World;

            var uiTickDelta = tick - Ui.LastTickTime;

            if (uiTickDelta >= Ui.Timestep)
            {
                // Explained below for the world tick calculation
                var integralTickTimestep = (uiTickDelta / Ui.Timestep) * Ui.Timestep;
                Ui.LastTickTime += integralTickTimestep >= TimestepJankThreshold ? integralTickTimestep : Ui.Timestep;

                Sync.RunUnsynced(Settings.Debug.SyncCheckUnsyncedCode, world, Ui.Tick);
                Cursor.Tick();
            }

            var worldTimestep = world == null ? Ui.Timestep :
                                world.IsLoadingGameSave ? 1 :
                                world.IsReplay ? world.ReplayTimestep :
                                world.Timestep;

            var worldTickDelta = tick - orderManager.LastTickTime;

            if (worldTimestep != 0 && worldTickDelta >= worldTimestep)
            {
                using (new PerfSample("tick_time"))
                {
                    // Tick the world to advance the world time to match real time:
                    //    If dt < TickJankThreshold then we should try and catch up by repeatedly ticking
                    //    If dt >= TickJankThreshold then we should accept the jank and progress at the normal rate
                    // dt is rounded down to an integer tick count in order to preserve fractional tick components.
                    var integralTickTimestep = (worldTickDelta / worldTimestep) * worldTimestep;
                    orderManager.LastTickTime += integralTickTimestep >= TimestepJankThreshold ? integralTickTimestep : worldTimestep;

                    Sound.Tick();
                    Sync.RunUnsynced(Settings.Debug.SyncCheckUnsyncedCode, world, orderManager.TickImmediate);

                    if (world == null)
                    {
                        return;
                    }

                    var isNetTick = LocalTick % NetTickScale == 0;

                    if (!isNetTick || orderManager.IsReadyForNextFrame)
                    {
                        ++orderManager.LocalFrameNumber;

                        if (isNetTick)
                        {
                            orderManager.Tick();
                        }

                        Sync.RunUnsynced(Settings.Debug.SyncCheckUnsyncedCode, world, () =>
                        {
                            world.OrderGenerator.Tick(world);
                        });

                        world.Tick();

                        PerfHistory.Tick();
                    }
                    else if (orderManager.NetFrameNumber == 0)
                    {
                        orderManager.LastTickTime = RunTime;
                    }

                    // Wait until we have done our first world Tick before TickRendering
                    if (orderManager.LocalFrameNumber > 0)
                    {
                        Sync.RunUnsynced(Settings.Debug.SyncCheckUnsyncedCode, world, () => world.TickRender(worldRenderer));
                    }
                }

                benchmark?.Tick(LocalTick);
            }
        }
Ejemplo n.º 5
0
        static void TickInner(OrderManager orderManager)
        {
            var tick = Environment.TickCount;

            var world       = orderManager.world;
            var uiTickDelta = tick - Ui.LastTickTime;

            if (uiTickDelta >= Timestep)
            {
                // Explained below for the world tick calculation
                var integralTickTimestep = (uiTickDelta / Timestep) * Timestep;
                Ui.LastTickTime += integralTickTimestep >= TimestepJankThreshold ? integralTickTimestep : Timestep;

                Viewport.TicksSinceLastMove += uiTickDelta / Timestep;

                Sync.CheckSyncUnchanged(world, Ui.Tick);
                cursorFrame += 0.5f;
            }

            var worldTimestep  = world == null ? Timestep : world.Timestep;
            var worldTickDelta = (tick - orderManager.LastTickTime);

            if (worldTimestep != 0 && worldTickDelta >= worldTimestep)
            {
                using (new PerfSample("tick_time"))
                {
                    // Tick the world to advance the world time to match real time:
                    //    If dt < TickJankThreshold then we should try and catch up by repeatedly ticking
                    //    If dt >= TickJankThreshold then we should accept the jank and progress at the normal rate
                    // dt is rounded down to an integer tick count in order to preserve fractional tick components.

                    var integralTickTimestep = (worldTickDelta / worldTimestep) * worldTimestep;
                    orderManager.LastTickTime += integralTickTimestep >= TimestepJankThreshold ? integralTickTimestep : worldTimestep;

                    Sound.Tick();
                    Sync.CheckSyncUnchanged(world, orderManager.TickImmediate);

                    if (world != null)
                    {
                        var isNetTick = LocalTick % NetTickScale == 0;

                        if (!isNetTick || orderManager.IsReadyForNextFrame)
                        {
                            ++orderManager.LocalFrameNumber;

                            Log.Write("debug", "--Tick: {0} ({1})", LocalTick, isNetTick ? "net" : "local");

                            if (isNetTick)
                            {
                                orderManager.Tick();
                            }

                            Sync.CheckSyncUnchanged(world, () =>
                            {
                                world.OrderGenerator.Tick(world);
                                world.Selection.Tick(world);
                            });

                            world.Tick();

                            PerfHistory.Tick();
                        }
                        else
                        if (orderManager.NetFrameNumber == 0)
                        {
                            orderManager.LastTickTime = Environment.TickCount;
                        }

                        Sync.CheckSyncUnchanged(world, () => world.TickRender(worldRenderer));
                    }
                }
            }
        }
Ejemplo n.º 6
0
        static void InnerLogicTick(OrderManager orderManager)
        {
            var tick = RunTime;

            var world = orderManager.World;

            var uiTickDelta = tick - Ui.LastTickTime;

            if (uiTickDelta >= Timestep)
            {
                // Explained below for the world tick calculation
                var integralTickTimestep = (uiTickDelta / Timestep) * Timestep;
                Ui.LastTickTime += integralTickTimestep >= TimestepJankThreshold ? integralTickTimestep : Timestep;

                Sync.RunUnsynced(Settings.Debug.SyncCheckUnsyncedCode, world, Ui.Tick);
                Cursor.Tick();
            }

            var worldTimestep  = world == null ? Timestep : world.IsLoadingGameSave ? 1 : world.Timestep;
            var worldTickDelta = tick - orderManager.LastTickTime;

            if (worldTimestep != 0 && worldTickDelta >= worldTimestep)
            {
                using (new PerfSample("tick_time"))
                {
                    // Tick the world to advance the world time to match real time:
                    //    If dt < TickJankThreshold then we should try and catch up by repeatedly ticking
                    //    If dt >= TickJankThreshold then we should accept the jank and progress at the normal rate
                    // dt is rounded down to an integer tick count in order to preserve fractional tick components.
                    var integralTickTimestep = (worldTickDelta / worldTimestep) * worldTimestep;
                    orderManager.LastTickTime += integralTickTimestep >= TimestepJankThreshold ? integralTickTimestep : worldTimestep;

                    Sound.Tick();

                    if (world == null)
                    {
                        orderManager.TickPreGame();
                        return;
                    }

                    // Collect orders first, we will dispatch them if we can this frame
                    Sync.RunUnsynced(Settings.Debug.SyncCheckUnsyncedCode, world, () =>
                    {
                        world.OrderGenerator.Tick(world);
                    });

                    if (orderManager.TryTick())
                    {
                        Log.Write("debug", "--Tick: {0} ({1})", LocalTick, orderManager.IsNetTick ? "net" : "local");

                        world.Tick();

                        PerfHistory.Tick();
                    }
                    else if (orderManager.NetFrameNumber == 0)
                    {
                        orderManager.LastTickTime = RunTime;
                    }

                    // Wait until we have done our first world Tick before TickRendering
                    if (orderManager.LocalFrameNumber > 0)
                    {
                        Sync.RunUnsynced(Settings.Debug.SyncCheckUnsyncedCode, world, () => world.TickRender(worldRenderer));
                    }
                }

                if (benchmark != null)
                {
                    benchmark.Tick(LocalTick);
                }
            }
        }