Beispiel #1
0
        public static void LoadTexts(string rootDirectory, string cultureName = null, string subcultureName = null)
        {
            HashSet <string> baseFiles = new HashSet <string>();
            var files = MyFileSystem.GetFiles(rootDirectory, "*.resx", FileSystem.MySearchOption.TopDirectoryOnly);

            foreach (var file in files)
            {
                baseFiles.Add(Path.GetFileNameWithoutExtension(file).Split('.')[0]);
            }

            foreach (var baseFile in baseFiles)
            {
                PatchTexts(Path.Combine(rootDirectory, string.Format("{0}.resx", baseFile)));
            }

            if (cultureName == null)
            {
                return;
            }

            foreach (var baseFile in baseFiles)
            {
                PatchTexts(Path.Combine(rootDirectory, string.Format("{0}.{1}.resx", baseFile, cultureName)));
            }

            if (subcultureName == null)
            {
                return;
            }

            foreach (var baseFile in baseFiles)
            {
                PatchTexts(Path.Combine(rootDirectory, string.Format("{0}.{1}-{2}.resx", baseFile, cultureName, subcultureName)));
            }
        }
Beispiel #2
0
        public static void LoadSupportedLanguages(string rootDirectory, HashSet <int> outSupportedLanguages)
        {
            // we always support English
            outSupportedLanguages.Add((int)MyLanguagesEnum.English);

            var files = MyFileSystem.GetFiles(rootDirectory, "*.resx", FileSystem.MySearchOption.TopDirectoryOnly);
            HashSet <string> foundCultures = new HashSet <string>();

            foreach (var file in files)
            {
                var parts = Path.GetFileNameWithoutExtension(file).Split('.');
                Debug.Assert(parts.Length == 1 || parts.Length == 2);
                if (parts.Length > 1)
                {
                    foundCultures.Add(parts[1]);
                }
            }

            foreach (var culture in foundCultures)
            {
                int id;
                if (m_cultureToLanguageId.TryGetValue(culture, out id))
                {
                    outSupportedLanguages.Add(id);
                }
            }
        }
        private void ScriptSelected(string scriptPath)
        {
            string programData   = null;
            string fileExtension = Path.GetExtension(scriptPath);

            if (fileExtension == MyGuiIngameScriptsPage.SCRIPT_EXTENSION && File.Exists(scriptPath))
            {
                programData = File.ReadAllText(scriptPath);
            }
            else if (fileExtension == MyGuiIngameScriptsPage.WORKSHOP_SCRIPT_EXTENSION)
            {
                foreach (var file in MyFileSystem.GetFiles(scriptPath, MyGuiIngameScriptsPage.SCRIPT_EXTENSION, VRage.FileSystem.MySearchOption.AllDirectories))
                {
                    if (MyFileSystem.FileExists(file))
                    {
                        using (var stream = MyFileSystem.OpenRead(file))
                        {
                            using (StreamReader reader = new StreamReader(stream))
                            {
                                programData = reader.ReadToEnd();
                            }
                        }
                    }
                }
            }
            if (programData != null)
            {
                SetDescription(Regex.Replace(programData, "\r\n", " \n"));
                m_lineCounter.Text = string.Format(MyTexts.GetString(MySpaceTexts.ProgrammableBlock_Editor_LineNo), m_editorWindow.GetCurrentCarriageLine(), m_editorWindow.GetTotalNumLines());
                EnableButtons();
            }
        }
        // Loads campaign data to storage.
        public void Init()
        {
            MySandboxGame.Log.WriteLine("MyCampaignManager.Constructor() - START");

            // Variables needed for loading
            var vanillaFiles =
                MyFileSystem.GetFiles(Path.Combine(MyFileSystem.ContentPath, CAMPAIGN_CONTENT_RELATIVE_PATH), "*.vs",
                                      MySearchOption.TopDirectoryOnly);

            // Load vanilla files
            foreach (var vanillaFile in vanillaFiles)
            {
                MyObjectBuilder_VSFiles ob;
                if (MyObjectBuilderSerializer.DeserializeXML(vanillaFile, out ob))
                {
                    if (ob.Campaign != null)
                    {
                        ob.Campaign.IsVanilla  = true;
                        ob.Campaign.IsLocalMod = false;
                        LoadCampaignData(ob.Campaign);
                    }
                }
            }

            MySandboxGame.Log.WriteLine("MyCampaignManager.Constructor() - END");
        }
        // Loads campaign bundle with provided files
        // This is and should be used only
        public void LoadCampaignLocalization(IEnumerable <string> paths, string campaignModFolderPath = null)
        {
            // Remove the first part of the full path
            m_campaignModFolderName = Path.GetFileName(campaignModFolderPath);
            m_campaignBundle.FilePaths.Clear();
            // Add campaign mod folder
            if (campaignModFolderPath != null)
            {
                m_campaignBundle.FilePaths.Add(campaignModFolderPath);
            }

            // Add custom content folders
            foreach (var path in paths)
            {
                var files = MyFileSystem.GetFiles(Path.Combine(MyFileSystem.ContentPath, path), "*.sbl", MySearchOption.AllDirectories);
                foreach (var filePath in files)
                {
                    m_campaignBundle.FilePaths.Add(filePath);
                }
            }

            // For nonempty bundles, clear contexts
            if (m_campaignBundle.FilePaths.Count > 0)
            {
                MyLocalization.Static.LoadBundle(m_campaignBundle, m_influencedContexts);
            }
        }
