using System; using System.IO; using System.Collections.Generic; using UnityEngine; namespace YooAsset { /// /// Web文件系统 /// internal class DefaultWebRemoteFileSystem : IFileSystem { /// /// 包裹名称 /// public string PackageName { private set; get; } /// /// 文件根目录 /// public string FileRoot { get { return string.Empty; } } /// /// 文件数量 /// public int FileCount { get { return 0; } } #region 自定义参数 /// /// 禁用Unity的网络缓存 /// public bool DisableUnityWebCache { private set; get; } = false; /// /// 自定义参数:跨域下载服务接口 /// public IRemoteServices RemoteServices { private set; get; } = null; /// /// 自定义参数:解密方法类 /// public IWebDecryptionServices DecryptionServices { private set; get; } #endregion public DefaultWebRemoteFileSystem() { } public virtual FSInitializeFileSystemOperation InitializeFileSystemAsync() { var operation = new DWRFSInitializeOperation(this); return operation; } public virtual FSLoadPackageManifestOperation LoadPackageManifestAsync(string packageVersion, int timeout) { var operation = new DWRFSLoadPackageManifestOperation(this, packageVersion, timeout); return operation; } public virtual FSRequestPackageVersionOperation RequestPackageVersionAsync(bool appendTimeTicks, int timeout) { var operation = new DWRFSRequestPackageVersionOperation(this, appendTimeTicks, timeout); return operation; } public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options) { var operation = new FSClearCacheFilesCompleteOperation(); return operation; } public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options) { throw new System.NotImplementedException(); } public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle) { if (bundle.BundleType == (int)EBuildBundleType.AssetBundle) { var operation = new DWRFSLoadAssetBundleOperation(this, bundle); return operation; } else { string error = $"{nameof(DefaultWebRemoteFileSystem)} not support load bundle type : {bundle.BundleType}"; var operation = new FSLoadBundleCompleteOperation(error); return operation; } } public virtual void SetParameter(string name, object value) { if (name == FileSystemParametersDefine.DISABLE_UNITY_WEB_CACHE) { DisableUnityWebCache = Convert.ToBoolean(value); } else if (name == FileSystemParametersDefine.REMOTE_SERVICES) { RemoteServices = (IRemoteServices)value; } else if (name == FileSystemParametersDefine.DECRYPTION_SERVICES) { DecryptionServices = (IWebDecryptionServices)value; } else { YooLogger.Warning($"Invalid parameter : {name}"); } } public virtual void OnCreate(string packageName, string packageRoot) { PackageName = packageName; } public virtual void OnDestroy() { } public virtual bool Belong(PackageBundle bundle) { return true; } public virtual bool Exists(PackageBundle bundle) { return true; } public virtual bool NeedDownload(PackageBundle bundle) { return false; } public virtual bool NeedUnpack(PackageBundle bundle) { return false; } public virtual bool NeedImport(PackageBundle bundle) { return false; } public virtual string GetBundleFilePath(PackageBundle bundle) { throw new System.NotImplementedException(); } public virtual byte[] ReadBundleFileData(PackageBundle bundle) { throw new System.NotImplementedException(); } public virtual string ReadBundleFileText(PackageBundle bundle) { throw new System.NotImplementedException(); } #region 内部方法 #endregion } }