예제 #1
0
 private void BeginUnzip(byte[] bytes, int size, string dest, List <string> requestIDs, AssetList assetList)
 {
     if (!this.mMutexAcquired)
     {
         this.mMutex.WaitOne();
         this.mMutexAcquired = true;
     }
     AssetDownloader.UnzipJob unzipJob = new AssetDownloader.UnzipJob();
     unzipJob.Bytes = bytes;
     unzipJob.Size  = size;
     unzipJob.Dest  = dest;
     unzipJob.nodes = new List <AssetDownloader.UnzipJob.Node>();
     using (List <string> .Enumerator enumerator = requestIDs.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             string         current  = enumerator.Current;
             AssetList.Item itemById = assetList.FindItemByID(current);
             unzipJob.nodes.Add(new AssetDownloader.UnzipJob.Node()
             {
                 ID   = current,
                 hash = itemById.Hash
             });
         }
     }
     this.mUnzipJobs.Add(unzipJob);
     if (size <= 0)
     {
         unzipJob.State = AssetDownloader.UnzipJobState.Error;
     }
     this.mMutex.ReleaseMutex();
     this.mMutexAcquired = false;
     this.mUnzipSignal.Set();
 }
예제 #2
0
    public static SceneRequest LoadSceneAsync(string sceneName, bool additive)
    {
        sceneName = AssetManager.GetLocalizedObjectName(sceneName, true);
        AssetList.Item          itemByPath = AssetManager.AssetList.FindItemByPath(sceneName);
        List <AssetBundleCache> result     = (List <AssetBundleCache>)null;
        SceneRequest            sceneRequest;

        if (itemByPath == null)
        {
            sceneRequest = (SceneRequest) new DefaultSceneRequest(!additive ? SceneManager.LoadSceneAsync(sceneName, (LoadSceneMode)0) : SceneManager.LoadSceneAsync(sceneName, (LoadSceneMode)1), additive);
        }
        else
        {
            result = new List <AssetBundleCache>();
            AssetManager.Instance.OpenAssetBundleAndDependencies(itemByPath, 1, result, 0.0f);
            sceneRequest = (SceneRequest) new DefaultSceneRequest(!additive ? SceneManager.LoadSceneAsync(sceneName, (LoadSceneMode)0) : SceneManager.LoadSceneAsync(sceneName, (LoadSceneMode)1), additive);
        }
        AssetManager.Instance.mSceneRequests.Add(sceneRequest);
        AssetManager.Instance.mScenes.Add(new AssetManager.ManagedScene()
        {
            Name         = sceneName,
            AssetBundles = result,
            Request      = sceneRequest
        });
        return(sceneRequest);
    }
예제 #3
0
 public static void LoadSceneImmediate(string sceneName, bool additive)
 {
     sceneName = AssetManager.GetLocalizedObjectName(sceneName, true);
     AssetList.Item itemByPath = AssetManager.AssetList.FindItemByPath(sceneName);
     if (itemByPath == null)
     {
         if (additive)
         {
             Application.LoadLevelAdditive(sceneName);
         }
         else
         {
             Application.LoadLevel(sceneName);
         }
     }
     else
     {
         List <AssetBundleCache> result = new List <AssetBundleCache>();
         AssetManager.Instance.OpenAssetBundleAndDependencies(itemByPath, 1, result, 0.0f);
         AssetManager.ManagedScene managedScene = new AssetManager.ManagedScene();
         managedScene.Name         = sceneName;
         managedScene.AssetBundles = result;
         if (additive)
         {
             SceneManager.LoadScene(sceneName, (LoadSceneMode)1);
         }
         else
         {
             SceneManager.LoadScene(sceneName, (LoadSceneMode)0);
             AssetManager.Instance.ReleaseSceneAssetBundles();
         }
         AssetManager.Instance.mScenes.Add(managedScene);
     }
 }
예제 #4
0
 private void BeginUnzip(byte[] bytes, int size, string dest, string requestID, AssetList assetList)
 {
     if (!this.mMutexAcquired)
     {
         this.mMutex.WaitOne();
         this.mMutexAcquired = true;
     }
     AssetDownloader.UnzipJob unzipJob = new AssetDownloader.UnzipJob();
     unzipJob.Bytes = bytes;
     unzipJob.Size  = size;
     unzipJob.Dest  = dest;
     unzipJob.nodes = new List <AssetDownloader.UnzipJob.Node>();
     AssetList.Item itemById = assetList.FindItemByID(requestID);
     unzipJob.nodes.Add(new AssetDownloader.UnzipJob.Node()
     {
         ID   = requestID,
         hash = itemById.Hash,
         Item = itemById
     });
     this.mUnzipJobs.Add(unzipJob);
     if (size <= 0)
     {
         unzipJob.State = AssetDownloader.UnzipJobState.Error;
     }
     this.mMutex.ReleaseMutex();
     this.mMutexAcquired = false;
     this.mUnzipSignal.Set();
 }
예제 #5
0
 public FastLoadRequest(AssetList.Item assetBundleNode, string assetName, System.Type assetType)
 {
     this.mAssetBundleNode = assetBundleNode;
     this.mAssetName       = assetName;
     this.mAssetType       = assetType;
     FastLoadRequest.mRequests.Add(this);
     this.UpdateLoading();
 }
예제 #6
0
 public void SetDependencies(uint ID, uint[] dependencies)
 {
     AssetList.Item obj = this.AddItem(ID);
     obj.Dependencies = new AssetList.Item[dependencies.Length];
     for (int index = 0; index < dependencies.Length; ++index)
     {
         obj.Dependencies[index] = this.AddItem(dependencies[index]);
     }
 }
예제 #7
0
 public override void OnActivate(int pinID)
 {
     if (pinID != 0)
     {
         return;
     }
     if (!GameUtility.Config_UseAssetBundles.Value)
     {
         this.ActivateOutputLinks(11);
     }
     else
     {
         if (((Behaviour)this).get_enabled())
         {
             return;
         }
         GameManager  instance = MonoSingleton <GameManager> .Instance;
         GachaParam[] gachas   = instance.Gachas;
         for (int index1 = 0; index1 < gachas.Length; ++index1)
         {
             if (gachas[index1] != null)
             {
                 if (gachas[index1].units != null && gachas[index1].units.Count > 0)
                 {
                     for (int index2 = 0; index2 < gachas[index1].units.Count; ++index2)
                     {
                         if (instance.Player.FindUnitDataByUnitID(gachas[index1].units[index2].iname) == null && this.DownloadUnits.IndexOf(gachas[index1].units[index2].iname) == -1)
                         {
                             this.DownloadUnits.Add(gachas[index1].units[index2].iname);
                         }
                     }
                 }
                 if (gachas[index1].artifacts != null && gachas[index1].artifacts.Count > 0)
                 {
                     for (int index2 = 0; index2 < gachas[index1].artifacts.Count; ++index2)
                     {
                         ArtifactParam artifact = gachas[index1].artifacts[index2];
                         if (artifact != null)
                         {
                             string path = AssetPath.Artifacts(artifact);
                             if (!string.IsNullOrEmpty(path))
                             {
                                 AssetList.Item itemByPath = AssetManager.AssetList.FindItemByPath(path);
                                 if (itemByPath != null && !AssetManager.IsAssetInCache(itemByPath.IDStr))
                                 {
                                     this.DownloadArtifacts.Add(artifact);
                                 }
                             }
                         }
                     }
                 }
             }
         }
         ((Behaviour)this).set_enabled(true);
         this.StartCoroutine(this.AsyncWork(pinID == 1));
     }
 }
