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); }
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>(); }
private void Create() { bool dedicated = Sandbox.Engine.Platform.Game.IsDedicated; Environment.SetEnvironmentVariable("SteamAppId", _appSteamId.ToString()); var service = MySteamServiceWrapper.Init(dedicated, _appSteamId); MyServiceManager.Instance.AddService <IMyGameService>(service); var serviceInstance = MySteamUgcService.Create(_appSteamId, service); MyServiceManager.Instance.AddService <IMyUGCService>(serviceInstance); if (dedicated && !MyGameService.HasGameServer) { _log.Warn("Steam service is not running! Please reinstall dedicated server."); return; } SpaceEngineersGame.SetupBasicGameInfo(); SpaceEngineersGame.SetupPerGameSettings(); MyFinalBuildConstants.APP_VERSION = MyPerGameSettings.BasicGameInfo.GameVersion; MySessionComponentExtDebug.ForceDisable = true; MyPerGameSettings.SendLogToKeen = false; // SpaceEngineersGame.SetupAnalytics(); MyFileSystem.ExePath = Path.GetDirectoryName(typeof(SpaceEngineersGame).Assembly.Location); _tweakGameSettings(); MyFileSystem.Reset(); MyInitializer.InvokeBeforeRun(_appSteamId, _appName, _userDataPath); // MyInitializer.InitCheckSum(); // Hook into the VRage plugin system for updates. _getVRagePluginList().Add(_torch); if (!MySandboxGame.IsReloading) { MyFileSystem.InitUserSpecific(dedicated ? null : MyGameService.UserId.ToString()); } MySandboxGame.IsReloading = dedicated; // render init { IMyRender renderer = null; if (dedicated) { renderer = new MyNullRender(); } else { MyPerformanceSettings preset = MyGuiScreenOptionsGraphics.GetPreset(MyRenderQualityEnum.NORMAL); MyRenderProxy.Settings.User = MyVideoSettingsManager.GetGraphicsSettingsFromConfig(ref preset, false) .PerformanceSettings.RenderSettings; MyStringId graphicsRenderer = MySandboxGame.Config.GraphicsRenderer; if (graphicsRenderer == MySandboxGame.DirectX11RendererKey) { renderer = new MyDX11Render(new MyRenderSettings?(MyRenderProxy.Settings)); if (!renderer.IsSupported) { MySandboxGame.Log.WriteLine( "DirectX 11 renderer not supported. No renderer to revert back to."); renderer = null; } } if (renderer == null) { throw new MyRenderException( "The current version of the game requires a Dx11 card. \\n For more information please see : http://blog.marekrosa.org/2016/02/space-engineers-news-full-source-code_26.html", MyRenderExceptionEnum.GpuNotSupported); } MySandboxGame.Config.GraphicsRenderer = graphicsRenderer; } MyRenderProxy.Initialize(renderer); MyRenderProfiler.SetAutocommit(false); //This broke services? //MyRenderProfiler.InitMemoryHack("MainEntryPoint"); } // Loads object builder serializers. Intuitive, right? _log.Info("Setting up serializers"); MyPlugins.RegisterGameAssemblyFile(MyPerGameSettings.GameModAssembly); if (MyPerGameSettings.GameModBaseObjBuildersAssembly != null) { MyPlugins.RegisterBaseGameObjectBuildersAssemblyFile(MyPerGameSettings.GameModBaseObjBuildersAssembly); } MyPlugins.RegisterGameObjectBuildersAssemblyFile(MyPerGameSettings.GameModObjBuildersAssembly); MyPlugins.RegisterSandboxAssemblyFile(MyPerGameSettings.SandboxAssembly); MyPlugins.RegisterSandboxGameAssemblyFile(MyPerGameSettings.SandboxGameAssembly); //typeof(MySandboxGame).GetMethod("Preallocate", BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, null); MyGlobalTypeMetadata.Static.Init(false); }
private void Create() { bool dedicated = true; Environment.SetEnvironmentVariable("SteamAppId", _appSteamId.ToString()); SpaceEngineersGame.SetupBasicGameInfo(); SpaceEngineersGame.SetupPerGameSettings(); MyFinalBuildConstants.APP_VERSION = MyPerGameSettings.BasicGameInfo.GameVersion; MySessionComponentExtDebug.ForceDisable = true; MyPerGameSettings.SendLogToKeen = false; // SpaceEngineersGame.SetupAnalytics(); //not implemented by keen.. removed in cross-play update //MyVRage.Platform.InitScripting(MyVRageScripting.Create()); _ = MyVRage.Platform.Scripting; MyFileSystem.ExePath = Path.GetDirectoryName(typeof(SpaceEngineersGame).Assembly.Location); _tweakGameSettings(); MyFileSystem.Reset(); MyInitializer.InvokeBeforeRun(_appSteamId, _appName, _userDataPath); _log.Info("Loading Dedicated Config"); // object created in SpaceEngineersGame.SetupPerGameSettings() MySandboxGame.ConfigDedicated.Load(); MyPlatformGameSettings.CONSOLE_COMPATIBLE = MySandboxGame.ConfigDedicated.ConsoleCompatibility; //Type.GetType("VRage.Steam.MySteamService, VRage.Steam").GetProperty("IsActive").GetSetMethod(true).Invoke(service, new object[] {SteamAPI.Init()}); _log.Info("Initializing network services"); var isEos = TorchBase.Instance.Config.UgcServiceType == UGCServiceType.EOS; if (isEos) { _log.Info("Running on Epic Online Services."); _log.Warn("Steam workshop will not work with current settings. Some functions might not work properly!"); } var aggregator = new MyServerDiscoveryAggregator(); MyServiceManager.Instance.AddService <IMyServerDiscovery>(aggregator); IMyGameService service; if (isEos) { service = MyEOSService.Create(); MyEOSService.InitNetworking(dedicated, "Space Engineers", service, "xyza7891A4WeGrpP85BTlBa3BSfUEABN", "ZdHZVevSVfIajebTnTmh5MVi3KPHflszD9hJB7mRkgg", "24b1cd652a18461fa9b3d533ac8d6b5b", "1958fe26c66d4151a327ec162e4d49c8", "07c169b3b641401496d352cad1c905d6", "https://retail.epicgames.com/", MyEOSService.CreatePlatform(), MySandboxGame.ConfigDedicated.VerboseNetworkLogging, Enumerable.Empty <string>(), aggregator, MyMultiplayer.Channels); var mockingInventory = new MyMockingInventory(service); MyServiceManager.Instance.AddService <IMyInventoryService>(mockingInventory); } else { service = MySteamGameService.Create(dedicated, _appSteamId); MyGameService.WorkshopService.AddAggregate(MySteamUgcService.Create(_appSteamId, service)); MySteamGameService.InitNetworking(dedicated, service, "Space Engineers", aggregator); } MyServiceManager.Instance.AddService(service); MyGameService.WorkshopService.AddAggregate(MyModIoService.Create(service, "spaceengineers", "264", "1fb4489996a5e8ffc6ec1135f9985b5b", "331", "f2b64abe55452252b030c48adc0c1f0e", MyPlatformGameSettings.UGC_TEST_ENVIRONMENT, true)); if (!isEos && !MyGameService.HasGameServer) { _log.Warn("Network service is not running! Please reinstall dedicated server."); return; } _log.Info("Initializing services"); MyServiceManager.Instance.AddService <IMyMicrophoneService>(new MyNullMicrophone()); MyNetworkMonitor.Init(); _log.Info("Services initialized"); MySandboxGame.InitMultithreading(); // MyInitializer.InitCheckSum(); // Hook into the VRage plugin system for updates. _getVRagePluginList().Add(_torch); if (!MySandboxGame.IsReloading) { MyFileSystem.InitUserSpecific(dedicated ? null : MyGameService.UserId.ToString()); } MySandboxGame.IsReloading = dedicated; // render init { IMyRender renderer = null; if (dedicated) { renderer = new MyNullRender(); } else { MyPerformanceSettings preset = MyGuiScreenOptionsGraphics.GetPreset(MyRenderPresetEnum.NORMAL); MyRenderProxy.Settings.User = MyVideoSettingsManager.GetGraphicsSettingsFromConfig(ref preset, false) .PerformanceSettings.RenderSettings; MyStringId graphicsRenderer = MySandboxGame.Config.GraphicsRenderer; if (graphicsRenderer == MySandboxGame.DirectX11RendererKey) { renderer = new MyDX11Render(new MyRenderSettings?(MyRenderProxy.Settings)); if (!renderer.IsSupported) { MySandboxGame.Log.WriteLine( "DirectX 11 renderer not supported. No renderer to revert back to."); renderer = null; } } if (renderer == null) { throw new MyRenderException( "The current version of the game requires a Dx11 card. \\n For more information please see : http://blog.marekrosa.org/2016/02/space-engineers-news-full-source-code_26.html", MyRenderExceptionEnum.GpuNotSupported); } MySandboxGame.Config.GraphicsRenderer = graphicsRenderer; } MyRenderProxy.Initialize(renderer); MyRenderProfiler.SetAutocommit(false); //This broke services? //MyRenderProfiler.InitMemoryHack("MainEntryPoint"); } // Loads object builder serializers. Intuitive, right? _log.Info("Setting up serializers"); MyPlugins.RegisterGameAssemblyFile(MyPerGameSettings.GameModAssembly); if (MyPerGameSettings.GameModBaseObjBuildersAssembly != null) { MyPlugins.RegisterBaseGameObjectBuildersAssemblyFile(MyPerGameSettings.GameModBaseObjBuildersAssembly); } MyPlugins.RegisterGameObjectBuildersAssemblyFile(MyPerGameSettings.GameModObjBuildersAssembly); MyPlugins.RegisterSandboxAssemblyFile(MyPerGameSettings.SandboxAssembly); MyPlugins.RegisterSandboxGameAssemblyFile(MyPerGameSettings.SandboxGameAssembly); //typeof(MySandboxGame).GetMethod("Preallocate", BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, null); MyGlobalTypeMetadata.Static.Init(false); }