Ejemplo n.º 1
0
 private static bool EnsureGameService()
 {
     if (m_gameServiceCache == null)
     {
         m_gameServiceCache = MyServiceManager.Instance.GetService <IMyGameService>();
     }
     return(m_gameServiceCache != null);
 }
Ejemplo n.º 2
0
        private void CleanupSandbox()
        {
            try
            {
                m_steamService?.ShutDown();
                m_game?.Dispose();
                m_steamService = null;
                m_game         = null;
            }
            catch (Exception ex)
            {
                // Don't spam console with annoying cleanup error
                MySandboxGame.Log.WriteLine(ex.Message);
                MySandboxGame.Log.WriteLine(ex.StackTrace);
            }
#if !SE
            VRage.Logging.MyLog.Default.Dispose();
#endif
        }
Ejemplo n.º 3
0
        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>();
        }
Ejemplo n.º 4
0
 public static bool DeleteFromCloud(this IMyGameService service, string fileName)
 {
     return(SteamRemoteStorage.FileDelete(fileName));
 }
Ejemplo n.º 5
0
 public static void ClearCache()
 {
     m_gameServiceCache = null;
 }
Ejemplo n.º 6
0
 public static bool RemoteStorageFileForget(this IMyGameService service, string file)
 {
     return(SteamRemoteStorage.FileForget(file));
 }
Ejemplo n.º 7
0
 public static bool IsRemoteStorageFilePersisted(this IMyGameService service, string file)
 {
     return(SteamRemoteStorage.FilePersisted(file));
 }
Ejemplo n.º 8
0
 public static string GetRemoteStorageFileNameAndSize(this IMyGameService service, int fileIndex, out int fileSizeInBytes)
 {
     return(SteamRemoteStorage.GetFileNameAndSize(fileIndex, out fileSizeInBytes));
 }
Ejemplo n.º 9
0
 public static int GetRemoteStorageFileCount(this IMyGameService service)
 {
     return(SteamRemoteStorage.GetFileCount());
 }
Ejemplo n.º 10
0
 public static bool GetRemoteStorageQuota(this IMyGameService service, out ulong totalBytes, out ulong availableBytes)
 {
     return(SteamRemoteStorage.GetQuota(out totalBytes, out availableBytes));
 }