예제 #8
0
    public AssetBundleCache OpenAssetBundleAndDependencies(AssetList.Item node, int refCount = 1, List <AssetBundleCache> result = null, float expireTime = 0.0f)
    {
        if (this.mAssetBundles.Count + (1 + node.Dependencies.Length) > AssetManager.MaxAssetBundles)
        {
            this.UnloadUnusedAssetBundles(true, true);
        }
        AssetBundleCache assetBundleCache1 = this.OpenAssetBundle(node.IDStr, (node.Flags & AssetBundleFlags.Persistent) != (AssetBundleFlags)0, false);

        if (assetBundleCache1 == null)
        {
            return((AssetBundleCache)null);
        }
        assetBundleCache1.AddReferencer(refCount);
        if (result != null)
        {
            result.Add(assetBundleCache1);
        }
        this.OpenScriptAssetBundle();
        bool flag1 = false;
        bool flag2 = false;

        if (assetBundleCache1.Dependencies == null)
        {
            assetBundleCache1.Dependencies = new AssetBundleCache[node.Dependencies.Length + 1];
            assetBundleCache1.Dependencies[assetBundleCache1.Dependencies.Length - 1] = assetBundleCache1;
            flag2 = true;
        }
        for (int index = 0; index < node.Dependencies.Length; ++index)
        {
            AssetList.Item   dependency        = node.Dependencies[index];
            AssetBundleCache assetBundleCache2 = this.OpenAssetBundle(dependency.IDStr, (dependency.Flags & AssetBundleFlags.Persistent) != (AssetBundleFlags)0, false);
            if (flag2)
            {
                assetBundleCache1.Dependencies[index] = assetBundleCache2;
            }
            if (assetBundleCache2 != null)
            {
                if (assetBundleCache2.NumReferencers == 0)
                {
                    assetBundleCache2.ExpireTime = expireTime;
                }
                if (result != null)
                {
                    result.Add(assetBundleCache2);
                }
                assetBundleCache2.AddReferencer(refCount);
            }
            flag1 |= assetBundleCache2 == null;
        }
        if (flag1)
        {
            DebugUtility.LogError("Error occurred when opening '" + ((Object)this).get_name() + "'");
        }
        return(assetBundleCache1);
    }
예제 #9
0
 private void RemoveCompletedDownloadRequests(string cacheDir, AssetList assets)
 {
     for (int index = 0; index < AssetDownloader.mRequestIDs.Count; ++index)
     {
         AssetList.Item itemById = assets.FindItemByID(AssetDownloader.mRequestIDs[index]);
         if (itemById != null && itemById.Exist)
         {
             AssetDownloader.mRequestIDs.RemoveAt(index--);
         }
     }
 }
예제 #10
0
 private void DownloadLocalizedAssetAndDependencies(AssetList.Item node, AssetList assetList)
 {
     if (node == null)
     {
         return;
     }
     if (!node.Exist)
     {
         AssetDownloader.Add(node.IDStr);
     }
     for (int index = 0; index < node.Dependencies.Length; ++index)
     {
         if (!File.Exists(AssetDownloader.CachePath + node.Dependencies[index].IDStr))
         {
             AssetDownloader.Add(node.Dependencies[index].IDStr);
         }
     }
     for (int index = 0; index < node.AdditionalDependencies.Length; ++index)
     {
         string         path = AssetDownloader.CachePath + node.AdditionalDependencies[index].IDStr;
         string         localizedObjectName = AssetManager.GetLocalizedObjectName(node.AdditionalDependencies[index].Path, false);
         AssetList.Item itemByPath          = assetList.FindItemByPath(localizedObjectName);
         if (localizedObjectName == node.AdditionalDependencies[index].Path || itemByPath == null)
         {
             if (!File.Exists(path))
             {
                 AssetDownloader.Add(node.AdditionalDependencies[index].IDStr);
             }
         }
         else if (!File.Exists(AssetDownloader.CachePath + itemByPath.IDStr))
         {
             AssetDownloader.Add(itemByPath.IDStr);
         }
     }
     for (int index = 0; index < node.AdditionalStreamingAssets.Length; ++index)
     {
         string         path = AssetDownloader.CachePath + node.AdditionalStreamingAssets[index].IDStr;
         string         localizedObjectName = AssetManager.GetLocalizedObjectName(node.AdditionalStreamingAssets[index].Path, false);
         AssetList.Item itemByPath          = assetList.FindItemByPath(localizedObjectName);
         if (localizedObjectName == node.AdditionalStreamingAssets[index].Path || itemByPath == null)
         {
             if (!File.Exists(path))
             {
                 AssetDownloader.Add(node.AdditionalStreamingAssets[index].IDStr);
             }
         }
         else if (!File.Exists(AssetDownloader.CachePath + itemByPath.IDStr))
         {
             DebugUtility.LogWarning("Downloading localized streaming dependency: " + localizedObjectName);
             AssetDownloader.Add(itemByPath.IDStr);
         }
     }
 }
예제 #11
0
 public void SetPath(AssetList.Item item, string path)
 {
     if (!string.IsNullOrEmpty(item.Path))
     {
         this.mPath2Item.Remove(item.Path);
     }
     item.SetPath(path);
     if (string.IsNullOrEmpty(path))
     {
         return;
     }
     this.mPath2Item[path] = item;
 }
예제 #12
0
    public static string GetStreamingAssetPath(string name)
    {
        AssetList.Item itemByPath = AssetManager.AssetList.FindItemByPath(name);
        if (itemByPath != null)
        {
            return(AssetDownloader.CachePath + itemByPath.IDStr);
        }
        StringBuilder stringBuilder = GameUtility.GetStringBuilder();

        stringBuilder.Append(Application.get_streamingAssetsPath());
        stringBuilder.Append('/');
        stringBuilder.Append(Path.GetFileName(name));
        return(stringBuilder.ToString());
    }