Beispiel #6
0
        private void ReadScripts(string path)
        {
            var fsPath      = Path.Combine(path, "Data", "Scripts");
            var scriptFiles = MyFileSystem.GetFiles(fsPath, "*.cs");//, searchOption: VRage.FileSystem.SearchOption.TopDirectoryOnly);

            try
            {
                if (scriptFiles.Count() == 0)
                {
                    return;
                }
            }
            catch (Exception)
            {
                MySandboxGame.Log.WriteLine(string.Format("Failed to load scripts from: {0}", path));
                return;
            }
            foreach (var file in scriptFiles)
            {
                try
                {
                    var stream = MyFileSystem.OpenRead(file);
                    using (var sr = new StreamReader(stream))
                    {
                        m_scriptsToSave.Add(file.Substring(fsPath.Length + 1), sr.ReadToEnd());
                    }
                }
                catch (Exception e)
                {
                    MySandboxGame.Log.WriteLine(e);
                }
            }
        }
        public override void BeforeStart()
        {
            foreach (var modItem in Session.Mods)
            {
                // Local mods have a name as folder name
                // workshop mods have pulisherfileid + .sbm archive
                var modPath = Path.Combine(MyFileSystem.ModsPath,
                                           modItem.ShouldSerializeName() ? modItem.Name : modItem.PublishedFileId + ".sbm");
                try
                {
                    var files = MyFileSystem.GetFiles(modPath, "*.sbl", MySearchOption.AllDirectories);

                    foreach (var file in files)
                    {
                        m_modBundle.FilePaths.Add(file);
                    }
                }
                catch (Exception e)
                {
                    // ignored -- can be just about anything that causes trouble in file system
                    MyLog.Default.WriteLine("MyLocalizationSessionComponent: Problem deserializing " + modPath + "\n" + e);
                }
            }

            // Load the bundle
            MyLocalization.Static.LoadBundle(m_modBundle, m_influencedContexts);
            SwitchLanguage(m_language);
        }
Beispiel #8
0
        public static void LoadTexts(string rootDirectory, string cultureName = null, string subcultureName = null)
        {
            HashSet <string> commonTexts = new HashSet <string>();
            HashSet <string> baseFiles   = new HashSet <string>();
            var           files          = MyFileSystem.GetFiles(rootDirectory, "*.resx", FileSystem.MySearchOption.AllDirectories);
            List <string> allFiles       = new List <string>(); // list of files with their full path

            foreach (var file in files)
            {
                if (file.Contains("MyCommonTexts"))
                {
                    commonTexts.Add(Path.GetFileNameWithoutExtension(file).Split('.')[0]);
                }
                else
                {
                    baseFiles.Add(Path.GetFileNameWithoutExtension(file).Split('.')[0]);
                }
                allFiles.Add(file);
            }

            foreach (var commonText in commonTexts)
            {
                PatchTexts(GetPathWithFile(string.Format("{0}.resx", commonText), allFiles));
            }

            foreach (var baseFile in baseFiles)
            {
                PatchTexts(GetPathWithFile(string.Format("{0}.resx", baseFile), allFiles));
            }

            if (cultureName == null)
            {
                return;
            }

            foreach (var commonText in commonTexts)
            {
                PatchTexts(GetPathWithFile(string.Format("{0}.{1}.resx", commonText, cultureName), allFiles));
            }

            foreach (var baseFile in baseFiles)
            {
                PatchTexts(GetPathWithFile(string.Format("{0}.{1}.resx", baseFile, cultureName), allFiles));
            }

            if (subcultureName == null)
            {
                return;
            }

            foreach (var commonText in commonTexts)
            {
                PatchTexts(GetPathWithFile(string.Format("{0}.{1}-{2}.resx", commonText, cultureName, subcultureName), allFiles));
            }

            foreach (var baseFile in baseFiles)
            {
                PatchTexts(GetPathWithFile(string.Format("{0}.{1}-{2}.resx", baseFile, cultureName, subcultureName), allFiles));
            }
        }
