Esempio n. 1
0
 public Inventory(GridClient client, InventoryManager manager, UUID owner)
 {
     Client = client;
     //Manager = manager;
     _Owner = owner;
     if (owner.IsZero())
     {
         Logger.Log("Inventory owned by nobody!", Helpers.LogLevel.Warning, Client);
     }
     Items = new Dictionary <UUID, InventoryNode>();
 }
Esempio n. 2
0
        /// <summary>
        /// Request a texture asset from the simulator using the <see cref="TexturePipeline"/> system to
        /// manage the requests and re-assemble the image from the packets received from the simulator
        /// </summary>
        /// <param name="textureID">The <see cref="UUID"/> of the texture asset to download</param>
        /// <param name="imageType">The <see cref="ImageType"/> of the texture asset.
        /// Use <see cref="ImageType.Normal"/> for most textures, or <see cref="ImageType.Baked"/> for baked layer texture assets</param>
        /// <param name="priority">A float indicating the requested priority for the transfer. Higher priority values tell the simulator
        /// to prioritize the request before lower valued requests. An image already being transferred using the <see cref="TexturePipeline"/> can have
        /// its priority changed by resending the request with the new priority value</param>
        /// <param name="discardLevel">Number of quality layers to discard.
        /// This controls the end marker of the data sent</param>
        /// <param name="packetStart">The packet number to begin the request at. A value of 0 begins the request
        /// from the start of the asset texture</param>
        /// <param name="callback">The <see cref="TextureDownloadCallback"/> callback to fire when the image is retrieved. The callback
        /// will contain the result of the request and the texture asset data</param>
        /// <param name="progressive">If true, the callback will be fired for each chunk of the downloaded image.
        /// The callback asset parameter will contain all previously received chunks of the texture asset starting
        /// from the beginning of the request</param>
        public void RequestTexture(UUID textureID, ImageType imageType, float priority, int discardLevel, uint packetStart, TextureDownloadCallback callback, bool progressive)
        {
            if (textureID.IsZero())
            {
                return;
            }

            if (callback != null)
            {
                if (_Client.Assets.Cache.HasAsset(textureID))
                {
                    ImageDownload image = new ImageDownload();
                    image.ID          = textureID;
                    image.AssetData   = _Client.Assets.Cache.GetCachedAssetBytes(textureID);
                    image.Size        = image.AssetData.Length;
                    image.Transferred = image.AssetData.Length;
                    image.ImageType   = imageType;
                    image.AssetType   = AssetType.Texture;
                    image.Success     = true;

                    callback(TextureRequestState.Finished, new AssetTexture(image.ID, image.AssetData));

                    _Client.Assets.FireImageProgressEvent(image.ID, image.Transferred, image.Size);
                }
                else
                {
                    lock (_Transfers)
                    {
                        TaskInfo request;

                        if (_Transfers.TryGetValue(textureID, out request))
                        {
                            request.Callbacks.Add(callback);
                        }
                        else
                        {
                            request                = new TaskInfo();
                            request.State          = TextureRequestState.Pending;
                            request.RequestID      = textureID;
                            request.ReportProgress = progressive;
                            request.RequestSlot    = -1;
                            request.Type           = imageType;

                            request.Callbacks = new List <TextureDownloadCallback>();
                            request.Callbacks.Add(callback);

                            ImageDownload downloadParams = new ImageDownload();
                            downloadParams.ID           = textureID;
                            downloadParams.Priority     = priority;
                            downloadParams.ImageType    = imageType;
                            downloadParams.DiscardLevel = discardLevel;

                            request.Transfer = downloadParams;
#if DEBUG_TIMING
                            request.StartTime = DateTime.UtcNow;
#endif
                            _Transfers.Add(textureID, request);
                        }
                    }
                }
            }
        }