public void StartPreload(NodeAddedEvent e, SingleNode <PreloadAllResourcesComponent> preload, [JoinAll] DataBaseNode db)
 {
     if (DiskCaching.Enabled)
     {
         AssetBundleDatabase  assetBundleDatabase             = db.assetBundleDatabase.AssetBundleDatabase;
         AssetBundleDiskCache assetBundleDiskCache            = db.assetBundleDiskCache.AssetBundleDiskCache;
         List <string>        prioritizedAssetsConfigPathList = GetPrioritizedAssetsConfigPathList();
         int           num   = 100 + prioritizedAssetsConfigPathList.Count;
         List <string> list2 = new List <string>();
         for (int i = 0; i < prioritizedAssetsConfigPathList.Count; i++)
         {
             AssetReferenceComponent assetReferenceComponent = AssetReferenceComponent.createFromConfig(prioritizedAssetsConfigPathList[i]);
             string assetGuid = assetReferenceComponent.Reference.AssetGuid;
             list2.Add(assetGuid);
             AssetBundleInfo assetBundleInfoByGuid = assetBundleDatabase.GetAssetBundleInfoByGuid(assetGuid);
             if (!assetBundleDiskCache.IsCached(assetBundleInfoByGuid))
             {
                 this.CreateEntityForPreloadingBundles(assetReferenceComponent, num - i);
             }
         }
         foreach (string str2 in assetBundleDatabase.GetRootGuids())
         {
             AssetBundleInfo assetBundleInfoByGuid = assetBundleDatabase.GetAssetBundleInfoByGuid(str2);
             if (!list2.Contains(str2) && !assetBundleDiskCache.IsCached(assetBundleInfoByGuid))
             {
                 AssetReferenceComponent assetReferenceComponent = new AssetReferenceComponent(new AssetReference(str2));
                 this.CreateEntityForPreloadingBundles(assetReferenceComponent, 0);
             }
         }
     }
 }
        public AssetBundleDatabase DeserializeDatabase(byte[] bytes)
        {
            string str = string.Empty;

            if (true)
            {
                str = Encoding.UTF8.GetString(bytes);
                if (string.IsNullOrEmpty(str))
                {
                    throw new Exception("AssetBundleDatabase data is empty");
                }
            }
            else
            {
                using (GZipStream stream = new GZipStream(new MemoryStream(bytes), CompressionMode.Decompress))
                {
                    int    count  = 0xa00000;
                    byte[] buffer = new byte[count];
                    int    num2   = stream.Read(buffer, 0, count);
                    if ((num2 < bytes.Length) || (num2 == count))
                    {
                        throw new Exception("Decompress failed. read=" + num2);
                    }
                    str = new UTF8Encoding().GetString(buffer, 0, num2);
                }
            }
            AssetBundleDatabase database = new AssetBundleDatabase();

            database.Deserialize(str);
            return(database);
        }
 public AssetBundleDiskCache(AssetBundleDatabase dataBase, string baseUrl)
 {
     this.DataBase         = dataBase;
     this.BaseUrl          = baseUrl;
     this.CachePath        = this.ResolveAssetBundlesCachePath();
     this.diskWriter       = new DiskCacheWriterThread();
     this.diskWriterThread = new Thread(new ThreadStart(this.diskWriter.Run));
     this.diskWriterThread.Start();
     INSTANCE = this;
 }