Beispiel #1
0
            internal static void Start(object obj)
            {
                _queue = new ConcurrentWorkQueue <Action>(action => action());

                Game.Init();
                RunService.Init();
                SocialService.Init();
                HttpService.Init();
                ScriptService.Init();
                //AnalyticsService.Init();

                _resetter.Set();
                var stopwatch        = Stopwatch.StartNew();
                var physicsStopwatch = Stopwatch.StartNew();

                while (!CancelTokenSource.IsCancellationRequested)
                {
                    var step = stopwatch.Elapsed.TotalSeconds;
                    stopwatch.Restart();

                    // User Input
                    InputService.Step();

                    Game.FocusedCamera?.UpdateCamera(step);

                    // Network Replication
                    Game.NetworkServer?.Update(step);
                    Game.NetworkClient?.Update(step);

                    // wait() resume
                    ScriptService.ResumeWaitingScripts();

                    // Stepped
                    RunService.Update(step);
                    _queue.Work();

                    // Physics
                    var physicsStep = (float)physicsStopwatch.Elapsed.TotalSeconds;
                    foreach (var world in Game.Worlds)
                    {
                        world.Key.Physics?.Step(physicsStep);
                    }
                    physicsStopwatch.Restart();

                    // Heartbeat
                    RunService.Service.Heartbeat.Fire(step);
                }
            }
Beispiel #2
0
            internal static void Start(object obj)
            {
                _queue = new ConcurrentWorkQueue <Action>(action => action());

                switch (RenderSettings.GraphicsMode)
                {
                case GraphicsMode.Direct3D11:
                    Renderer.Init();
                    break;

                case GraphicsMode.NoGraphics:
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(RenderSettings.GraphicsMode),
                                                          $"Unsupported graphics mode \"{RenderSettings.GraphicsMode}\"");
                }
                Logger.Info("Loading primitives...");
                Primitives.Load();
                Logger.Info("Primitives loaded.");

                if (RenderSettings.GraphicsMode == GraphicsMode.NoGraphics)
                {
                    return;
                }

                _resetter.Set();
                var _stopwatch = Stopwatch.StartNew();

                Logger.Info("Entering render loop...");
                while (!CancelTokenSource.IsCancellationRequested)
                {
                    Renderer.Update(_stopwatch.Elapsed.TotalSeconds);
                    _queue.Work();
                    _stopwatch.Restart();
                }

                Renderer.Shutdown();
            }
Beispiel #3
0
            internal static void Start(object obj)
            {
                _queue = new ConcurrentWorkQueue <Action>(action => action());

                SoundService.Init();

                XAudioDLL = Kernel32.LoadLibraryEx("XAudio2_7.DLL", IntPtr.Zero, (LoadLibraryFlags)0x00000800);

                _resetter.Set();
                //var _stopwatch = Stopwatch.StartNew();

                while (!CancelTokenSource.IsCancellationRequested)
                {
                    if (!SoundService.Update())
                    {
                        if (SoundService.IsCriticalError)
                        {
                            SoundService.Reset();
                        }
                    }
                    _queue.Work();
                    //_stopwatch.Restart();
                }
            }