当前位置: 首页>>代码示例>>C#>>正文


C# AvatarAppearance.GetAttachments方法代码示例

本文整理汇总了C#中AvatarAppearance.GetAttachments方法的典型用法代码示例。如果您正苦于以下问题:C# AvatarAppearance.GetAttachments方法的具体用法?C# AvatarAppearance.GetAttachments怎么用?C# AvatarAppearance.GetAttachments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AvatarAppearance的用法示例。


在下文中一共展示了AvatarAppearance.GetAttachments方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AvatarData

        public AvatarData(AvatarAppearance appearance)
        {
            AvatarType = 1; // SL avatars
            Data = new Dictionary<string, string>();

            Data["Serial"] = appearance.Serial.ToString();
            // Wearables
            Data["AvatarHeight"] = appearance.AvatarHeight.ToString();

            Data["Textures"] = OSDParser.SerializeJsonString(appearance.Texture.GetOSD());

            for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++)
            {
                for (int j = 0; j < appearance.Wearables[i].Count; j++)
                {
                    string fieldName = String.Format("Wearable {0}:{1}", i, j);
                    Data[fieldName] = String.Format("{0}:{1}",
                            appearance.Wearables[i][j].ItemID.ToString(),
                            appearance.Wearables[i][j].AssetID.ToString());
                }
            }

            // Visual Params
            string[] vps = new string[AvatarAppearance.VISUALPARAM_COUNT];
            byte[] binary = appearance.VisualParams;

            for (int i = 0; i < AvatarAppearance.VISUALPARAM_COUNT; i++)
            {
                vps[i] = binary[i].ToString();
            }

            Data["VisualParams"] = String.Join(",", vps);

            // Attachments
            List<AvatarAttachment> attachments = appearance.GetAttachments();
            foreach (AvatarAttachment attach in attachments)
            {
                Data["_ap_" + attach.AttachPoint] = attach.ItemID.ToString();
            }
        }
开发者ID:rknop,项目名称:Aurora-Sim,代码行数:40,代码来源:IAvatarService.cs

