public override int InitGame(string[] args) { MyMedievalGame.SetupBasicGameInfo(); m_startup = new MyCommonProgramStartup(args); VRage.FileSystem.MyFileSystem.Init(MyPerGameSettings.BasicGameInfo.ApplicationName); var appInformation = new VRage.Engine.AppInformation("Medieval Engineers", Medieval.MyMedievalGame.ME_VERSION, "", "", "", Medieval.MyMedievalGame.VersionString); var vrageCore = new VRage.Engine.VRageCore(appInformation, true); var configuration = VRage.Engine.Util.CoreProgram.LoadParameters("MEWT.config"); vrageCore.GetType().GetMethod("LoadSystems", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)?.Invoke(vrageCore, new[] { configuration }); vrageCore.GetType().GetField("m_state", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)?.SetValue(vrageCore, 1); vrageCore.GetType().GetMethod("InitSystems", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)?.Invoke(vrageCore, new object[] { configuration.SystemConfiguration, true }); vrageCore.GetType().GetMethod("LoadMetadata", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)?.Invoke(vrageCore, new[] { configuration }); vrageCore.GetType().GetMethod("InitSystems", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)?.Invoke(vrageCore, new object[] { configuration.SystemConfiguration, false }); m_steamService = new MySteamService(); ((MySteamService)(m_steamService)).Init(new VRage.Steam.MySteamService.Parameters() { Server = MySandboxGame.IsDedicated, AppId = AppId }); VRage.Logging.MyLog.Default = MySandboxGame.Log = new VRage.Logging.MyLog(); MySandboxGame.Log.Init(MyPerGameSettings.BasicGameInfo.ApplicationName + "ModTool.log", null); VRage.Plugins.MyPlugins.Load(); return(base.InitGame(args)); }
protected override bool SetupBasicGameInfo() { SpaceEngineersGame.SetupBasicGameInfo(); m_startup = new MyCommonProgramStartup(m_args); var appDataPath = m_startup.GetAppDataPath(); VRage.Platform.Windows.MyVRageWindows.Init(MyPerGameSettings.BasicGameInfo.ApplicationName, MySandboxGame.Log, appDataPath, false); MyInitializer.InvokeBeforeRun(AppId, MyPerGameSettings.BasicGameInfo.ApplicationName + "ModTool", MyVRage.Platform.System.GetAppDataPath()); MyRenderProxy.Initialize((IMyRender) new MyNullRender()); MyInitializer.InitCheckSum(); if (m_startup.PerformColdStart()) { return(false); } if (!m_startup.Check64Bit()) { return(false); } m_steamService = VRage.Steam.MySteamGameService.Create(MySandboxGame.IsDedicated, AppId); MyServiceManager.Instance.AddService(m_steamService); MyServiceManager.Instance.AddService(VRage.Steam.MySteamUgcService.Create(AppId, m_steamService)); if (m_useModIO) { MyLog.Default.WriteLineAndConsole("Using mod.io service, instead of Steam."); MyServiceManager.Instance.AddService(VRage.Mod.Io.MyModIoService.Create(MySandboxGame.IsDedicated, MyServiceManager.Instance.GetService <IMyGameService>(), ModIO_GameName, ModIO_GameID, ModIO_Key, ModIO_TestGameID, ModIO_TestKey, false)); } SpaceEngineersGame.SetupPerGameSettings(); ManuallyAddDLCs(); return(true); }
public override void Init() { Log.Info("Initializing Torch Client"); base.Init(); if (!File.Exists("steam_appid.txt")) { Directory.SetCurrentDirectory(Path.GetDirectoryName(typeof(VRage.FastResourceLock).Assembly.Location) + "\\.."); } SpaceEngineersGame.SetupBasicGameInfo(); _startup = new MyCommonProgramStartup(RunArgs); if (_startup.PerformReporting()) { return; } _startup.PerformAutoconnect(); if (!_startup.CheckSingleInstance()) { return; } var appDataPath = _startup.GetAppDataPath(); MyInitializer.InvokeBeforeRun(APP_ID, MyPerGameSettings.BasicGameInfo.ApplicationName, appDataPath); MyInitializer.InitCheckSum(); if (!_startup.Check64Bit()) { return; } _startup.DetectSharpDxLeaksBeforeRun(); using (var mySteamService = new SteamService(Game.IsDedicated, APP_ID)) { _renderer = null; SpaceEngineersGame.SetupPerGameSettings(); OverrideMenus(); InitializeRender(); _services = new VRageGameServices(mySteamService); if (!Game.IsDedicated) { MyFileSystem.InitUserSpecific(mySteamService.UserId.ToString()); } } _startup.DetectSharpDxLeaksAfterRun(); MyInitializer.InvokeAfterRun(); }
public override void Init() { Directory.SetCurrentDirectory(Program.SpaceEngineersInstallAlias); MyFileSystem.ExePath = Path.Combine(Program.SpaceEngineersInstallAlias, Program.SpaceEngineersBinaries); Log.Info("Initializing Torch Client"); base.Init(); SpaceEngineersGame.SetupBasicGameInfo(); _startup = new MyCommonProgramStartup(RunArgs); if (_startup.PerformReporting()) { throw new InvalidOperationException("Torch client won't launch when started in error reporting mode"); } _startup.PerformAutoconnect(); if (!_startup.CheckSingleInstance()) { throw new InvalidOperationException("Only one instance of Space Engineers can be running at a time."); } var appDataPath = _startup.GetAppDataPath(); MyInitializer.InvokeBeforeRun(APP_ID, MyPerGameSettings.BasicGameInfo.ApplicationName, appDataPath); MyInitializer.InitCheckSum(); _startup.InitSplashScreen(); if (!_startup.Check64Bit()) { throw new InvalidOperationException("Torch requires a 64bit operating system"); } _startup.DetectSharpDxLeaksBeforeRun(); var steamService = new SteamService(Game.IsDedicated, APP_ID); MyServiceManager.Instance.AddService <IMyGameService>(steamService); _renderer = null; SpaceEngineersGame.SetupPerGameSettings(); // I'm sorry, but it's what Keen does in SpaceEngineers.MyProgram #pragma warning disable 612 SpaceEngineersGame.SetupRender(); #pragma warning restore 612 InitializeRender(); if (!_startup.CheckSteamRunning()) { throw new InvalidOperationException("Space Engineers requires steam to be running"); } if (!Game.IsDedicated) { MyFileSystem.InitUserSpecific(MyGameService.UserId.ToString()); } }
protected override bool SetupBasicGameInfo() { SpaceEngineersGame.SetupBasicGameInfo(); m_startup = new MyCommonProgramStartup(m_args); var appDataPath = m_startup.GetAppDataPath(); VRage.Platform.Windows.MyVRageWindows.Init(MyPerGameSettings.BasicGameInfo.ApplicationName, MySandboxGame.Log, appDataPath, false); MyInitializer.InvokeBeforeRun(AppId, MyPerGameSettings.BasicGameInfo.ApplicationName + "ModTool", MyVRage.Platform.System.GetAppDataPath()); MyRenderProxy.Initialize((IMyRender) new MyNullRender()); MyInitializer.InitCheckSum(); if (m_startup.PerformColdStart()) { return(false); } if (!m_startup.Check64Bit()) { return(false); } m_steamService = MySteamGameService.Create(MySandboxGame.IsDedicated, AppId); MyServiceManager.Instance.AddService(m_steamService); MyServerDiscoveryAggregator serverDiscoveryAggregator = new MyServerDiscoveryAggregator(); MySteamGameService.InitNetworking(false, m_steamService, MyPerGameSettings.BasicGameInfo.GameName, serverDiscoveryAggregator, true, true); // If user specified --modio, set that as the "default" (added first) var modioService = MyModIoService.Create(MyServiceManager.Instance.GetService <IMyGameService>(), ModIO_GameName, ModIO_GameID, ModIO_Key, ModIO_TestGameID, ModIO_TestKey, MyPlatformGameSettings.UGC_TEST_ENVIRONMENT, m_useModIO ? true : false); if (m_useModIO) { MyGameService.WorkshopService.AddAggregate(modioService); } MyGameService.WorkshopService.AddAggregate(MySteamUgcService.Create(AppId, m_steamService)); if (!m_useModIO) { MyGameService.WorkshopService.AddAggregate(modioService); } SpaceEngineersGame.SetupPerGameSettings(); ManuallyAddDLCs(); return(true); }
protected override bool SetupBasicGameInfo() { MyMedievalGame.SetupBasicGameInfo(); m_startup = new MyCommonProgramStartup(new string[] { }); var appDataPath = m_startup.GetAppDataPath(); MyInitializer.InvokeBeforeRun(AppId, MyPerGameSettings.BasicGameInfo.ApplicationName + "ModTool", appDataPath); if (!m_startup.Check64Bit()) { return(false); } m_steamService = new WorkshopTool.MySteamService(MySandboxGame.IsDedicated, AppId); MyServiceManager.Instance.AddService <IMyGameService>(m_steamService); MyMedievalGame.SetupPerGameSettings(); return(true); }
public SpaceEngineersCore() { var contentPath = ToolboxUpdater.GetApplicationContentPath(); string userDataPath = SpaceEngineersConsts.BaseLocalPath.DataPath; MyFileSystem.ExePath = Path.GetDirectoryName(Assembly.GetAssembly(typeof(FastResourceLock)).Location); MyLog.Default = MySandboxGame.Log; SpaceEngineersGame.SetupBasicGameInfo(); _startup = new MyCommonProgramStartup(new string[] { }); //var appDataPath = _startup.GetAppDataPath(); //MyInitializer.InvokeBeforeRun(AppId, MyPerGameSettings.BasicGameInfo.ApplicationName + "SEToolbox", appDataPath); //MyInitializer.InitCheckSum(); MyFileSystem.Reset(); MyFileSystem.Init(contentPath, userDataPath); // This will start the Steam Service, and Steam will think SE is running. // TODO: we don't want to be doing this all the while SEToolbox is running, // perhaps a once off during load to fetch of mods then disconnect/Dispose. _steamService = MySteamGameService.Create(MySandboxGame.IsDedicated, AppId); MyServiceManager.Instance.AddService(_steamService); IMyUGCService serviceInstance = MySteamUgcService.Create(AppId, _steamService); MyServiceManager.Instance.AddService(serviceInstance); MyFileSystem.InitUserSpecific(_steamService.UserId.ToString()); // This sets the save file/path to load games from. //MyFileSystem.InitUserSpecific(null); //SpaceEngineersWorkshop.MySteam.Dispose(); MySandboxGame.Config = new MyConfig("SpaceEngineers.cfg"); // TODO: Is specific to SE, not configurable to ME. MySandboxGame.Config.Load(); SpaceEngineersGame.SetupPerGameSettings(); VRage.MyVRage.Init(new ToolboxPlatform()); VRage.MyVRage.Platform.Init(); MySandboxGame.InitMultithreading(); VRageRender.MyRenderProxy.Initialize(new MyNullRender()); // We create a whole instance of MySandboxGame! // If this is causing an exception, then there is a missing dependency. MySandboxGame gameTemp = new DerivedGame(new string[] { "-skipintro" }); // creating MySandboxGame will reset the CurrentUICulture, so I have to reapply it. Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfoByIetfLanguageTag(GlobalSettings.Default.LanguageCode); SpaceEngineersApi.LoadLocalization(); MyStorageBase.UseStorageCache = false; // Create an empty instance of MySession for use by low level code. var mySession = (Sandbox.Game.World.MySession)FormatterServices.GetUninitializedObject(typeof(Sandbox.Game.World.MySession)); // Required as the above code doesn't populate it during ctor of MySession. ReflectionUtil.ConstructField(mySession, "m_creativeTools"); ReflectionUtil.ConstructField(mySession, "m_sessionComponents"); ReflectionUtil.ConstructField(mySession, "m_sessionComponentsForUpdate"); mySession.Settings = new MyObjectBuilder_SessionSettings { EnableVoxelDestruction = true }; // change for the Clone() method to use XML cloning instead of Protobuf because of issues with MyObjectBuilder_CubeGrid.Clone() ReflectionUtil.SetFieldValue(typeof(VRage.ObjectBuilders.MyObjectBuilderSerializer), "ENABLE_PROTOBUFFERS_CLONING", false); // Assign the instance back to the static. Sandbox.Game.World.MySession.Static = mySession; var heightMapLoadingSystem = new MyHeightMapLoadingSystem(); mySession.RegisterComponent(heightMapLoadingSystem, heightMapLoadingSystem.UpdateOrder, heightMapLoadingSystem.Priority); heightMapLoadingSystem.LoadData(); _stockDefinitions = new SpaceEngineersResources(); _stockDefinitions.LoadDefinitions(); _manageDeleteVoxelList = new List <string>(); }
// Main method static void Main(string[] args) { #if XB1 XB1Interface.XB1Interface.Init(); MyAssembly.Init(); #endif SpaceEngineersGame.SetupBasicGameInfo(); m_startup = new MyCommonProgramStartup(args); if (m_startup.PerformReporting()) { return; } m_startup.PerformAutoconnect(); #if !XB1 if (!m_startup.CheckSingleInstance()) { return; } #endif // !XB1 var appDataPath = m_startup.GetAppDataPath(); MyInitializer.InvokeBeforeRun(AppId, MyPerGameSettings.BasicGameInfo.ApplicationName, appDataPath); MyInitializer.InitCheckSum(); m_startup.InitSplashScreen(); if (!m_startup.Check64Bit()) { return; } m_startup.DetectSharpDxLeaksBeforeRun(); using (MySteamService steamService = new MySteamService(MySandboxGame.IsDedicated, AppId)) { m_renderer = null; SpaceEngineersGame.SetupPerGameSettings(); SpaceEngineersGame.SetupRender(); try { InitializeRender(); } catch (MyRenderException ex) { #if !XB1 MessageBox.Show(ex.Message); #else // XB1 System.Diagnostics.Debug.Assert(false, "InitializeRender failed"); #endif // XB1 return; } VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyProgram.Init"); VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MySteam.Init()"); if (!m_startup.CheckSteamRunning(steamService)) { return; } VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock(); VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("new MySandboxGame()"); VRageGameServices services = new VRageGameServices(steamService); if (!MySandboxGame.IsDedicated) { MyFileSystem.InitUserSpecific(steamService.UserId.ToString()); } using (SpaceEngineersGame game = new SpaceEngineersGame(services, args)) { VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock(); VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock(); game.Run(disposeSplashScreen: m_startup.DisposeSplashScreen); } } m_startup.DetectSharpDxLeaksAfterRun(); #if PROFILING MyPerformanceTimer.WriteToLog(); #endif MyInitializer.InvokeAfterRun(); }
// This is mostly copied from MyProgram.Main(), with UI stripped out. private static void InitSandbox(string instancepath) { MyFakes.ENABLE_INFINARIO = false; if (m_spacegame != null) { m_spacegame.Exit(); } SpaceEngineersGame.SetupBasicGameInfo(); m_startup = new MyCommonProgramStartup(new string[] { }); var appDataPath = m_startup.GetAppDataPath(); MyInitializer.InvokeBeforeRun(AppId_SE, MyPerGameSettings.BasicGameInfo.ApplicationName + "ModTool", appDataPath); MyInitializer.InitCheckSum(); if (!m_startup.Check64Bit()) { return; } m_steamService = new MySteamService(MySandboxGame.IsDedicated, AppId_SE); SpaceEngineersGame.SetupPerGameSettings(); if (System.Diagnostics.Debugger.IsAttached) { m_startup.CheckSteamRunning(m_steamService); // Just give the warning message box when debugging, ignore for release } VRageGameServices services = new VRageGameServices(m_steamService); if (!MySandboxGame.IsDedicated) { MyFileSystem.InitUserSpecific(m_steamService.UserId.ToString()); } try { // NOTE: an assert may be thrown in debug, about missing Tutorials.sbx. Ignore it. m_spacegame = new SpaceEngineersGame(services, null); // Initializing the workshop means the categories are available var initWorkshopMethod = typeof(SpaceEngineersGame).GetMethod("InitSteamWorkshop", BindingFlags.NonPublic | BindingFlags.Instance); MyDebug.AssertDebug(initWorkshopMethod != null); if (initWorkshopMethod != null) { var parameters = initWorkshopMethod.GetParameters(); MyDebug.AssertDebug(parameters.Count() == 0); } if (initWorkshopMethod != null) { initWorkshopMethod.Invoke(m_spacegame, 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 MySandboxGame.Log.WriteLineAndConsole("An exception occured, ignoring: " + ex.Message); } }