當前位置: 首頁>>代碼示例>>C#>>正文


C# Scene.GiveInventoryItem方法代碼示例

本文整理匯總了C#中OpenSim.Region.Framework.Scenes.Scene.GiveInventoryItem方法的典型用法代碼示例。如果您正苦於以下問題:C# Scene.GiveInventoryItem方法的具體用法?C# Scene.GiveInventoryItem怎麽用?C# Scene.GiveInventoryItem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OpenSim.Region.Framework.Scenes.Scene的用法示例。


在下文中一共展示了Scene.GiveInventoryItem方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: UserInventoryOffer

//////////////////////////////////////////////// 
// User-to-user inventory offers

        private void UserInventoryOffer(IClientAPI client, Scene scene, GridInstantMessage im)
        {
            InventoryFolderBase folder = null;
            InventoryItemBase item = null;

            UUID toAgentID = new UUID(im.toAgentID);

            IMuteListModule m_muteListModule = scene.RequestModuleInterface<IMuteListModule>();
            if (m_muteListModule != null)
            {
                if (m_muteListModule.IsMuted(client.AgentId, toAgentID))
                {
                    client.SendAgentAlertMessage("Inventory offer was automatically declined.", false);
                    return; // recipient has sender muted
                }
            }

            // Unpack the binary bucket
            AssetType assetType = (AssetType)im.binaryBucket[0];
            UUID destID = new UUID(im.binaryBucket, 1);
            UUID copyID;
            bool isFolder = (assetType == AssetType.Folder);

            ScenePresence recipient = scene.GetScenePresence(toAgentID);

            if (recipient != null && recipient.IsBot)
            {
                client.SendAgentAlertMessage("Can't give inventory to bots.", false);
                return;//can't give objects to bots
            }

            if (assetType == AssetType.Folder)
            {
                folder = scene.GiveInventoryFolder(toAgentID, client.AgentId, destID, UUID.Zero);
                if (folder == null)
                {
                    client.SendAgentAlertMessage("Can't find folder to give. Nothing given.", false);
                    return;
                }
                copyID = folder.ID;
            }
            else
            {
                item = scene.GiveInventoryItem(toAgentID, client.AgentId, destID);
                if (item == null)
                {
                    client.SendAgentAlertMessage("Can't find item to give. Nothing given.", false);
                    return;
                }
                copyID = item.ID;
            }
//            m_log.InfoFormat("[AGENT INVENTORY]: Offering {0} {1} to user {2} inventory as {3}", isFolder ? "folder" : "item", destID, toAgentID, copyID);

            // Update the asset type and destination ID into the outgoing IM.
            im.binaryBucket = new byte[17];
            im.binaryBucket[0] = (byte)assetType;
            Array.Copy(copyID.GetBytes(), 0, im.binaryBucket, 1, 16);
            // Also stuff the destination ID into the session ID field for retrieval in accept/decline
            im.imSessionID = copyID.Guid;

            CachedUserInfo recipientInfo = scene.CommsManager.UserService.GetUserDetails(toAgentID);
            if (recipientInfo != null && recipient != null)
            {
                if ((!isFolder) && (item != null))
                {
                    // item offer?
                    recipient.ControllingClient.SendInventoryItemCreateUpdate(item, 0);
                }

                if (isFolder && (folder != null))
                {
                    // folder offer?
                    folder = recipientInfo.GetFolder(folder.ID);
                    if (folder != null)
                    {
                        recipient.ControllingClient.SendBulkUpdateInventory(folder);
                        recipientInfo.SendInventoryDecendents(recipient.ControllingClient, folder.ID, false, true);
                    }
                }
            }

            // Send the IM to the recipient. The item is already in their inventory, so
            // it will not be lost if they are offline. Transaction ID is the item ID.
            // We get that same ID back on the reply so we know what to act on.
            RelayInventoryOfferIM(scene, recipient, im);
        }
開發者ID:emperorstarfinder,項目名稱:halcyon,代碼行數:89,代碼來源:InventoryTransferModule.cs


注:本文中的OpenSim.Region.Framework.Scenes.Scene.GiveInventoryItem方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。