示例2: WearFolder

        public AvatarAppearance WearFolder(AvatarAppearance avappearance, UUID user, UUID folderOwnerID)
        {
            InventoryFolderBase Folder2Wear = m_InventoryService.GetFolderByOwnerAndName(folderOwnerID,
                                                                                         m_forceUserToWearFolderName);
            if (Folder2Wear != null)
            {
                List<InventoryItemBase> itemsInFolder = m_InventoryService.GetFolderItems(UUID.Zero, Folder2Wear.ID);

                InventoryFolderBase appearanceFolder = m_InventoryService.GetFolderForType(user, InventoryType.Wearable,
                                                                                           AssetType.Clothing);

                InventoryFolderBase folderForAppearance = new InventoryFolderBase(UUID.Random(), "GridWear", user, -1,
                                                                                  appearanceFolder.ID, 1);
                List<InventoryFolderBase> userFolders = m_InventoryService.GetFolderFolders(user, appearanceFolder.ID);
                bool alreadyThere = false;
                List<UUID> items2RemoveFromAppearence = new List<UUID>();
                List<UUID> toDelete = new List<UUID>();
                foreach (InventoryFolderBase folder in userFolders)
                {
                    if (folder.Name == folderForAppearance.Name)
                    {
                        List<InventoryItemBase> itemsInCurrentFolder = m_InventoryService.GetFolderItems(UUID.Zero,
                                                                                                         folder.ID);
                        foreach (InventoryItemBase itemBase in itemsInCurrentFolder)
                        {
                            items2RemoveFromAppearence.Add(itemBase.AssetID);
                            items2RemoveFromAppearence.Add(itemBase.ID);
                            toDelete.Add(itemBase.ID);
                        }
                        folderForAppearance = folder;
                        alreadyThere = true;
                        m_InventoryService.DeleteItems(user, toDelete);
                        break;
                    }
                }

                if (!alreadyThere)
                    m_InventoryService.AddFolder(folderForAppearance);
                else
                {
                    // we have to remove all the old items if they are currently wearing them
                    for (int i = 0; i < avappearance.Wearables.Length; i++)
                    {
                        AvatarWearable wearable = avappearance.Wearables[i];
                        for (int ii = 0; ii < wearable.Count; ii++)
                        {
                            if (items2RemoveFromAppearence.Contains(wearable[ii].ItemID))
                            {
                                avappearance.Wearables[i] = AvatarWearable.DefaultWearables[i];
                                break;
                            }
                        }
                    }

                    List<AvatarAttachment> attachments = avappearance.GetAttachments();
                    foreach (AvatarAttachment attachment in attachments)
                    {
                        if ((items2RemoveFromAppearence.Contains(attachment.AssetID)) ||
                            (items2RemoveFromAppearence.Contains(attachment.ItemID)))
                        {
                            avappearance.DetachAttachment(attachment.ItemID);
                        }
                    }
                }

                // ok, now we have a empty folder, lets add the items
                foreach (InventoryItemBase itemBase in itemsInFolder)
                {
                    InventoryItemBase newcopy = m_InventoryService.InnerGiveInventoryItem(user, folderOwnerID, itemBase,
                                                                                          folderForAppearance.ID,
                                                                                          true, true);

                    if (newcopy.InvType == (int) InventoryType.Object)
                    {
                        byte[] attobj = m_AssetService.GetData(newcopy.AssetID.ToString());

                        if (attobj != null)
                        {
                            string xmlData = Utils.BytesToString(attobj);
                            XmlDocument doc = new XmlDocument();
                            try
                            {
                                doc.LoadXml(xmlData);
                            }
                            catch
                            {
                                continue;
                            }

                            if (doc.FirstChild.OuterXml.StartsWith("<groups>") ||
                                (doc.FirstChild.NextSibling != null &&
                                 doc.FirstChild.NextSibling.OuterXml.StartsWith("<groups>")))
                                continue;

                            string xml = "";
                            if ((doc.FirstChild.NodeType == XmlNodeType.XmlDeclaration) &&
                                (doc.FirstChild.NextSibling != null))
                                xml = doc.FirstChild.NextSibling.OuterXml;
                            else
                                xml = doc.FirstChild.OuterXml;
//.........这里部分代码省略.........
开发者ID:keverw,项目名称:Aurora-Sim,代码行数:101,代码来源:LLLoginService.cs

示例3: MakeXMLFormat

        private string MakeXMLFormat(AvatarAppearance appearance, string FolderNameToSaveInto)
        {
            string ArchiveXML = "";

            ArchiveXML += "<avatar>\n";
            ArchiveXML += "<" + appearance.AvatarHeight + ">\n";
            ArchiveXML += "<" + appearance.BodyAsset + ">\n";
            ArchiveXML += "<" + appearance.BodyItem + ">\n";
            ArchiveXML += "<" + appearance.EyesAsset + ">\n";
            ArchiveXML += "<" + appearance.EyesItem + ">\n";
            ArchiveXML += "<" + appearance.GlovesAsset + ">\n";
            ArchiveXML += "<" + appearance.GlovesItem + ">\n";
            ArchiveXML += "<" + appearance.HairAsset + ">\n";
            ArchiveXML += "<" + appearance.HairItem + ">\n";
            ArchiveXML += "<" + appearance.HipOffset + ">\n";
            ArchiveXML += "<" + appearance.JacketAsset + ">\n";
            ArchiveXML += "<" + appearance.JacketItem + ">\n";
            ArchiveXML += "<" + appearance.Owner + ">\n";
            ArchiveXML += "<" + appearance.PantsAsset + ">\n";
            ArchiveXML += "<" + appearance.PantsItem + ">\n";
            ArchiveXML += "<" + appearance.Serial + ">\n";
            ArchiveXML += "<" + appearance.ShirtAsset + ">\n";
            ArchiveXML += "<" + appearance.ShirtItem + ">\n";
            ArchiveXML += "<" + appearance.ShoesAsset + ">\n";
            ArchiveXML += "<" + appearance.ShoesItem + ">\n";
            ArchiveXML += "<" + appearance.SkinAsset + ">\n";
            ArchiveXML += "<" + appearance.SkinItem + ">\n";
            ArchiveXML += "<" + appearance.SkirtAsset + ">\n";
            ArchiveXML += "<" + appearance.SkirtItem + ">\n";
            ArchiveXML += "<" + appearance.SocksAsset + ">\n";
            ArchiveXML += "<" + appearance.SocksItem + ">\n";
            ArchiveXML += "<" + appearance.UnderPantsAsset + ">\n";
            ArchiveXML += "<" + appearance.UnderPantsItem + ">\n";
            ArchiveXML += "<" + appearance.UnderShirtAsset + ">\n";
            ArchiveXML += "<" + appearance.UnderShirtItem + ">\n";
            ArchiveXML += "<" + FolderNameToSaveInto + ">\n";
            ArchiveXML += "<VisualParams>\n";
            foreach (Byte Byte in appearance.VisualParams)
            {
                ArchiveXML += "</VP" + Convert.ToString(Byte) + ">\n";
            }
            ArchiveXML += "</VisualParams>\n";
            ArchiveXML += "<wearables>\n";
            foreach (AvatarWearable wear in appearance.Wearables)
            {
                ArchiveXML += "<WA" + wear.AssetID + ">\n";
                ArchiveXML += "<WI" + wear.ItemID + ">\n";
            }
            ArchiveXML += "</wearables>\n";
            ArchiveXML += "<TEXTURE" + appearance.Texture.ToString().Replace("\n", "") + "TEXTURE>\n";
            ArchiveXML += "</avatar>";
            Hashtable attachments = appearance.GetAttachments();
            ArchiveXML += "<attachments>\n";
            if (attachments != null)
            {
                foreach (DictionaryEntry element in attachments)
                {
                    Hashtable attachInfo = (Hashtable)element.Value;

                    InventoryItemBase IB = new InventoryItemBase(UUID.Parse(attachInfo["item"].ToString()));
                    IB = InventoryService.GetItem(IB);
                    ArchiveXML += "<AI" + attachInfo["item"] + ">\n";
                    ArchiveXML += "<AA" + IB.AssetID + ">\n";
                    ArchiveXML += "<AP" + (int)element.Key + ">\n";
                }
            }
            ArchiveXML += "</attachments>";
            return ArchiveXML;
        }
开发者ID:shangcheng,项目名称:Aurora,代码行数:69,代码来源:LLLoginService.cs

示例4: CopyWearablesAndAttachments

        private AvatarAppearance CopyWearablesAndAttachments(UUID destination, UUID source,
            AvatarAppearance avatarAppearance,
            InventoryFolderBase destinationFolder, UUID agentid,
            OSDMap itemsMap,
            out List<InventoryItemBase> items)
        {
            if (destinationFolder == null)
                throw new Exception("Cannot locate folder(s)");
            items = new List<InventoryItemBase>();

            List<InventoryItemBase> litems = new List<InventoryItemBase>();
            foreach (KeyValuePair<string, OSD> kvp in itemsMap)
            {
                InventoryItemBase item = new InventoryItemBase();
                item.FromOSD((OSDMap)kvp.Value);
                MainConsole.Instance.Info("[AvatarArchive]: Loading item " + item.ID.ToString());
                litems.Add(item);
            }

            // Wearables
            AvatarWearable[] wearables = avatarAppearance.Wearables;

            for (int i = 0; i < wearables.Length; i++)
            {
                AvatarWearable wearable = wearables[i];
                for (int ii = 0; ii < wearable.Count; ii++)
                {
                    if (wearable[ii].ItemID != UUID.Zero)
                    {
                        // Get inventory item and copy it
                        InventoryItemBase item = InventoryService.GetItem(UUID.Zero, wearable[ii].ItemID);

                        if (item == null)
                        {
                            //Attempt to get from the map if it doesn't already exist on the grid
                            item = litems.First((itm) => itm.ID == wearable[ii].ItemID);
                        }
                        if (item != null)
                        {
                            InventoryItemBase destinationItem = InventoryService.InnerGiveInventoryItem(destination,
                                                                                                        destination,
                                                                                                        item,
                                                                                                        destinationFolder
                                                                                                            .ID,
                                                                                                        false, false);
                            items.Add(destinationItem);
                            MainConsole.Instance.DebugFormat("[RADMIN]: Added item {0} to folder {1}",
                                                             destinationItem.ID, destinationFolder.ID);

                            // Wear item
                            AvatarWearable newWearable = new AvatarWearable();
                            newWearable.Wear(destinationItem.ID, destinationItem.AssetID);
                            avatarAppearance.SetWearable(i, newWearable);
                        }
                        else
                        {
                            MainConsole.Instance.WarnFormat("[RADMIN]: Error transferring {0} to folder {1}",
                                                            wearable[ii].ItemID, destinationFolder.ID);
                        }
                    }
                }
            }

            // Attachments
            List<AvatarAttachment> attachments = avatarAppearance.GetAttachments();

            foreach (AvatarAttachment attachment in attachments)
            {
                int attachpoint = attachment.AttachPoint;
                UUID itemID = attachment.ItemID;

                if (itemID != UUID.Zero)
                {
                    // Get inventory item and copy it
                    InventoryItemBase item = InventoryService.GetItem(UUID.Zero, itemID);

                    if (item != null)
                    {
                        InventoryItemBase destinationItem = InventoryService.InnerGiveInventoryItem(destination,
                                                                                                    destination, item,
                                                                                                    destinationFolder.ID,
                                                                                                    false, false);
                        items.Add(destinationItem);
                        MainConsole.Instance.DebugFormat("[RADMIN]: Added item {0} to folder {1}", destinationItem.ID,
                                                         destinationFolder.ID);

                        // Attach item
                        avatarAppearance.SetAttachment(attachpoint, destinationItem.ID, destinationItem.AssetID);
                        MainConsole.Instance.DebugFormat("[RADMIN]: Attached {0}", destinationItem.ID);
                    }
                    else
                    {
                        MainConsole.Instance.WarnFormat("[RADMIN]: Error transferring {0} to folder {1}", itemID,
                                                        destinationFolder.ID);
                    }
                }
            }
            return avatarAppearance;
        }
开发者ID:KSLcom,项目名称:Aurora-Sim,代码行数:99,代码来源:AppearanceArchiver.cs

示例5: CopyWearablesAndAttachments

        private AvatarAppearance CopyWearablesAndAttachments(UUID destination, UUID source,
                                                             AvatarAppearance avatarAppearance,
                                                             InventoryFolderBase destinationFolder, UUID agentid,
                                                             out List<InventoryItemBase> items)
        {
            if (destinationFolder == null)
                throw new Exception("Cannot locate folder(s)");
            items = new List<InventoryItemBase>();

            // Wearables
            AvatarWearable[] wearables = avatarAppearance.Wearables;

            for (int i = 0; i < wearables.Length; i++)
            {
                AvatarWearable wearable = wearables[i];
                for (int ii = 0; ii < wearable.Count; ii++)
                {
                    if (wearable[ii].ItemID != UUID.Zero)
                    {
                        // Get inventory item and copy it
                        InventoryItemBase item = InventoryService.GetItem(agentid, wearable[ii].ItemID);

                        if (item != null)
                        {
                            InventoryItemBase destinationItem = InventoryService.InnerGiveInventoryItem(destination,
                                                                                                        destination,
                                                                                                        item,
                                                                                                        destinationFolder
                                                                                                            .ID,
                                                                                                        false);
                            items.Add(destinationItem);
                            MainConsole.Instance.DebugFormat("[RADMIN]: Added item {0} to folder {1}",
                                                             destinationItem.ID, destinationFolder.ID);

                            // Wear item
                            AvatarWearable newWearable = new AvatarWearable();
                            newWearable.Wear(destinationItem.ID, destinationItem.AssetID);
                            avatarAppearance.SetWearable(i, newWearable);
                        }
                        else
                        {
                            MainConsole.Instance.WarnFormat("[RADMIN]: Error transferring {0} to folder {1}",
                                                            wearable[ii].ItemID, destinationFolder.ID);
                        }
                    }
                }
            }

            // Attachments
            List<AvatarAttachment> attachments = avatarAppearance.GetAttachments();

            foreach (AvatarAttachment attachment in attachments)
            {
                int attachpoint = attachment.AttachPoint;
                UUID itemID = attachment.ItemID;

                if (itemID != UUID.Zero)
                {
                    // Get inventory item and copy it
                    InventoryItemBase item = InventoryService.GetItem(source, itemID);

                    if (item != null)
                    {
                        InventoryItemBase destinationItem = InventoryService.InnerGiveInventoryItem(destination,
                                                                                                    destination, item,
                                                                                                    destinationFolder.ID,
                                                                                                    false);
                        items.Add(destinationItem);
                        MainConsole.Instance.DebugFormat("[RADMIN]: Added item {0} to folder {1}", destinationItem.ID,
                                                         destinationFolder.ID);

                        // Attach item
                        avatarAppearance.SetAttachment(attachpoint, destinationItem.ID, destinationItem.AssetID);
                        MainConsole.Instance.DebugFormat("[RADMIN]: Attached {0}", destinationItem.ID);
                    }
                    else
                    {
                        MainConsole.Instance.WarnFormat("[RADMIN]: Error transferring {0} to folder {1}", itemID,
                                                        destinationFolder.ID);
                    }
                }
            }
            return avatarAppearance;
        }
开发者ID:velus,项目名称:Async-Sim-Testing,代码行数:84,代码来源:AppearanceArchiver.cs


注:本文中的AvatarAppearance.GetAttachments方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。