Beispiel #9
0
        private void RefreshLocalModData()
        {
            var localModFolders       = Directory.GetDirectories(MyFileSystem.ModsPath);
            var localModCampaignFiles = new List <string>();

            // Remove all local mods
            foreach (var campaignList in m_campaignsByNames.Values)
            {
                campaignList.RemoveAll(campaign => campaign.IsLocalMod);
            }

            // Gather local mod campaign files
            foreach (var localModFolder in localModFolders)
            {
                localModCampaignFiles.AddRange(
                    MyFileSystem.GetFiles(Path.Combine(localModFolder, CAMPAIGN_CONTENT_RELATIVE_PATH), "*.vs",
                                          MySearchOption.TopDirectoryOnly));
            }

            // Add local mods data to campaign structure
            foreach (var localModCampaignFile in localModCampaignFiles)
            {
                MyObjectBuilder_VSFiles ob;
                if (MyObjectBuilderSerializer.DeserializeXML(localModCampaignFile, out ob))
                {
                    if (ob.Campaign != null)
                    {
                        ob.Campaign.IsVanilla     = false;
                        ob.Campaign.IsLocalMod    = true;
                        ob.Campaign.ModFolderPath = GetModFolderPath(localModCampaignFile);
                        LoadCampaignData(ob.Campaign);
                    }
                }
            }
        }
Beispiel #10
0
        // Loads data from content folder
        private void Init()
        {
            var localizationFiles = MyFileSystem.GetFiles(
                Path.Combine(MyFileSystem.ContentPath, LOCALIZATION_FOLDER), "*.sbl", MySearchOption.AllDirectories);

            foreach (var localizationFilePath in localizationFiles)
            {
                LoadLocalizationFile(localizationFilePath, MyStringId.NullOrEmpty);
            }
        }
        private void LoadScripts(string path, MyModContext mod = null)
        {
#if XB1
#if !XB1_SKIPASSERTFORNOW
            System.Diagnostics.Debug.Assert(false, "Unsupported runtime script compilation on XB1.");
#endif // !XB1_SKIPASSERTFORNOW
#else
            if (!MyFakes.ENABLE_SCRIPTS)
            {
                return;
            }

            var fsPath      = Path.Combine(path, "Data", "Scripts");
            var scriptFiles = MyFileSystem.GetFiles(fsPath, "*.cs");//, searchOption: VRage.FileSystem.SearchOption.TopDirectoryOnly);
            try
            {
                if (scriptFiles.Count() == 0)
                {
                    return;
                }
            }
            catch (Exception)
            {
                MySandboxGame.Log.WriteLine(string.Format("Failed to load scripts from: {0}", path));
                return;
            }
            var           isZip     = VRage.FileSystem.MyZipFileProvider.IsZipFile(path);
            List <string> files     = new List <string>();
            var           split     = scriptFiles.First().Split('\\');
            string        scriptDir = split[split.Length - 2];
            foreach (var scriptFile in scriptFiles)
            {
                split = scriptFile.Split('\\');
                var extension = split[split.Length - 1].Split('.').Last();
                if (extension != "cs")
                {
                    continue;
                }
                var idx = Array.IndexOf(split, "Scripts") + 1; //index of script directory (there can be any dir hierarchy above it)
                if (split[idx] == scriptDir)
                {
                    files.Add(scriptFile);
                }
                else
                {
                    Compile(files, string.Format("{0}_{1}", mod.ModId, scriptDir), isZip, mod);
                    files.Clear();
                    scriptDir = split[split.Length - 2];
                    files.Add(scriptFile);
                }
            }
            Compile(files.ToArray(), Path.Combine(MyFileSystem.ModsPath, string.Format("{0}_{1}", mod.ModId, scriptDir)), isZip, mod);
            files.Clear();
#endif
        }
