Exemple #1
0
        /// <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);
        }
Exemple #2
0
        /// <summary>
        /// 获取版本丢失的资源文件
        /// </summary>
        /// <param name="core">所使用的核心</param>
        /// <param name="version">要检查的版本</param>
        /// <returns>返回Key为路径,value为资源文件信息实例的集合</returns>
        public static Dictionary <string, JAssetsInfo> GetLostAssets(LaunchHandler core, JAssets assets)
        {
            Dictionary <string, JAssetsInfo> lostAssets = new Dictionary <string, JAssetsInfo>();

            try
            {
                if (assets == null)
                {
                    return(lostAssets);
                }
                foreach (var item in assets.Objects)
                {
                    string path = core.GetAssetsPath(item.Value);
                    if (lostAssets.ContainsKey(path))
                    {
                        continue;
                    }
                    else if (!File.Exists(path))
                    {
                        lostAssets.Add(item.Key, item.Value);
                    }
                }

                return(lostAssets);
            }
            catch
            {
                return(lostAssets);
            }
        }