/// <summary> /// 获取丢失的资源文件下载任务 /// </summary> /// <param name="source"></param> /// <param name="core"></param> /// <param name="version"></param> /// <returns></returns> public async static Task <List <DownloadTask> > GetLostAssetsDownloadTaskAsync(DownloadSource source, LaunchHandler core, MCVersion ver) { List <DownloadTask> tasks = new List <DownloadTask>(); JAssets assets = null; string assetsPath = core.GetAssetsIndexPath(ver.Assets); if (!File.Exists(assetsPath)) { if (ver.AssetIndex != null) { string jsonUrl = GetDownloadUrl.DoURLReplace(source, ver.AssetIndex.URL); string assetsJson = await HttpRequesterAPI.HttpGetStringAsync(jsonUrl); assets = core.GetAssetsByJson(assetsJson); tasks.Add(new DownloadTask("资源文件引导", jsonUrl, assetsPath)); } else { return(tasks); } } else { assets = core.GetAssets(ver); } var lostAssets = GetLostAssets(core, assets); foreach (var item in lostAssets) { DownloadTask task = GetDownloadUrl.GetAssetsDownloadTask(source, item.Value, core); tasks.Add(task); } return(tasks); }
/// <summary> /// 获取丢失的资源文件下载任务 /// </summary> /// <param name="source"></param> /// <param name="core"></param> /// <param name="version"></param> /// <returns></returns> public static List <DownloadTask> GetLostAssetsDownloadTask(DownloadSource source, LaunchHandler core, Version ver) { List <DownloadTask> tasks = new List <DownloadTask>(); JAssets assets = null; string assetsPath = core.GetAssetsIndexPath(ver.Assets); if (!File.Exists(assetsPath)) { if (ver.AssetIndex != null) { string jsonUrl = GetDownloadUrl.DoURLReplace(source, ver.AssetIndex.URL); string assetsJson = FunctionAPIHandler.HttpGet(jsonUrl); assets = core.GetAssetsByJson(assetsJson); tasks.Add(new DownloadTask("资源文件引导", jsonUrl, assetsPath)); } else { return(tasks); } } else { assets = core.GetAssets(ver); } var lostAssets = GetLostAssets(core, assets); foreach (var item in lostAssets) { DownloadTask task = GetDownloadUrl.GetAssetsDownloadTask(source, item.Value, core); if (!tasks.Contains(task)) { tasks.Add(task); } } return(tasks); }