Ejemplo n.º 1
0
        public string RequestDependency(string dependency)
        {
            if (Files.TryGetValue(dependency, out string dependencyPath))
            {
                return(dependencyPath);
            }

            foreach (string dataPath in DataPathes)
            {
                string filePath = Path.Combine(dataPath, dependency);
                if (MultiFileStream.Exists(filePath))
                {
                    return(filePath);
                }

                if (FilenameUtils.IsDefaultResource(dependency))
                {
                    return(FindEngineDependency(dataPath, FilenameUtils.DefaultResourceName1) ??
                           FindEngineDependency(dataPath, FilenameUtils.DefaultResourceName2));
                }
                else if (FilenameUtils.IsBuiltinExtra(dependency))
                {
                    return(FindEngineDependency(dataPath, FilenameUtils.BuiltinExtraName1) ??
                           FindEngineDependency(dataPath, FilenameUtils.BuiltinExtraName2));
                }
            }
            return(null);
        }
Ejemplo n.º 2
0
        public MixedGameStructure(IEnumerable <string> pathes)
        {
            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 SelectUniquePathes(pathes))
            {
                if (MultiFileStream.Exists(path))
                {
                    string name = MultiFileStream.GetFileName(path);
                    AddFile(files, 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");
                }
            }

            DataPathes = dataPathes.ToArray();
            Files      = files;
            Assemblies = assemblies;
            Name       = Files.Count == 0 ? string.Empty : Files.First().Key;
        }
Ejemplo n.º 3
0
        protected void CollectGameFiles(DirectoryInfo root, IDictionary <string, string> files)
        {
            const string DataBundleName = DataName + AssetBundleExtension;
            string       dataBundlePath = Path.Combine(root.FullName, DataBundleName);

            if (MultiFileStream.Exists(dataBundlePath))
            {
                AddAssetBundle(files, DataBundleName, dataBundlePath);
            }

            string filePath = Path.Combine(root.FullName, GlobalGameManagerName);

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

            foreach (FileInfo levelFile in root.EnumerateFiles())
            {
                if (s_levelTemplate.IsMatch(levelFile.Name))
                {
                    string levelName = MultiFileStream.GetFileName(levelFile.Name);
                    AddFile(files, levelName, levelFile.FullName);
                }
            }
        }
        protected void CollectBundleGameFiles(DirectoryInfo root, IDictionary <string, string> files)
        {
            const string DataBundleName = DataName + AssetBundleExtension;
            string       dataBundlePath = Path.Combine(root.FullName, DataBundleName);

            if (MultiFileStream.Exists(dataBundlePath))
            {
                AddAssetBundle(files, DataBundleName, dataBundlePath);
            }
        }
Ejemplo n.º 5
0
 public static SerializedFileScheme LoadScheme(string filePath, string fileName, TransferInstructionFlags flags)
 {
     if (!MultiFileStream.Exists(filePath))
     {
         throw new Exception($"Serialized file at path '{filePath}' doesn't exist");
     }
     using (SmartStream fileStream = SmartStream.OpenRead(filePath))
     {
         return(ReadScheme(fileStream, 0, fileStream.Length, filePath, fileName, flags));
     }
 }
Ejemplo n.º 6
0
 public string RequestResource(string resource)
 {
     foreach (string dataPath in DataPathes)
     {
         string path = Path.Combine(dataPath, resource);
         if (MultiFileStream.Exists(path))
         {
             return(path);
         }
     }
     return(null);
 }
Ejemplo n.º 7
0
        public static bool IsBundleFile(string filePath)
        {
            if (!MultiFileStream.Exists(filePath))
            {
                throw new Exception($"Bundle at path '{filePath}' doesn't exist");
            }

            using (Stream stream = MultiFileStream.OpenRead(filePath))
            {
                return(IsBundleFile(stream));
            }
        }
Ejemplo n.º 8
0
        public static bool IsWebFile(string webPath)
        {
            if (!MultiFileStream.Exists(webPath))
            {
                throw new Exception($"Web at path '{webPath}' doesn't exist");
            }

            using (Stream stream = MultiFileStream.OpenRead(webPath))
            {
                return(IsWebFile(stream));
            }
        }
Ejemplo n.º 9
0
        public static ResourceFileScheme LoadScheme(string filePath, string fileName)
        {
            if (!MultiFileStream.Exists(filePath))
            {
                throw new Exception($"Resource file at path '{filePath}' doesn't exist");
            }

            using (SmartStream stream = SmartStream.OpenRead(filePath))
            {
                return(ReadScheme(stream, 0, stream.Length, filePath, fileName));
            }
        }