private void _DownloadAssets(string listFileName, string text, PreDownloader.DownlaodToComplete userCompleteCallback)
        {
            int num = 0;

            BackgroundInstall.DownloadAssets downloadAssets = new BackgroundInstall.DownloadAssets(listFileName);
            foreach (string current in this._ParseBundleList(text))
            {
                PatchFileInfo patchFileInfo = PatchFinalList.Instance.GetPatchFileInfo(current);
                if (this._IsVersionCached(current, patchFileInfo.nVersion, patchFileInfo.bUseCustomCache))
                {
                    num++;
                }
                else
                {
                    downloadAssets.requestFiles.Add(current);
                }
            }
            int num2 = downloadAssets.requestFiles.Count + num;

            BackgroundInstall.Progress progress = new BackgroundInstall.Progress(num2, num);
            BackgroundInstall.ms_ProgressCollection[listFileName] = progress;
            if (downloadAssets.requestFiles.Count > 0)
            {
                progress.downloading = true;
                if (Option.EnableTrace)
                {
                    TsLog.Log("[PreDownload] Request( \"{0}\" ) => wait for downloads (Requests={1}, Cacheds={2}, Total={3})", new object[]
                    {
                        listFileName,
                        downloadAssets.requestFiles.Count,
                        num,
                        num2
                    });
                }
                downloadAssets.userCompleteCallback = userCompleteCallback;
                Helper.PreDownloadRequest(downloadAssets.requestFiles, new PostProcPerList(this._DownloadComplete_Assets), downloadAssets);
            }
            else
            {
                if (Option.EnableTrace)
                {
                    TsLog.Log("[PreDownload] Request( \"{0}\" ) => Complete to download: All file is chached on disk. (Progress={1}%, CachedFiles={2}, Total={3})", new object[]
                    {
                        listFileName,
                        (float)num / (float)num2 * 100f,
                        num,
                        num2
                    });
                }
                if (userCompleteCallback != null)
                {
                    userCompleteCallback(listFileName, (num != num2) ? ((float)num / (float)num2) : 1f);
                }
            }
        }
        public static bool Request(string listFileName, PreDownloader.DownlaodToComplete callback)
        {
            if (!Option.EnablePreDownload)
            {
                TsLog.LogWarning("[PreDownload] TsBundle.Predownloader.Rqeuset({0}) => Disabled pre-download", new object[]
                {
                    listFileName
                });
                return(false);
            }
            BackgroundInstall backgroundInstall = new BackgroundInstall();

            return(backgroundInstall._RequestPreDownload(listFileName, callback));
        }
 internal bool _RequestPreDownload(string listFileName, PreDownloader.DownlaodToComplete callback)
 {
     if (!Option.EnablePreDownload)
     {
         TsLog.LogWarning("[PreDownload] Request( \"{0}\" ) => Disalbe Pre-Download.", new object[]
         {
             listFileName
         });
         return(false);
     }
     BackgroundInstall.Progress progress;
     if (BackgroundInstall.ms_ProgressCollection.TryGetValue(listFileName, out progress) && progress.downloading)
     {
         TsLog.LogWarning("[PreDownload] Request( \"{0}\" ) => alreay request pre-download.", new object[]
         {
             listFileName
         });
         return(false);
     }
     if (Path.HasExtension(listFileName))
     {
         WWWItem wWWItem = Holder.TryGetOrCreateBundle(listFileName, Option.undefinedStackName);
         if (wWWItem == null)
         {
             TsLog.LogWarning("[PreDownload] Request( \"{0}\" ) => cannot read file from AssetBundle.", new object[]
             {
                 listFileName
             });
             return(false);
         }
         wWWItem.SetCallback(new PostProcPerItem(this._DownloadComplete_ListFile), callback);
         wWWItem.SetItemType(ItemType.USER_STRING);
         TsImmortal.bundleService.RequestDownloadCoroutine(wWWItem, DownGroup.RUNTIME, true);
     }
     else
     {
         TextAsset textAsset = ResourceCache.LoadFromResourcesImmediate(string.Format("PreDownload/{0}", listFileName)) as TextAsset;
         if (!textAsset)
         {
             TsLog.LogWarning("[PreDownload] Request( \"{0}\" ) => cannot read file from resources.", new object[]
             {
                 listFileName
             });
             return(false);
         }
         this._DownloadAssets(listFileName, textAsset.text, callback);
     }
     return(true);
 }