예제 #13
0
 public AssetList.Item AddItem(uint ID)
 {
     for (int index = 0; index < this.mItems.Count; ++index)
     {
         if ((int)this.mItems[index].ID == (int)ID)
         {
             return(this.mItems[index]);
         }
     }
     AssetList.Item obj = new AssetList.Item();
     obj.ID    = ID;
     obj.IDStr = ID.ToString("X8").ToLower();
     this.mItems.Add(obj);
     return(obj);
 }
예제 #14
0
 public void FileCheckThread(object arg)
 {
     AssetDownloader.FileCheckArg fileCheckArg = arg as AssetDownloader.FileCheckArg;
     if (fileCheckArg == null)
     {
         return;
     }
     for (int index = 0; index < AssetDownloader.mExistFile.Count; ++index)
     {
         AssetList.Item itemById = fileCheckArg.assetList.FastFindItemByID(AssetDownloader.mExistFile[index].FileID);
         if (itemById != null)
         {
             itemById.Exist = true;
         }
     }
 }
예제 #15
0
 public static string LoadTextData(string path)
 {
     AssetList.Item itemByPath1 = AssetManager.TxtAssetList.FindItemByPath(path);
     if (itemByPath1 != null)
     {
         int    size;
         IntPtr num = NativePlugin.DecompressFile(AssetDownloader.TextCachePath + itemByPath1.IDStr, out size);
         if (num == IntPtr.Zero)
         {
             return((string)null);
         }
         byte[] numArray = new byte[size];
         Marshal.Copy(num, numArray, 0, size);
         NativePlugin.FreePtr(num);
         using (StreamReader streamReader = new StreamReader((Stream) new MemoryStream(numArray), Encoding.UTF8))
             return(streamReader.ReadToEnd());
     }
     else
     {
         AssetList.Item itemByPath2 = AssetManager.AssetList.FindItemByPath(path);
         if (itemByPath2 != null)
         {
             int    size;
             IntPtr num = NativePlugin.DecompressFile(AssetDownloader.CachePath + itemByPath2.IDStr, out size);
             if (num == IntPtr.Zero)
             {
                 return((string)null);
             }
             byte[] numArray = new byte[size];
             Marshal.Copy(num, numArray, 0, size);
             NativePlugin.FreePtr(num);
             using (StreamReader streamReader = new StreamReader((Stream) new MemoryStream(numArray), Encoding.UTF8))
                 return(streamReader.ReadToEnd());
         }
         else
         {
             TextAsset textAsset = (TextAsset)Resources.Load <TextAsset>(path);
             if (Object.op_Inequality((Object)textAsset, (Object)null))
             {
                 return(textAsset.get_text());
             }
             return((string)null);
         }
     }
 }
예제 #16
0
 public void ReadSkipAssetList(string path, ref Dictionary <uint, AssetList.Item> ItemMap)
 {
     using (BinaryReader binaryReader = new BinaryReader((Stream)File.Open(path, FileMode.Open)))
     {
         binaryReader.ReadInt32();
         int num1 = binaryReader.ReadInt32();
         for (int index1 = 0; index1 < num1; ++index1)
         {
             AssetList.Item obj = new AssetList.Item();
             obj.ID             = binaryReader.ReadUInt32();
             obj.IDStr          = obj.ID.ToString("X8").ToLower();
             obj.Size           = binaryReader.ReadInt32();
             obj.CompressedSize = binaryReader.ReadInt32();
             obj.Path           = binaryReader.ReadString();
             obj.PathHash       = binaryReader.ReadInt32();
             obj.Hash           = binaryReader.ReadUInt32();
             obj.Flags          = (AssetBundleFlags)binaryReader.ReadInt32();
             for (int index2 = 0; index2 < 3; ++index2)
             {
                 int num2 = binaryReader.ReadInt32();
                 if (num2 < 0)
                 {
                     throw new Exception("Paramater is Broken. cnt:" + (object)num1 + "/ hash:" + obj.IDStr);
                 }
                 if (num2 != 0)
                 {
                     binaryReader.ReadBytes(num2 * 4);
                 }
             }
             if (!ItemMap.ContainsKey(obj.ID))
             {
                 ItemMap.Add(obj.ID, obj);
             }
         }
     }
 }
