protected void CollectGameFiles(DirectoryInfo root, IDictionary <string, string> files)
        {
            string filePath = Path.Combine(root.FullName, GlobalGameManagerName);

            if (FileMultiStream.Exists(filePath))
            {
                AddFile(files, GlobalGameManagerName, filePath);
            }
            else
            {
                filePath = Path.Combine(root.FullName, MainDataName);
                if (FileMultiStream.Exists(filePath))
                {
                    AddFile(files, MainDataName, filePath);
                }
            }

            foreach (FileInfo levelFile in root.EnumerateFiles())
            {
                if (s_levelName.IsMatch(levelFile.Name))
                {
                    string levelName = FileMultiStream.GetFileName(levelFile.Name);
                    AddFile(files, levelName, levelFile.FullName);
                }
            }
        }
示例#2
0
        public MixedGameStructure(FileCollection collection, IEnumerable <string> pathes) :
            base(collection)
        {
            Dictionary <string, string> files      = new Dictionary <string, string>();
            Dictionary <string, string> assemblies = new Dictionary <string, string>();
            HashSet <string>            dataPathes = new HashSet <string>();

            foreach (string path in pathes)
            {
                if (FileMultiStream.Exists(path))
                {
                    string name = FileMultiStream.GetFileName(path);
                    files.Add(name, path);
                    string directory = Path.GetDirectoryName(path);
                    dataPathes.Add(directory);
                }
                else if (DirectoryUtils.Exists(path))
                {
                    DirectoryInfo directory = new DirectoryInfo(DirectoryUtils.ToLongPath(path));
                    CollectFromDirectory(directory, files, assemblies, dataPathes);
                }
                else
                {
                    throw new Exception($"Neither file nor directory at '{path}' exists");
                }
            }

            if (files.Count == 0)
            {
                throw new Exception("No files has been found");
            }

            DataPathes = dataPathes.ToArray();
            Files      = files;
            Assemblies = assemblies;
            SetScriptingBackend();
            Name = Files.First().Key;
        }