Beispiel #12
0
        private MyGuiControlCombobox MakeComboFromFiles(string path, string filter = "*", SearchOption search = SearchOption.AllDirectories)
        {
            var  combo = AddCombo();
            long key   = 0;

            combo.AddItem(key++, "");
            foreach (var file in MyFileSystem.GetFiles(path, filter, search))
            {
                combo.AddItem(key++, Path.GetFileNameWithoutExtension(file));
            }
            combo.SelectItemByIndex(0);
            return(combo);
        }
Beispiel #13
0
        private void LoadScripts(string path, string modName = null)
        {
            if (!MyFakes.ENABLE_SCRIPTS)
            {
                return;
            }

            var fsPath      = Path.Combine(path, "Data", "Scripts");
            var scriptFiles = MyFileSystem.GetFiles(fsPath, "*.cs"); //, searchOption: VRage.FileSystem.SearchOption.TopDirectoryOnly);

            try
            {
                if (scriptFiles.Count() == 0)
                {
                    return;
                }
            }
            catch (Exception)
            {
                MySandboxGame.Log.WriteLine(string.Format("Failed to load scripts from: {0}", path));
                return;
            }
            var           isZip     = VRage.FileSystem.MyZipFileProvider.IsZipFile(path);
            List <string> files     = new List <string>();
            var           split     = scriptFiles.First().Split('\\');
            string        scriptDir = split[split.Length - 2];

            foreach (var scriptFile in scriptFiles)
            {
                split = scriptFile.Split('\\');
                var extension = split[split.Length - 1].Split('.').Last();
                if (extension != "cs")
                {
                    continue;
                }
                var idx = Array.IndexOf(split, "Scripts") + 1; //index of script directory (there can be any dir hierarchy above it)
                if (split[idx] == scriptDir)
                {
                    files.Add(scriptFile);
                }
                else
                {
                    Compile(files, string.Format("{0}_{1}", modName, scriptDir), isZip);
                    files.Clear();
                    scriptDir = split[split.Length - 2];
                    files.Add(scriptFile);
                }
            }
            Compile(files.ToArray(), string.Format("{0}_{1}", modName, scriptDir), isZip);
            files.Clear();
        }
Beispiel #14
0
        private void ResavePrefabs(MyGuiControlButton sender)
        {
            var fileList = MyFileSystem.GetFiles(
                MyFileSystem.ContentPath,
                //Path.Combine(MyFileSystem.ContentPath, "VoxelMaps"),
                "*" + MyVoxelConstants.FILE_EXTENSION,
                SearchOption.AllDirectories).ToArray();

            for (int i = 0; i < fileList.Length; ++i)
            {
                var file = fileList[i];
                Debug.WriteLine(string.Format("Resaving [{0}/{1}] '{2}'", i + 1, fileList.Length, file));
                var    storage = MyStorageBase.LoadFromFile(file);
                byte[] savedData;
                storage.Save(out savedData);
                using (var stream = MyFileSystem.OpenWrite(file, System.IO.FileMode.Open))
                {
                    stream.Write(savedData, 0, savedData.Length);
                }
            }
            Debug.WriteLine("Saving prefabs finished.");
        }
Beispiel #15
0
        // Removes unsubscribed items and adds newly subscribed items
        private void RefreshSubscribedModData()
        {
            if (MySteamWorkshop.GetSubscribedCampaignsBlocking(m_subscribedCampaignItems))
            {
                var toRemove = new List <MyObjectBuilder_Campaign>();
                // Remove unsubed items
                foreach (var campaignList in m_campaignsByNames.Values)
                {
                    foreach (var campaign in campaignList)
                    {
                        if (campaign.PublishedFileId == 0)
                        {
                            continue;
                        }

                        var found = false;
                        for (var index = 0; index < m_subscribedCampaignItems.Count; index++)
                        {
                            var subscribedItem = m_subscribedCampaignItems[index];
                            if (subscribedItem.PublishedFileId == campaign.PublishedFileId)
                            {
                                // Remove the result as processed (the entry should not appear elsewhere)
                                m_subscribedCampaignItems.RemoveAtFast(index);
                                found = true;
                                break;
                            }
                        }

                        if (!found)
                        {
                            toRemove.Add(campaign);
                        }
                    }

                    toRemove.ForEach(campaignToRemove => campaignList.Remove(campaignToRemove));
                    toRemove.Clear();
                }

                // Download the subscribed items
                MySteamWorkshop.DownloadModsBlocking(m_subscribedCampaignItems);

                // Load data for rest of the results
                foreach (var subscribedItem in m_subscribedCampaignItems)
                {
                    var modPath = Path.Combine(MyFileSystem.ModsPath, subscribedItem.PublishedFileId + ".sbm");
                    var visualScriptingFiles = MyFileSystem.GetFiles(modPath, "*.vs", MySearchOption.AllDirectories);

                    foreach (var modFile in visualScriptingFiles)
                    {
                        MyObjectBuilder_VSFiles ob;
                        if (MyObjectBuilderSerializer.DeserializeXML(modFile, out ob))
                        {
                            if (ob.Campaign != null)
                            {
                                ob.Campaign.IsVanilla       = false;
                                ob.Campaign.IsLocalMod      = false;
                                ob.Campaign.PublishedFileId = subscribedItem.PublishedFileId;
                                ob.Campaign.ModFolderPath   = GetModFolderPath(modFile);
                                LoadCampaignData(ob.Campaign);
                            }
                        }
                    }
                }
            }
        }