예제 #17
0
    private void CompareFileListHashThread(object args)
    {
        AssetDownloader.CompareFileListHashArg compareFileListHashArg = args as AssetDownloader.CompareFileListHashArg;
        if (compareFileListHashArg == null || string.IsNullOrEmpty(compareFileListHashArg.cacheDir) || compareFileListHashArg.nodes == null)
        {
            return;
        }
        string    cacheDir  = compareFileListHashArg.cacheDir;
        AssetList assetList = AssetManager.AssetList;

        if (compareFileListHashArg.dic.Count == 0)
        {
            AssetDownloader.mExistFile.Clear();
            for (int index = 0; index < compareFileListHashArg.nodes.Count; ++index)
            {
                this.mCompareHashMutex.WaitOne();
                this.mCompareHashProgressShared = (float)index / (float)compareFileListHashArg.nodes.Count;
                this.mCompareHashMutex.ReleaseMutex();
                AssetDownloader.CompareFileListHashArg.Node node = compareFileListHashArg.nodes[index];
                if (node != null && !string.IsNullOrEmpty(node.IDStr) && !string.IsNullOrEmpty(node.metaPath))
                {
                    string path     = cacheDir + node.IDStr;
                    string metaPath = node.metaPath;
                    bool   flag1    = File.Exists(path);
                    bool   flag2    = false;
                    if (File.Exists(metaPath))
                    {
                        if (flag1)
                        {
                            if (AssetDownloader.GetFileSize(path) != (long)node.Size)
                            {
                                flag2 = true;
                                goto label_17;
                            }
                        }
                        try
                        {
                            using (FileStream fileStream = new FileStream(metaPath, FileMode.Open))
                            {
                                uint num = new BinaryReader((Stream)fileStream).ReadUInt32();
                                if ((int)node.Hash != (int)num)
                                {
                                    flag2 = true;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            flag2 = true;
                        }
label_17:
                        if (flag2)
                        {
                            File.Delete(metaPath);
                        }
                    }
                    else
                    {
                        flag2 = true;
                    }
                    if (flag1)
                    {
                        if (flag2)
                        {
                            File.Delete(path);
                        }
                        else
                        {
                            node.Item.Exist = true;
                            AssetDownloader.mExistFile.Add(new AssetDownloader.ExistAssetList(node.Item.ID, assetList.SearchItemIdx(node.Item.ID)));
                        }
                    }
                }
            }
        }
        else
        {
            AssetDownloader.ExistAssetList[] array = AssetDownloader.mExistFile.ToArray();
            for (int index = 0; index < array.Length; ++index)
            {
                this.mCompareHashMutex.WaitOne();
                this.mCompareHashProgressShared = (float)index / (float)array.Length;
                this.mCompareHashMutex.ReleaseMutex();
                bool           flag     = false;
                AssetList.Item itemById = AssetManager.AssetList.FastFindItemByID(array[index].FileID);
                AssetList.Item obj;
                if (itemById != null && compareFileListHashArg.dic.TryGetValue(array[index].FileID, out obj))
                {
                    if (flag | itemById.Size != obj.Size | (int)itemById.Hash != (int)obj.Hash)
                    {
                        AssetDownloader.mExistFile.Remove(array[index]);
                    }
                    else
                    {
                        itemById.Exist = true;
                    }
                }
            }
        }
    }
예제 #18
0
    private LoadRequest InternalLoadAsync(string name, System.Type type)
    {
        string localizedObjectName = AssetManager.GetLocalizedObjectName(name, false);

        if (name != localizedObjectName)
        {
            if (GameUtility.Config_UseAssetBundles.Value)
            {
                AssetList.Item itemByPath = AssetManager.AssetList.FindItemByPath(localizedObjectName);
                if (itemByPath != null && itemByPath.Exist)
                {
                    name = localizedObjectName;
                }
            }
            else
            {
                name = localizedObjectName;
            }
        }
        AssetManager.ManagedAsset managedAsset = (AssetManager.ManagedAsset)null;
        bool flag     = true;
        int  hashCode = name.GetHashCode();

        for (int index = this.mLoadingAssets.Count - 1; index >= 0; --index)
        {
            if (this.mLoadingAssets[index].HashCode == hashCode && (object)this.mLoadingAssets[index].AssetType == (object)type && this.mLoadingAssets[index].Name == name)
            {
                return((LoadRequest)this.mLoadingAssets[index].Request_Weak.Target);
            }
        }
        for (int index = this.mAssets.Count - 1; index >= 0; --index)
        {
            managedAsset = this.mAssets[index];
            if (managedAsset.HashCode == hashCode && (object)managedAsset.AssetType == (object)type && managedAsset.Name == name)
            {
                if (managedAsset.Asset.IsAlive && Object.op_Inequality(managedAsset.Asset.Target, (Object)null))
                {
                    return((LoadRequest) new ResourceLoadRequest(managedAsset.Asset.Target));
                }
                this.mAssets.RemoveAt(index);
                flag = false;
                break;
            }
        }
        if (flag)
        {
            managedAsset           = new AssetManager.ManagedAsset();
            managedAsset.Name      = name;
            managedAsset.HashCode  = hashCode;
            managedAsset.AssetType = type;
        }
        AssetList.Item itemByPath1 = AssetManager.AssetList.FindItemByPath(name);
        LoadRequest    loadRequest;

        if (itemByPath1 == null)
        {
            loadRequest = !type.IsSubclassOf(typeof(Texture)) ? (LoadRequest) new ResourceLoadRequest(Resources.LoadAsync(name, type)) : (LoadRequest) new FastLoadRequest((AssetList.Item)null, name, type);
        }
        else if (type.IsSubclassOf(typeof(Texture)))
        {
            loadRequest = (LoadRequest) new FastLoadRequest(itemByPath1, name, type);
        }
        else
        {
            managedAsset.AssetBundles = new List <AssetBundleCache>();
            AssetBundleCache assetBundle = this.OpenAssetBundleAndDependencies(itemByPath1, 1, managedAsset.AssetBundles, 0.0f);
            if (assetBundle == null)
            {
                loadRequest           = (LoadRequest) new ResourceLoadRequest((Object)null);
                managedAsset.HasError = true;
            }
            else
            {
                string withoutExtension = Path.GetFileNameWithoutExtension(name);
                loadRequest = (LoadRequest) new AssetBundleLoadRequest(assetBundle, withoutExtension, type);
            }
        }
        managedAsset.Request_Weak   = new WeakReference((object)loadRequest);
        managedAsset.Request_Strong = loadRequest;
        this.mLoadingAssets.Add(managedAsset);
        return(loadRequest);
    }
예제 #19
0
 public void ReadAssetListProc(string path, ref List <AssetList.Item> ItemList)
 {
     using (BinaryReader binaryReader = new BinaryReader((Stream)File.Open(path, FileMode.Open)))
     {
         this.mRevision = binaryReader.ReadInt32();
         int length1 = binaryReader.ReadInt32();
         AssetList.Item[] objArray = new AssetList.Item[length1];
         ItemList = (List <AssetList.Item>)null;
         ItemList = new List <AssetList.Item>((IEnumerable <AssetList.Item>)objArray);
         for (int index1 = 0; index1 < length1; ++index1)
         {
             if (ItemList[index1] == null)
             {
                 ItemList[index1] = new AssetList.Item();
             }
             AssetList.Item obj = ItemList[index1];
             obj.ID             = binaryReader.ReadUInt32();
             obj.IDStr          = obj.ID.ToString("X8").ToLower();
             obj.Size           = binaryReader.ReadInt32();
             obj.CompressedSize = binaryReader.ReadInt32();
             obj.Path           = binaryReader.ReadString();
             obj.PathHash       = binaryReader.ReadInt32();
             this.SetPath(obj, obj.Path);
             obj.Hash  = binaryReader.ReadUInt32();
             obj.Flags = (AssetBundleFlags)binaryReader.ReadInt32();
             int length2 = binaryReader.ReadInt32();
             if (length2 != 0)
             {
                 if (length2 < 0)
                 {
                     throw new Exception("Dependencies Paramater is Broken. cnt:" + (object)length1 + "/ hash:" + obj.IDStr);
                 }
                 obj.Dependencies = new AssetList.Item[length2];
                 for (int index2 = 0; index2 < obj.Dependencies.Length; ++index2)
                 {
                     int index3 = binaryReader.ReadInt32();
                     if (this.mItems[index3] == null)
                     {
                         ItemList[index3] = new AssetList.Item();
                     }
                     obj.Dependencies[index2] = ItemList[index3];
                 }
             }
             else
             {
                 obj.Dependencies = new AssetList.Item[0];
             }
             int length3 = binaryReader.ReadInt32();
             if (length3 != 0)
             {
                 if (length3 < 0)
                 {
                     throw new Exception("AdditionalDependencies Paramater is Broken. cnt:" + (object)length1 + "/ hash:" + obj.IDStr);
                 }
                 obj.AdditionalDependencies = new AssetList.Item[length3];
                 for (int index2 = 0; index2 < obj.AdditionalDependencies.Length; ++index2)
                 {
                     int index3 = binaryReader.ReadInt32();
                     if (this.mItems[index3] == null)
                     {
                         ItemList[index3] = new AssetList.Item();
                     }
                     obj.AdditionalDependencies[index2] = ItemList[index3];
                 }
             }
             else
             {
                 obj.AdditionalDependencies = new AssetList.Item[0];
             }
             int length4 = binaryReader.ReadInt32();
             if (length4 != 0)
             {
                 if (length4 < 0)
                 {
                     throw new Exception("AdditionalStreamingAssets Paramater is Broken. cnt:" + (object)length1 + "/ hash:" + obj.IDStr);
                 }
                 obj.AdditionalStreamingAssets = new AssetList.Item[length4];
                 for (int index2 = 0; index2 < obj.AdditionalStreamingAssets.Length; ++index2)
                 {
                     int index3 = binaryReader.ReadInt32();
                     if (this.mItems[index3] == null)
                     {
                         ItemList[index3] = new AssetList.Item();
                     }
                     obj.AdditionalStreamingAssets[index2] = ItemList[index3];
                 }
             }
             else
             {
                 obj.AdditionalStreamingAssets = new AssetList.Item[0];
             }
             if (!this.mID2Item.ContainsKey(obj.ID))
             {
                 this.mID2Item.Add(obj.ID, obj);
             }
         }
     }
 }
예제 #20
0
 public void ReadFromMemory(string src)
 {
     try
     {
         StringReader stringReader1 = new StringReader(src);
         int          num           = 0;
         StringReader stringReader2 = new StringReader(src);
         this.mRevision = 0;
         string str1 = stringReader2.ReadLine();
         if (str1.StartsWith("Revision:"))
         {
             int startIndex = str1.IndexOf(':') + 1;
             int.TryParse(str1.Substring(startIndex), out this.mRevision);
             ++num;
         }
         string str2;
         while ((str2 = stringReader2.ReadLine()) != null)
         {
             ++num;
             string[]       strArray1 = str2.Split('\t');
             AssetList.Item obj       = this.AddItem(uint.Parse(strArray1[0], NumberStyles.HexNumber));
             this.SetPath(obj, strArray1[1]);
             obj.Size           = int.Parse(strArray1[2]);
             obj.Hash           = uint.Parse(strArray1[3], NumberStyles.HexNumber);
             obj.Flags          = (AssetBundleFlags)int.Parse(strArray1[4]);
             obj.CompressedSize = int.Parse(strArray1[8]);
             if (!string.IsNullOrEmpty(strArray1[5]))
             {
                 string[] strArray2 = strArray1[5].Split(',');
                 obj.Dependencies = new AssetList.Item[strArray2.Length];
                 for (int index = 0; index < strArray2.Length; ++index)
                 {
                     obj.Dependencies[index] = this.AddItem(strArray2[index]);
                 }
             }
             else
             {
                 obj.Dependencies = new AssetList.Item[0];
             }
             if (!string.IsNullOrEmpty(strArray1[6]))
             {
                 string[] strArray2 = strArray1[6].Split(',');
                 obj.AdditionalDependencies = new AssetList.Item[strArray2.Length];
                 for (int index = 0; index < strArray2.Length; ++index)
                 {
                     obj.AdditionalDependencies[index] = this.AddItem(strArray2[index]);
                 }
             }
             else
             {
                 obj.AdditionalDependencies = new AssetList.Item[0];
             }
             if (strArray1.Length > 7 && !string.IsNullOrEmpty(strArray1[7]))
             {
                 string[] strArray2 = strArray1[7].Split(',');
                 obj.AdditionalStreamingAssets = new AssetList.Item[strArray2.Length];
                 for (int index = 0; index < strArray2.Length; ++index)
                 {
                     obj.AdditionalStreamingAssets[index] = this.AddItem(strArray2[index]);
                 }
             }
             else
             {
                 obj.AdditionalStreamingAssets = new AssetList.Item[0];
             }
         }
     }
     catch (Exception ex)
     {
         Debug.LogException(ex);
     }
 }
예제 #21
0
    public Object InternalLoad(string name, System.Type type)
    {
        AssetManager.ManagedAsset managedAsset = (AssetManager.ManagedAsset)null;
        string localizedObjectName             = AssetManager.GetLocalizedObjectName(name, false);

        if (name != localizedObjectName)
        {
            if (GameUtility.Config_UseAssetBundles.Value)
            {
                AssetList.Item itemByPath = AssetManager.AssetList.FindItemByPath(localizedObjectName);
                if (itemByPath != null && itemByPath.Exist)
                {
                    name = localizedObjectName;
                }
            }
            else
            {
                name = localizedObjectName;
            }
        }
        int hashCode = name.GetHashCode();

        for (int index = this.mLoadingAssets.Count - 1; index >= 0; --index)
        {
            if (this.mLoadingAssets[index].HashCode == hashCode && (object)this.mLoadingAssets[index].AssetType == (object)type && this.mLoadingAssets[index].Name == name)
            {
                managedAsset = this.mLoadingAssets[index];
                this.mLoadingAssets.RemoveAt(index);
                this.mAssets.Add(managedAsset);
                managedAsset.Request_Weak   = new WeakReference((object)managedAsset.Request_Strong);
                managedAsset.Request_Strong = (LoadRequest)null;
                managedAsset.Request        = new WeakReference((object)managedAsset.Request2);
                managedAsset.Request2       = (WeakReference)null;
                break;
            }
        }
        if (managedAsset == null)
        {
            for (int index = this.mAssets.Count - 1; index >= 0; --index)
            {
                managedAsset = this.mAssets[index];
                if (managedAsset.HashCode == hashCode && (object)managedAsset.AssetType == (object)type && managedAsset.Name == name)
                {
                    if (managedAsset.Asset.IsAlive)
                    {
                        Object target = managedAsset.Asset.Target;
                        if (Object.op_Inequality(target, (Object)null))
                        {
                            return(target);
                        }
                    }
                    if (managedAsset.HasError)
                    {
                        return((Object)null);
                    }
                    break;
                }
                managedAsset = (AssetManager.ManagedAsset)null;
            }
        }
        if (managedAsset == null)
        {
            managedAsset           = new AssetManager.ManagedAsset();
            managedAsset.Name      = name;
            managedAsset.AssetType = type;
            managedAsset.HashCode  = hashCode;
            this.mAssets.Add(managedAsset);
        }
        AssetList.Item itemByPath1 = AssetManager.AssetList.FindItemByPath(name);
        if (itemByPath1 == null)
        {
            managedAsset.Asset = AssetManager.ObjectRef <Object> .CreateWeakRef(Resources.Load(name, type));
        }
        else
        {
            AssetBundleCache assetBundleCache = this.OpenAssetBundleAndDependencies(itemByPath1, 0, (List <AssetBundleCache>)null, 0.0f);
            if (assetBundleCache != null)
            {
                string withoutExtension = Path.GetFileNameWithoutExtension(name);
                Object @object          = !type.IsSubclassOf(typeof(Component)) ? assetBundleCache.AssetBundle.LoadAsset(withoutExtension, type) : (Object)((GameObject)assetBundleCache.AssetBundle.LoadAsset(withoutExtension)).GetComponent(type);
                managedAsset.Asset = AssetManager.ObjectRef <Object> .CreateStrongRef(@object);

                managedAsset.Asset = AssetManager.ObjectRef <Object> .CreateWeakRef(@object);
            }
            else
            {
                managedAsset.Asset = AssetManager.ObjectRef <Object> .CreateStrongRef((Object)null);
            }
        }
        managedAsset.HasError = Object.op_Equality(managedAsset.Asset.Target, (Object)null);
        if (managedAsset != null)
        {
            return(managedAsset.Asset.Target);
        }
        return((Object)null);
    }
예제 #22
0
 public AssetList.Item FastFindItemByID(uint id)
 {
     AssetList.Item obj = (AssetList.Item)null;
     this.mID2Item.TryGetValue(id, out obj);
     return(obj);
 }
예제 #23
0
    private AssetBundleCache OpenAssetBundle(string assetbundleID, bool persistent = false, bool isDependency = false)
    {
        AssetList.Item itemById = AssetManager.AssetList.FindItemByID(assetbundleID);
        if (itemById == null)
        {
            DebugUtility.LogError("AssetBundle not found: " + assetbundleID);
            return((AssetBundleCache)null);
        }
        for (int index = 0; index < this.mAssetBundles.Count; ++index)
        {
            if (this.mAssetBundles[index].Name == assetbundleID)
            {
                return(this.mAssetBundles[index]);
            }
        }
        if (this.mAssetBundles.Count >= AssetManager.MaxAssetBundles)
        {
            this.UnloadUnusedAssetBundles(true, true);
        }
        string path = AssetDownloader.CachePath + assetbundleID;

        if (!File.Exists(path))
        {
            DebugUtility.LogError("AssetBundle doesn't exist: " + assetbundleID);
            return((AssetBundleCache)null);
        }
        if ((itemById.Flags & AssetBundleFlags.RawData) != (AssetBundleFlags)0)
        {
            DebugUtility.LogError("AssetBundle is RawData: " + assetbundleID);
            return((AssetBundleCache)null);
        }
        AssetBundle ab;

        if ((itemById.Flags & AssetBundleFlags.Compressed) != (AssetBundleFlags)0)
        {
            int    size;
            IntPtr num = NativePlugin.DecompressFile(path, out size);
            if (num == IntPtr.Zero)
            {
                DebugUtility.LogError("Failed to decompress AssetBundle: " + assetbundleID);
                return((AssetBundleCache)null);
            }
            byte[] destination = new byte[size];
            Marshal.Copy(num, destination, 0, size);
            NativePlugin.FreePtr(num);
            ab = AssetBundle.LoadFromMemory(destination);
            if (Object.op_Equality((Object)ab, (Object)null))
            {
                DebugUtility.LogError("Failed to create AssetBundle from memory: " + assetbundleID);
            }
        }
        else
        {
            ab = AssetBundle.LoadFromFile(path);
            if (Object.op_Equality((Object)ab, (Object)null))
            {
                DebugUtility.LogError("Failed to open AssetBundle: " + assetbundleID);
            }
        }
        AssetBundleCache assetBundleCache = new AssetBundleCache(assetbundleID, ab);

        this.mAssetBundles.Add(assetBundleCache);
        assetBundleCache.Persistent = persistent;
        return(assetBundleCache);
    }
예제 #24
0
 public static bool IsAssetInCache(string assetID)
 {
     AssetList.Item itemById = AssetManager.AssetList.FastFindItemByID(assetID);
     return(itemById != null && itemById.Exist);
 }
예제 #25
0
    public static void PrepareAssets(string resourcePath)
    {
        string localizedObjectName1 = AssetManager.GetLocalizedObjectName(resourcePath, false);
        bool   flag = resourcePath != localizedObjectName1;

        if (flag)
        {
            resourcePath = localizedObjectName1;
        }
        if (!AssetManager.mInstanceCreated)
        {
            return;
        }
        AssetList.Item itemByPath1 = AssetManager.mAssetListRef.FindItemByPath(resourcePath);
        if (itemByPath1 == null)
        {
            return;
        }
        if (!itemByPath1.Exist)
        {
            AssetDownloader.Add(itemByPath1.IDStr);
        }
        for (int index = 0; index < itemByPath1.Dependencies.Length; ++index)
        {
            if (!File.Exists(AssetDownloader.CachePath + itemByPath1.Dependencies[index].IDStr))
            {
                AssetDownloader.Add(itemByPath1.Dependencies[index].IDStr);
            }
        }
        for (int index = 0; index < itemByPath1.AdditionalDependencies.Length; ++index)
        {
            string path = AssetDownloader.CachePath + itemByPath1.AdditionalDependencies[index].IDStr;
            if (!flag)
            {
                if (!File.Exists(path))
                {
                    AssetDownloader.Add(itemByPath1.AdditionalDependencies[index].IDStr);
                }
            }
            else
            {
                string localizedObjectName2 = AssetManager.GetLocalizedObjectName(itemByPath1.AdditionalDependencies[index].Path, false);
                if (localizedObjectName2 == itemByPath1.AdditionalDependencies[index].Path)
                {
                    if (!File.Exists(path))
                    {
                        AssetDownloader.Add(itemByPath1.AdditionalDependencies[index].IDStr);
                    }
                }
                else
                {
                    AssetList.Item itemByPath2 = AssetManager.mAssetListRef.FindItemByPath(localizedObjectName2);
                    if (itemByPath2 == null)
                    {
                        if (!File.Exists(path))
                        {
                            AssetDownloader.Add(itemByPath1.AdditionalDependencies[index].IDStr);
                        }
                    }
                    else if (!File.Exists(AssetDownloader.CachePath + itemByPath2.IDStr))
                    {
                        AssetDownloader.Add(itemByPath2.IDStr);
                    }
                }
            }
        }
        for (int index = 0; index < itemByPath1.AdditionalStreamingAssets.Length; ++index)
        {
            string path = AssetDownloader.CachePath + itemByPath1.AdditionalStreamingAssets[index].IDStr;
            string localizedObjectName2 = AssetManager.GetLocalizedObjectName(itemByPath1.AdditionalStreamingAssets[index].Path, false);
            if (localizedObjectName2 == itemByPath1.AdditionalStreamingAssets[index].Path)
            {
                if (!File.Exists(path))
                {
                    AssetDownloader.Add(itemByPath1.AdditionalStreamingAssets[index].IDStr);
                }
            }
            else
            {
                DebugUtility.LogWarning("Checking localized streaming dependency: " + localizedObjectName2);
                AssetList.Item itemByPath2 = AssetManager.mAssetListRef.FindItemByPath(localizedObjectName2);
                if (itemByPath2 == null)
                {
                    if (!File.Exists(path))
                    {
                        AssetDownloader.Add(itemByPath1.AdditionalStreamingAssets[index].IDStr);
                    }
                }
                else if (!File.Exists(AssetDownloader.CachePath + itemByPath2.IDStr))
                {
                    DebugUtility.LogWarning("Downloading localized streaming dependency: " + localizedObjectName2);
                    AssetDownloader.Add(itemByPath2.IDStr);
                }
            }
        }
    }
예제 #26
0
    private void UnzipThread2()
    {
        AssetDownloader.UnzipThread2Arg mUnzipThreadArg = this.mUnzipThreadArg;
        if (mUnzipThreadArg == null)
        {
            return;
        }
        bool flag = false;

        while (!flag)
        {
            this.mMutex.WaitOne();
            AssetDownloader.UnzipJob[] array = this.mUnzipJobs.ToArray();
            this.mUnzipJobs.Clear();
            bool completed     = mUnzipThreadArg.completed;
            bool abort         = mUnzipThreadArg.abort;
            bool mShuttingDown = this.mShuttingDown;
            this.mMutex.ReleaseMutex();
            if (mShuttingDown || abort)
            {
                return;
            }
            if (array == null || array.Length <= 0)
            {
                if (completed)
                {
                    return;
                }
                this.mUnzipSignal.WaitOne();
            }
            else
            {
                AssetDownloader.UnzipJob unzipJob = (AssetDownloader.UnzipJob)null;
                for (int index1 = 0; index1 < array.Length; ++index1)
                {
                    unzipJob = array[index1];
                    if (unzipJob.State == AssetDownloader.UnzipJobState.Error)
                    {
                        flag = true;
                        break;
                    }
                    try
                    {
                        if (array != null)
                        {
                            AssetDownloader.UnZipFileSize = (long)((IEnumerable <AssetDownloader.UnzipJob>)array).Sum <AssetDownloader.UnzipJob>((Func <AssetDownloader.UnzipJob, int>)(arg => arg.Size));
                        }
                    }
                    catch (Exception ex)
                    {
                        Debug.Log((object)ex.ToString());
                    }
                    File.WriteAllBytes(AssetDownloader.CachePath + unzipJob.nodes[0].ID, unzipJob.Bytes);
                    if ((unzipJob.nodes[0].Item.Flags & AssetBundleFlags.IsCombined) != (AssetBundleFlags)0)
                    {
                        int    size = 0;
                        string path = AssetDownloader.CachePath + unzipJob.nodes[0].ID;
                        if ((unzipJob.nodes[0].Item.Flags & AssetBundleFlags.Compressed) != (AssetBundleFlags)0)
                        {
                            IntPtr num1 = NativePlugin.DecompressFile(path, out size);
                            if (num1 == IntPtr.Zero)
                            {
                                throw new Exception("Failed to decompress file [" + path + "]");
                            }
                            byte[] numArray = new byte[size];
                            Marshal.Copy(num1, numArray, 0, size);
                            using (BinaryReader binaryReader = new BinaryReader((Stream) new MemoryStream(numArray)))
                            {
                                int num2 = binaryReader.ReadInt32();
                                for (int index2 = 0; index2 < num2; ++index2)
                                {
                                    string lower = binaryReader.ReadInt32().ToString("X8").ToLower();
                                    int    count = binaryReader.ReadInt32();
                                    byte[] bytes = binaryReader.ReadBytes(count);
                                    File.WriteAllBytes(AssetDownloader.CachePath + lower, bytes);
                                    AssetList.Item itemById = mUnzipThreadArg.assetlist.FindItemByID(lower);
                                    itemById.Exist = true;
                                    AssetDownloader.mExistFile.Add(new AssetDownloader.ExistAssetList(itemById.ID, mUnzipThreadArg.assetlist.SearchItemIdx(itemById.ID)));
                                }
                            }
                            NativePlugin.FreePtr(num1);
                            File.Delete(path + ".tmp");
                        }
                        else
                        {
                            using (BinaryReader binaryReader = new BinaryReader((Stream)File.Open(path, FileMode.Open)))
                            {
                                int num = binaryReader.ReadInt32();
                                for (int index2 = 0; index2 < num; ++index2)
                                {
                                    string lower = binaryReader.ReadInt32().ToString("X8").ToLower();
                                    int    count = binaryReader.ReadInt32();
                                    byte[] bytes = binaryReader.ReadBytes(count);
                                    File.WriteAllBytes(AssetDownloader.CachePath + lower, bytes);
                                    AssetList.Item itemById = mUnzipThreadArg.assetlist.FindItemByID(lower);
                                    itemById.Exist = true;
                                    AssetDownloader.mExistFile.Add(new AssetDownloader.ExistAssetList(itemById.ID, mUnzipThreadArg.assetlist.SearchItemIdx(itemById.ID)));
                                }
                            }
                        }
                    }
                    using (List <AssetDownloader.UnzipJob.Node> .Enumerator enumerator = unzipJob.nodes.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            AssetDownloader.UnzipJob.Node current = enumerator.Current;
                            if (!File.Exists(unzipJob.Dest + current.ID))
                            {
                                flag = true;
                                break;
                            }
                        }
                    }
                    if (!flag)
                    {
                        using (List <AssetDownloader.UnzipJob.Node> .Enumerator enumerator = unzipJob.nodes.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                AssetDownloader.UnzipJob.Node current = enumerator.Current;
                                current.Item.Exist = true;
                                AssetDownloader.mExistFile.Add(new AssetDownloader.ExistAssetList(current.Item.ID, mUnzipThreadArg.assetlist.SearchItemIdx(current.Item.ID)));
                            }
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                try
                {
                    AssetDownloader.UnZipFileSize = 0L;
                    if (this.mDownloadObserver != null)
                    {
                        this.mDownloadObserver.IsWait = false;
                    }
                }
                catch (Exception ex)
                {
                    Debug.Log((object)ex.ToString());
                }
                if (flag && unzipJob != null)
                {
                    for (int index = 0; index < unzipJob.nodes.Count; ++index)
                    {
                        string path1 = unzipJob.Dest + unzipJob.nodes[index].ID;
                        if (File.Exists(path1))
                        {
                            File.Delete(path1);
                        }
                        string path2 = unzipJob.Dest + unzipJob.nodes[index].ID + ".meta";
                        if (!File.Exists(path2))
                        {
                            File.Delete(path2);
                        }
                        unzipJob.nodes[index].Item.Exist = false;
                    }
                }
            }
        }
        this.mMutex.WaitOne();
        mUnzipThreadArg.error = true;
        this.mMutex.ReleaseMutex();
    }
예제 #27
0
 public static void ReadAssetListProc(string path, ref List<AssetList.Item> ItemList)
 {
     using (BinaryReader binaryReader = new BinaryReader(File.Open(path, FileMode.Open)))
     {
         var mRevision = binaryReader.ReadInt32();
         int num = binaryReader.ReadInt32();
         AssetList.Item[] array = new AssetList.Item[num];
         ItemList = null;
         ItemList = new List<AssetList.Item>(array);
         for (int i = 0; i < num; i++)
         {
             if (ItemList[i] == null)
             {
                 ItemList[i] = new AssetList.Item();
             }
             AssetList.Item item = ItemList[i];
             item.ID = binaryReader.ReadUInt32();
             item.IDStr = item.ID.ToString("X8").ToLower();
             item.Size = binaryReader.ReadInt32();
             item.CompressedSize = binaryReader.ReadInt32();
             item.Path = binaryReader.ReadString();
             item.PathHash = binaryReader.ReadInt32();
             //this.SetPath(item, item.Path);
             item.Hash = binaryReader.ReadUInt32();
             item.Flags = (AssetBundleFlags)binaryReader.ReadInt32();
             int num2 = binaryReader.ReadInt32();
             if (num2 != 0)
             {
                 if (num2 < 0)
                 {
                     throw new Exception(string.Concat(new object[]
                     {
                     "Dependencies Paramater is Broken. cnt:",
                     num,
                     "/ hash:",
                     item.IDStr
                     }));
                 }
                 item.Dependencies = new AssetList.Item[num2];
                 for (int j = 0; j < item.Dependencies.Length; j++)
                 {
                     int num3 = binaryReader.ReadInt32();
                     //if (this.mItems.get_Item(num3) == null)
                     {
                         //    ItemList.set_Item(num3, new AssetList.Item());
                     }
                     item.Dependencies[j] = ItemList[num3];
                 }
             }
             else
             {
                 item.Dependencies = new AssetList.Item[0];
             }
             num2 = binaryReader.ReadInt32();
             if (num2 != 0)
             {
                 if (num2 < 0)
                 {
                     throw new Exception(string.Concat(new object[]
                     {
                     "AdditionalDependencies Paramater is Broken. cnt:",
                     num,
                     "/ hash:",
                     item.IDStr
                     }));
                 }
                 item.AdditionalDependencies = new AssetList.Item[num2];
                 for (int k = 0; k < item.AdditionalDependencies.Length; k++)
                 {
                     int num3 = binaryReader.ReadInt32();
                     //if (this.mItems.get_Item(num3) == null)
                     {
                         //    ItemList.set_Item(num3, new AssetList.Item());
                     }
                     //item.AdditionalDependencies[k] = ItemList.get_Item(num3);
                 }
             }
             else
             {
                 item.AdditionalDependencies = new AssetList.Item[0];
             }
             num2 = binaryReader.ReadInt32();
             if (num2 != 0)
             {
                 if (num2 < 0)
                 {
                     throw new Exception(string.Concat(new object[]
                     {
                     "AdditionalStreamingAssets Paramater is Broken. cnt:",
                     num,
                     "/ hash:",
                     item.IDStr
                     }));
                 }
                 item.AdditionalStreamingAssets = new AssetList.Item[num2];
                 for (int l = 0; l < item.AdditionalStreamingAssets.Length; l++)
                 {
                     int num3 = binaryReader.ReadInt32();
                     //if (this.mItems.get_Item(num3) == null)
                     {
                         //    ItemList.set_Item(num3, new AssetList.Item());
                     }
                     item.AdditionalStreamingAssets[l] = ItemList[num3];
                 }
             }
             else
             {
                 item.AdditionalStreamingAssets = new AssetList.Item[0];
             }
             //if (!this.mID2Item.ContainsKey(item.ID))
             {
                 //    this.mID2Item.Add(item.ID, item);
             }
         }
     }
 }
예제 #28
0
    private void AddRequiredAssets(string cacheDir, AssetList.Item[] assets)
    {
        AssetList assetList;
        bool      flag1;

        if (AssetManager.Format == AssetManager.AssetFormats.Text)
        {
            assetList = AssetManager.TxtAssetList;
            flag1     = true;
        }
        else
        {
            assetList = AssetManager.AssetList;
            flag1     = false;
        }
        AssetList.Item obj        = (AssetList.Item)null;
        List <string>  stringList = new List <string>();

        for (int index = 0; index < assets.Length; ++index)
        {
            AssetList.Item asset = assets[index];
            if ((asset.Flags & AssetBundleFlags.Required) != (AssetBundleFlags)0)
            {
                bool flag2 = asset.Size > 0 && !asset.Exist && asset.IsMatchLanguageItem();
                if (GameUtility.Config_Language == "english" || flag1)
                {
                    if (flag2)
                    {
                        stringList.Add(asset.IDStr);
                    }
                }
                else
                {
                    string         localizedObjectName = AssetManager.GetLocalizedObjectName(asset.Path, false);
                    AssetList.Item itemByPath          = assetList.FindItemByPath(localizedObjectName);
                    if (localizedObjectName == asset.Path || itemByPath == null)
                    {
                        if (flag2)
                        {
                            stringList.Add(asset.IDStr);
                        }
                    }
                    else
                    {
                        this.DownloadLocalizedAssetAndDependencies(itemByPath, assetList);
                    }
                }
            }
            else if (asset.Path == "reqAssetPack")
            {
                obj = asset;
            }
        }
        if (obj == null || stringList.Count < 30 || GameUtility.Config_Language != "english")
        {
            using (List <string> .Enumerator enumerator = stringList.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    AssetDownloader.Add(enumerator.Current);
                }
            }
        }
        else
        {
            AssetDownloader.Add(obj.IDStr);
        }
        stringList.Clear();
    }