Exemple #1
0
        // This is mostly copied from MyProgram.Main(), with UI stripped out.
        protected virtual void InitSandbox(string[] args)
        {
            m_args = args;
            // Infinario was removed from SE in update 1.184.6, but is still in ME
            var infinario = typeof(MyFakes).GetField("ENABLE_INFINARIO");

            if (infinario != null)
            {
                infinario.SetValue(null, false);
            }

            if (m_game != null)
            {
                m_game.Exit();
            }

            if (!SetupBasicGameInfo())
            {
                return;
            }

            // Init null render so profiler-enabled builds don't crash
            var render = new MyNullRender();

            MyRenderProxy.Initialize(render);
#if SE
            EmptyKeys.UserInterface.Engine engine = (EmptyKeys.UserInterface.Engine) new VRage.UserInterface.MyEngine();

            if (System.Diagnostics.Debugger.IsAttached)
            {
                m_startup.CheckSteamRunning();        // Just give the warning message box when debugging, ignore for release
            }
            if (!Sandbox.Engine.Platform.Game.IsDedicated)
            {
                MyFileSystem.InitUserSpecific(m_steamService.UserId.ToString());
            }
#endif

            try
            {
#if !SE
                MyRenderProxy.GetRenderProfiler().SetAutocommit(false);
                MyRenderProxy.GetRenderProfiler().InitMemoryHack("MainEntryPoint");
#endif
                // NOTE: an assert may be thrown in debug, about missing Tutorials.sbx. Ignore it.
                m_game = InitGame();

                // Initializing the workshop means the categories are available
                var initWorkshopMethod = m_game.GetType().GetMethod("InitSteamWorkshop", BindingFlags.NonPublic | BindingFlags.Instance);
                MyDebug.AssertRelease(initWorkshopMethod != null);

                if (initWorkshopMethod != null)
                {
                    var parameters = initWorkshopMethod.GetParameters();
                    MyDebug.AssertRelease(parameters.Count() == 0);
                }

                if (initWorkshopMethod != null)
                {
                    initWorkshopMethod.Invoke(m_game, null);
                }
                else
                {
                    MySandboxGame.Log.WriteLineAndConsole(string.Format(Constants.ERROR_Reflection, "InitSteamWorkshop"));
                }
            }
            catch (Exception ex)
            {
                // This shouldn't fail, but don't stop even if it does
                ex.Log("WARNING: An exception occured, ignoring: ");
            }

            AuthenticateWorkshop();
        }