BundleInfo.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. 
  2. namespace YooAsset
  3. {
  4. internal class BundleInfo
  5. {
  6. private readonly IFileSystem _fileSystem;
  7. private readonly string _importFilePath;
  8. /// <summary>
  9. /// 资源包对象
  10. /// </summary>
  11. public readonly PackageBundle Bundle;
  12. public BundleInfo(IFileSystem fileSystem, PackageBundle bundle)
  13. {
  14. _fileSystem = fileSystem;
  15. Bundle = bundle;
  16. _importFilePath = null;
  17. }
  18. public BundleInfo(IFileSystem fileSystem, PackageBundle bundle, string importFilePath)
  19. {
  20. _fileSystem = fileSystem;
  21. Bundle = bundle;
  22. _importFilePath = importFilePath;
  23. }
  24. /// <summary>
  25. /// 加载资源包
  26. /// </summary>
  27. public FSLoadBundleOperation LoadBundleFile()
  28. {
  29. return _fileSystem.LoadBundleFile(Bundle);
  30. }
  31. /// <summary>
  32. /// 创建下载器
  33. /// </summary>
  34. public FSDownloadFileOperation CreateDownloader(int failedTryAgain, int timeout)
  35. {
  36. DownloadParam downloadParam = new DownloadParam(failedTryAgain, timeout);
  37. downloadParam.ImportFilePath = _importFilePath;
  38. return _fileSystem.DownloadFileAsync(Bundle, downloadParam);
  39. }
  40. /// <summary>
  41. /// 是否需要从远端下载
  42. /// </summary>
  43. public bool IsNeedDownloadFromRemote()
  44. {
  45. return _fileSystem.NeedDownload(Bundle);
  46. }
  47. /// <summary>
  48. /// 下载器合并识别码
  49. /// </summary>
  50. public string GetDownloadCombineGUID()
  51. {
  52. return $"{_fileSystem.GetHashCode()}_{Bundle.BundleGUID}";
  53. }
  54. }
  55. }