Beispiel #16
0
        // Loads campaign data to storage.
        public void Init()
        {
            MySandboxGame.Log.WriteLine("MyCampaignManager.Constructor() - START");

            // Variables needed for loading
            var vanillaFiles =
                MyFileSystem.GetFiles(Path.Combine(MyFileSystem.ContentPath, CAMPAIGN_CONTENT_RELATIVE_PATH), "*.vs",
                                      MySearchOption.TopDirectoryOnly);
            var localModFolders       = Directory.GetDirectories(MyFileSystem.ModsPath);
            var modFiles              = MyFileSystem.GetFiles(MyFileSystem.ModsPath, "*.sbm", MySearchOption.TopDirectoryOnly);
            var localModCampaignFiles = new List <string>();
            var modCampaignFiles      = new List <string>();

            // Gather local mod campaign files
            foreach (var localModFolder in localModFolders)
            {
                localModCampaignFiles.AddRange(
                    MyFileSystem.GetFiles(Path.Combine(localModFolder, CAMPAIGN_CONTENT_RELATIVE_PATH), "*.vs",
                                          MySearchOption.TopDirectoryOnly));
            }

            // Gather campaign files from workshop zips
            foreach (var modFile in modFiles)
            {
                try
                {
                    modCampaignFiles.AddRange(MyFileSystem.GetFiles(Path.Combine(modFile, CAMPAIGN_CONTENT_RELATIVE_PATH),
                                                                    "*.vs", MySearchOption.TopDirectoryOnly));
                }
                catch (Exception e)
                {
                    MySandboxGame.Log.WriteLine("ERROR: Reading mod file: " + modFile + "\n" + e);
                }
            }

            // Load vanilla files
            foreach (var vanillaFile in vanillaFiles)
            {
                MyObjectBuilder_VSFiles ob;
                if (MyObjectBuilderSerializer.DeserializeXML(vanillaFile, out ob))
                {
                    if (ob.Campaign != null)
                    {
                        ob.Campaign.IsVanilla  = true;
                        ob.Campaign.IsLocalMod = false;
                        LoadCampaignData(ob.Campaign);
                    }
                }
            }

            foreach (var localModCampaignFile in localModCampaignFiles)
            {
                MyObjectBuilder_VSFiles ob;
                if (MyObjectBuilderSerializer.DeserializeXML(localModCampaignFile, out ob))
                {
                    if (ob.Campaign != null)
                    {
                        ob.Campaign.IsVanilla     = false;
                        ob.Campaign.IsLocalMod    = true;
                        ob.Campaign.ModFolderPath = GetModFolderPath(localModCampaignFile);
                        LoadCampaignData(ob.Campaign);
                    }
                }
            }

            foreach (var modCampaignFile in modCampaignFiles)
            {
                MyObjectBuilder_VSFiles ob;
                if (MyObjectBuilderSerializer.DeserializeXML(modCampaignFile, out ob))
                {
                    if (ob.Campaign != null)
                    {
                        ob.Campaign.IsVanilla     = false;
                        ob.Campaign.IsLocalMod    = false;
                        ob.Campaign.ModFolderPath = GetModFolderPath(modCampaignFile);
                        LoadCampaignData(ob.Campaign);
                    }
                }
            }

            MySandboxGame.Log.WriteLine("MyCampaignManager.Constructor() - END");
        }
