ORTSActSoundSources ORTSActSoundSourceList; // Dictionary of activity sound sources public SoundProcess(Game game) { Game = game; Thread = new Thread(SoundThread); WatchdogToken = new WatchdogToken(Thread); ORTSActSoundSourceList = new ORTSActSoundSources(); }
public LoaderProcess(Game game) { Game = game; Thread = new Thread(LoaderThread); WatchdogToken = new WatchdogToken(Thread); WatchdogToken.SpecialDispensationFactor = 6; CancellationTokenSource = new ORTS.Common.CancellationTokenSource(WatchdogToken.Ping); }
public static float[] ShadowMapLimit; // diameter of shadow map far edge from camera internal RenderProcess(Game game) { Game = game; GameForm = (Form)Control.FromHandle(Game.Window.Handle); WatchdogToken = new WatchdogToken(System.Threading.Thread.CurrentThread); Profiler = new Profiler("Render"); Profiler.SetThread(); Game.SetThreadLanguage(); Game.Window.Title = "Open Rails"; GraphicsDeviceManager = new GraphicsDeviceManager(game); var windowSizeParts = Game.Settings.WindowSize.Split(new[] { 'x' }, 2); GameWindowSize = new Point(Convert.ToInt32(windowSizeParts[0]), Convert.ToInt32(windowSizeParts[1])); FrameRate = new SmoothedData(); FrameTime = new SmoothedDataWithPercentiles(); PrimitiveCount = new int[(int)RenderPrimitiveSequence.Sentinel]; PrimitivePerFrame = new int[(int)RenderPrimitiveSequence.Sentinel]; // Run the game initially at 10FPS fixed-time-step. Do not change this! It affects the loading performance. Game.IsFixedTimeStep = true; Game.TargetElapsedTime = TimeSpan.FromMilliseconds(100); Game.InactiveSleepTime = TimeSpan.FromMilliseconds(100); // Set up the rest of the graphics according to the settings. GraphicsDeviceManager.SynchronizeWithVerticalRetrace = Game.Settings.VerticalSync; GraphicsDeviceManager.PreferredBackBufferFormat = SurfaceFormat.Color; GraphicsDeviceManager.PreferredDepthStencilFormat = DepthFormat.Depth24Stencil8; GraphicsDeviceManager.IsFullScreen = false; GraphicsDeviceManager.PreferMultiSampling = Game.Settings.EnableMultisampling; GraphicsDeviceManager.PreparingDeviceSettings += new EventHandler <PreparingDeviceSettingsEventArgs>(GDM_PreparingDeviceSettings); var screen = Game.Settings.FastFullScreenAltTab ? Screen.FromControl(GameForm) : Screen.PrimaryScreen; if (screen.Primary) { var wa = Screen.PrimaryScreen.WorkingArea; GameForm.Location = new System.Drawing.Point((wa.Right - GameWindowSize.X) / 2, (wa.Bottom - GameWindowSize.Y) / 2); } else { GameForm.Location = new System.Drawing.Point((screen.Bounds.Width - GameWindowSize.X) / 2, (screen.Bounds.Height - GameWindowSize.Y) / 2); } GameWindowOrigin = GameForm.Location; if (Game.Settings.FullScreen) { ToggleFullScreen(); } SynchronizeGraphicsDeviceManager(); }
/// <summary> /// Unregisters a thread token from monitoring by the watchdog. /// </summary> /// <param name="token">The token representing the thread to stop monitoring.</param> public void Unregister(WatchdogToken token) { // We must do this elaborate routine because: // a) We cannot modify Tokens in-place (due to potentially being read from other threads at the same time) // b) We cannot just assign directly (due to potentially being written from other threads at the same time) while (true) { var tokens = Tokens; var newTokens = new List <WatchdogToken>(tokens); newTokens.Remove(token); if (tokens == Interlocked.CompareExchange(ref Tokens, newTokens, tokens)) { break; } } }
public static float[] ShadowMapLimit; // diameter of shadow map far edge from camera internal RenderProcess(Game game) { Game = game; GameForm = (Form)Control.FromHandle(Game.Window.Handle); WatchdogToken = new WatchdogToken(System.Threading.Thread.CurrentThread); Profiler = new Profiler("Render"); Profiler.SetThread(); Game.SetThreadLanguage(); Game.Window.Title = "Open Rails"; GraphicsDeviceManager = new GraphicsDeviceManager(game); var windowSizeParts = Game.Settings.WindowSize.Split(new[] { 'x' }, 2); GameWindowSize = new Point(Convert.ToInt32(windowSizeParts[0]), Convert.ToInt32(windowSizeParts[1])); FrameRate = new SmoothedData(); FrameTime = new SmoothedDataWithPercentiles(); PrimitiveCount = new int[(int)RenderPrimitiveSequence.Sentinel]; PrimitivePerFrame = new int[(int)RenderPrimitiveSequence.Sentinel]; // Run the game initially at 10FPS fixed-time-step. Do not change this! It affects the loading performance. Game.IsFixedTimeStep = true; Game.TargetElapsedTime = TimeSpan.FromMilliseconds(100); Game.InactiveSleepTime = TimeSpan.FromMilliseconds(100); // Set up the rest of the graphics according to the settings. GraphicsDeviceManager.SynchronizeWithVerticalRetrace = Game.Settings.VerticalSync; GraphicsDeviceManager.PreferredBackBufferFormat = SurfaceFormat.Color; GraphicsDeviceManager.PreferredDepthStencilFormat = DepthFormat.Depth24Stencil8; GraphicsDeviceManager.IsFullScreen = Game.Settings.FullScreen; GraphicsDeviceManager.PreferMultiSampling = (AntiAliasingMethod)Game.Settings.AntiAliasing != AntiAliasingMethod.None; GraphicsDeviceManager.HardwareModeSwitch = false; // for fast full-screen Alt-Tab switching GraphicsDeviceManager.PreparingDeviceSettings += new EventHandler <PreparingDeviceSettingsEventArgs>(GDM_PreparingDeviceSettings); }
public UpdaterProcess(Game game) { Game = game; Thread = new Thread(UpdaterThread); WatchdogToken = new WatchdogToken(Thread); }