コード例 #1
0
        public override void OnAfterSimulationTick()
        {
            // Send economy packets every two seconds
            if (DateTime.Now.Subtract(_lastEconomyAndDropSync).TotalSeconds > 2)
            {
                ResourceCommandHandler.Send();
                SlowdownHelper.SendDroppedFrames();
                _lastEconomyAndDropSync = DateTime.Now;
            }

            // Finish transactions
            TransactionHandler.FinishSend();
        }
コード例 #2
0
        public override void OnAfterSimulationTick()
        {
            // Send economy and frame drop packets every two seconds
            if (DateTime.Now.Subtract(_lastEconomyAndDropSync).TotalSeconds > 2)
            {
                // Only send economy and dropped frames when connected
                // (loading may accumulate dropped frames we need to ignore)
                if (MultiplayerManager.Instance.IsConnected())
                {
                    ResourceCommandHandler.Send();
                    SlowdownHelper.SendDroppedFrames();
                }
                _lastEconomyAndDropSync = DateTime.Now;
            }

            // Finish transactions
            TransactionHandler.FinishSend();
        }
コード例 #3
0
ファイル: ThreadingExtension.cs プロジェクト: qifengwei/Tango
        public override void OnAfterSimulationTick()
        {
            // Normally, the game is paused when the player is in Esc or similar menus. We ignore this setting.
            if (SimulationManager.instance.ForcedSimulationPaused && MultiplayerManager.Instance.CurrentRole != MultiplayerRole.None)
            {
                SimulationManager.instance.ForcedSimulationPaused = false;
            }

            if (_lastSelectedSimulationSpeed != SimulationManager.instance.SelectedSimulationSpeed)
            {
                Command.SendToAll(new SpeedCommand
                {
                    SelectedSimulationSpeed = SimulationManager.instance.SelectedSimulationSpeed
                });
            }

            if (_lastSimulationPausedState != SimulationManager.instance.SimulationPaused)
            {
                Command.SendToAll(new PauseCommand
                {
                    SimulationPaused = SimulationManager.instance.SimulationPaused
                });
            }

            _lastSimulationPausedState   = SimulationManager.instance.SimulationPaused;
            _lastSelectedSimulationSpeed = SimulationManager.instance.SelectedSimulationSpeed;

            // Send economy packets every two seconds
            if (DateTime.Now.Subtract(lastEconomySync).TotalSeconds > 2)
            {
                ResourceCommandHandler.Send();
                lastEconomySync = DateTime.Now;
            }

            // Finish transactions
            TransactionHandler.FinishSend();
        }