Esempio n. 1
0
        /// <summary>
        /// Fires up the engine. And then it makes noise.
        /// </summary>
        public static void Start(EngineMode engineMode)
        {
#if DEBUG
            IsDebug = true;
#endif
            AppId = 480;
            Mode  = engineMode;

            LogService.ConfigureLoggers();

            Process      = Process.GetCurrentProcess();
            PlatformId   = PlatformId.Windows;
            PlatformType = PlatformType.Desktop;

            TempPath = Path.Combine(Path.GetTempPath(), "dEngine");
            if (Directory.Exists(TempPath))
            {
                ContentProvider.DeleteDirectory(TempPath);
            }
            // otherwise DeleteDirectory won't get called when stop debugging in VS.
            Directory.CreateDirectory(TempPath);

            Logger.Info("Log opened.");
            Logger.Info($"Command line args: {string.Join(" ", Environment.GetCommandLineArgs().Skip(1))})");
            Logger.Info($"Base directory: {Environment.CurrentDirectory}");

            Logger.Info($"Engine mode: {engineMode}");
            Logger.Info($"Graphics mode: {RenderSettings.GraphicsMode}");

            Logger.Info($"User: {Environment.UserName} on {Environment.MachineName}");
            Logger.Info($"CPU: {DebugSettings.CpuName} ({Environment.ProcessorCount} processors)");
            Logger.Info($"Memory: {((long)new ComputerInfo().TotalPhysicalMemory).ToPrettySize()}");

            CancelTokenSource = new CancellationTokenSource();

            Inst.Init();

            Logger.Info("Starting GraphicsThread...");
            StartThread(nameof(GraphicsThread), GraphicsThread.Start);
            GraphicsThread.Wait();
            Logger.Info("GraphicsThread started.");

            Logger.Info("Starting AudioThread...");
            StartThread(nameof(AudioThread), AudioThread.Start);
            AudioThread.Wait();
            Logger.Info("AudioThread started.");

            Logger.Info("Starting GameThread...");
            StartThread(nameof(GameThread), GameThread.Start);
            GameThread.Wait();
            Logger.Info("GameThread started.");

            AppDomain.CurrentDomain.ProcessExit += (s, e) => Shutdown(0);
        }