Beispiel #17
0
        public override void Init(MyObjectBuilder_SessionComponent sessionComponent)
        {
            base.Init(sessionComponent);

            // Only servers can run this session component
            if (!Session.IsServer)
            {
                return;
            }
            MyObjectBuilder_VisualScriptManagerSessionComponent ob = (MyObjectBuilder_VisualScriptManagerSessionComponent)sessionComponent;

            m_objectBuilder = ob;
            m_relativePathsToAbsolute.Clear();
            m_stateMachineDefinitionFilePaths.Clear();

            // Runs game started event
            m_firstUpdate = ob.FirstRun;

            // load vanilla level script files
            if (ob.LevelScriptFiles != null)
            {
                foreach (string relativeFilePath in ob.LevelScriptFiles)
                {
                    var absolutePath = Path.Combine(MyFileSystem.ContentPath, relativeFilePath);
                    // Add only existing files
                    if (MyFileSystem.FileExists(absolutePath))
                    {
                        m_relativePathsToAbsolute.Add(relativeFilePath, absolutePath);
                    }
                    else
                    {
                        MyLog.Default.WriteLine(relativeFilePath + " Level Script was not found.");
                        Debug.Fail(relativeFilePath + " Level Script was not found.");
                    }
                }
            }

            // load vanilla mission manchines
            if (ob.StateMachines != null)
            {
                foreach (var relativeFilePath in ob.StateMachines)
                {
                    var absolutePath = Path.Combine(MyFileSystem.ContentPath, relativeFilePath);
                    // Add only existing files
                    if (MyFileSystem.FileExists(absolutePath))
                    {
                        if (!m_relativePathsToAbsolute.ContainsKey(relativeFilePath))
                        {
                            m_stateMachineDefinitionFilePaths.Add(absolutePath);
                        }

                        m_relativePathsToAbsolute.Add(relativeFilePath, absolutePath);
                    }
                    else
                    {
                        MyLog.Default.WriteLine(relativeFilePath + " Mission File was not found.");
                        Debug.Fail(relativeFilePath + " Mission File was not found.");
                    }
                }
            }

            // Load mission machines and level scripts from mods
            // Overrides vanilla files
            if (Session.Mods != null)
            {
                foreach (var modItem in Session.Mods)
                {
                    // First try is a mod archive
                    var directoryPath = Path.Combine(MyFileSystem.ModsPath, modItem.PublishedFileId + ".sbm");
                    if (!MyFileSystem.DirectoryExists(directoryPath))
                    {
                        directoryPath = Path.Combine(MyFileSystem.ModsPath, modItem.Name);
                        if (!MyFileSystem.DirectoryExists(directoryPath))
                        {
                            directoryPath = null;
                        }
                    }

                    if (!string.IsNullOrEmpty(directoryPath))
                    {
                        foreach (var filePath in MyFileSystem.GetFiles(directoryPath, "*", MySearchOption.AllDirectories))
                        {
                            var extension    = Path.GetExtension(filePath);
                            var relativePath = MyFileSystem.MakeRelativePath(Path.Combine(directoryPath, "VisualScripts"), filePath);
                            if (extension == ".vs" || extension == ".vsc")
                            {
                                if (m_relativePathsToAbsolute.ContainsKey(relativePath))
                                {
                                    m_relativePathsToAbsolute[relativePath] = filePath;
                                }
                                else
                                {
                                    m_relativePathsToAbsolute.Add(relativePath, filePath);
                                }
                            }
                        }
                    }
                }
            }

            // Provider will compile all required scripts for the session.
            MyVSAssemblyProvider.Init(m_relativePathsToAbsolute.Values);
            // Retrive the Level script instances
            m_levelScripts = new CachingList <IMyLevelScript>();
            var scriptInstances = MyVSAssemblyProvider.GetLevelScriptInstances();

            if (scriptInstances != null)
            {
                scriptInstances.ForEach(script => m_levelScripts.Add(script));
            }
            m_levelScripts.ApplyAdditions();

            // Store the names of the level scripts
            m_runningLevelScriptNames         = m_levelScripts.Select(x => x.GetType().Name).ToArray();
            m_failedLevelScriptExceptionTexts = new string[m_runningLevelScriptNames.Length];

            // mission manager initialization - state machine definitions
            m_smManager = new MyVSStateMachineManager();
            foreach (var stateMachineFilePath in m_stateMachineDefinitionFilePaths)
            {
                m_smManager.AddMachine(stateMachineFilePath);
            }
        }