OpenMetaverse.AppearanceManager.DownloadTextures C# (CSharp) Метод

DownloadTextures() приватный Метод

Blocking method to download all of the textures needed for baking the given bake layers
No return value is given because the baking will happen whether or not all textures are successfully downloaded
private DownloadTextures ( List bakeLayers ) : void
bakeLayers List A list of layers that need baking
Результат void
        private void DownloadTextures(List<BakeType> bakeLayers)
        {
            List<UUID> textureIDs = new List<UUID>();

            for (int i = 0; i < bakeLayers.Count; i++)
            {
                List<UUID> layerTextureIDs = GetTextureDownloadList(bakeLayers[i]);

                for (int j = 0; j < layerTextureIDs.Count; j++)
                {
                    UUID uuid = layerTextureIDs[j];
                    if (!textureIDs.Contains(uuid))
                        textureIDs.Add(uuid);
                }
            }

            Logger.DebugLog("Downloading " + textureIDs.Count + " textures for baking");

            Parallel.ForEach<UUID>(MAX_CONCURRENT_DOWNLOADS, textureIDs,
                delegate(UUID textureID)
                {
                    AutoResetEvent downloadEvent = new AutoResetEvent(false);

                    Client.Assets.RequestImage(textureID,
                        delegate(TextureRequestState state, AssetTexture assetTexture)
                        {
                            if (state == TextureRequestState.Finished)
                            {
                                assetTexture.Decode();

                                for (int i = 0; i < Textures.Length; i++)
                                {
                                    if (Textures[i].TextureID == textureID)
                                        Textures[i].Texture = assetTexture;
                                }
                            }
                            else
                            {
                                Logger.Log("Texture " + textureID + " failed to download, one or more bakes will be incomplete",
                                    Helpers.LogLevel.Warning);
                            }

                            downloadEvent.Set();
                        }
                    );

                    downloadEvent.WaitOne(TEXTURE_TIMEOUT, false);
                }
            );
        }