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


C# AvatarAppearance.SetAttachment方法代码示例

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


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

示例1: ToAvatarAppearance


//.........这里部分代码省略.........
                if (Data.ContainsKey("UnderShirtItem"))
                    appearance.Wearables[AvatarWearable.UNDERSHIRT].Wear(
                            UUID.Parse(Data["UnderShirtItem"]),
                            UUID.Parse(Data["UnderShirtAsset"]));

                if (Data.ContainsKey("UnderPantsItem"))
                    appearance.Wearables[AvatarWearable.UNDERPANTS].Wear(
                            UUID.Parse(Data["UnderPantsItem"]),
                            UUID.Parse(Data["UnderPantsAsset"]));

                if (Data.ContainsKey("SkirtItem"))
                    appearance.Wearables[AvatarWearable.SKIRT].Wear(
                            UUID.Parse(Data["SkirtItem"]),
                            UUID.Parse(Data["SkirtAsset"]));


                if (Data.ContainsKey("VisualParams"))
                {
                    string[] vps = Data["VisualParams"].Split(new char[] { ',' });
                    byte[] binary = new byte[AvatarAppearance.VISUALPARAM_COUNT];

                    for (int i = 0; i < vps.Length && i < binary.Length; i++)
                        binary[i] = (byte)Convert.ToInt32(vps[i]);

                    appearance.VisualParams = binary;
                }

                if (Data.ContainsKey("Textures"))
                {
                    string t = Data["Textures"];
                    OSD tex = OSDParser.DeserializeJson(t);
                    appearance.Texture = Primitive.TextureEntry.FromOSD(tex);
                }

                // New style wearables
                foreach (KeyValuePair<string, string> _kvp in Data)
                {
                    if (_kvp.Key.StartsWith("Wearable "))
                    {
                        string wearIndex = _kvp.Key.Substring(9);
                        string[] wearIndices = wearIndex.Split(new char[] { ':' });
                        int index = Convert.ToInt32(wearIndices[0]);

                        string[] ids = _kvp.Value.Split(new char[] { ':' });
                        UUID itemID = new UUID(ids[0]);
                        UUID assetID = new UUID(ids[1]);

                        appearance.Wearables[index].Add(itemID, assetID);
                    }
                }


                // Attachments
                Dictionary<string, string> attchs = new Dictionary<string, string>();
                foreach (KeyValuePair<string, string> _kvp in Data)
                    if (_kvp.Key.StartsWith("_ap_"))
                        attchs[_kvp.Key] = _kvp.Value;

                foreach (KeyValuePair<string, string> _kvp in attchs)
                {
                    string pointStr = _kvp.Key.Substring(4);
                    int point = 0;
                    if (!Int32.TryParse(pointStr, out point))
                        continue;

                    UUID uuid = UUID.Zero;
                    UUID.TryParse(_kvp.Value, out uuid);

                    appearance.SetAttachment(point, uuid, UUID.Zero);
                }

                if (appearance.Wearables[AvatarWearable.BODY].Count == 0)
                    appearance.Wearables[AvatarWearable.BODY].Wear(
                            AvatarWearable.DefaultWearables[
                            AvatarWearable.BODY][0]);

                if (appearance.Wearables[AvatarWearable.SKIN].Count == 0)
                    appearance.Wearables[AvatarWearable.SKIN].Wear(
                            AvatarWearable.DefaultWearables[
                            AvatarWearable.SKIN][0]);

                if (appearance.Wearables[AvatarWearable.HAIR].Count == 0)
                    appearance.Wearables[AvatarWearable.HAIR].Wear(
                            AvatarWearable.DefaultWearables[
                            AvatarWearable.HAIR][0]);

                if (appearance.Wearables[AvatarWearable.EYES].Count == 0)
                    appearance.Wearables[AvatarWearable.EYES].Wear(
                            AvatarWearable.DefaultWearables[
                            AvatarWearable.EYES][0]);
            }
            catch
            {
                // We really should report something here, returning null
                // will at least break the wrapper
                return null;
            }

            return appearance;
        }
开发者ID:rknop,项目名称:Aurora-Sim,代码行数:101,代码来源:IAvatarService.cs

示例2: ConvertXMLToAvatarAppearance


//.........这里部分代码省略.........
            appearance.ShoesAsset = new UUID(newFile[19]);
            appearance.ShoesItem = new UUID(newFile[20]);
            appearance.SkinAsset = new UUID(newFile[21]);
            appearance.SkinItem = new UUID(newFile[22]);
            appearance.SkirtAsset = new UUID(newFile[23]);
            appearance.SkirtItem = new UUID(newFile[24]);
            appearance.SocksAsset = new UUID(newFile[25]);
            appearance.SocksItem = new UUID(newFile[26]);
            //appearance.Texture = new Primitive.TextureEntry(newFile[27],);
            appearance.UnderPantsAsset = new UUID(newFile[27]);
            appearance.UnderPantsItem = new UUID(newFile[28]);
            appearance.UnderShirtAsset = new UUID(newFile[29]);
            appearance.UnderShirtItem = new UUID(newFile[30]);
            FolderNameToPlaceAppearanceIn = newFile[31];

            Byte[] bytes = new byte[218];
            int i = 0;
            while (i <= 31)
            {
                newFile.RemoveAt(0); //Clear out the already processed parts
                i++;
            }
            i = 0;
            if (newFile[0] == "VisualParams")
            {
                foreach (string partLine in newFile)
                {
                    if (partLine.StartsWith("/VP"))
                    {
                        string newpartLine = "";
                        newpartLine = partLine.Replace("/VP", "");
                        bytes[i] = Convert.ToByte(newpartLine);
                        i++;
                    }
                }
            }
            appearance.VisualParams = bytes;
            List<string> WearableAsset = new List<string>();
            List<string> WearableItem = new List<string>();
            string texture = "";
            AttachmentIDs = new List<UUID>();
            AttachmentPoints = new List<string>();
            AttachmentAsset = new List<string>();
            foreach (string partLine in newFile)
            {
                if (partLine.StartsWith("WA"))
                {
                    string newpartLine = "";
                    newpartLine = partLine.Replace("WA", "");
                    WearableAsset.Add(newpartLine);
                }
                if (partLine.StartsWith("WI"))
                {
                    string newpartLine = "";
                    newpartLine = partLine.Replace("WI", "");
                    WearableItem.Add(newpartLine);
                }
                if (partLine.StartsWith("TEXTURE"))
                {
                    string newpartLine = "";
                    newpartLine = partLine.Replace("TEXTURE", "");
                    texture = newpartLine;
                }
                if (partLine.StartsWith("AI"))
                {
                    string newpartLine = "";
                    newpartLine = partLine.Replace("AI", "");
                    AttachmentIDs.Add(new UUID(newpartLine));
                }
                if (partLine.StartsWith("AA"))
                {
                    string newpartLine = "";
                    newpartLine = partLine.Replace("AA", "");
                    AttachmentAsset.Add(newpartLine);
                }
                if (partLine.StartsWith("AP"))
                {
                    string newpartLine = "";
                    newpartLine = partLine.Replace("AP", "");
                    AttachmentPoints.Add(newpartLine);
                }
            }
            //byte[] textureBytes = Utils.StringToBytes(texture);
            //appearance.Texture = new Primitive.TextureEntry(textureBytes, 0, textureBytes.Length);
            AvatarWearable[] wearables = new AvatarWearable[13];
            i = 0;
            foreach (string asset in WearableAsset)
            {
                AvatarWearable wearable = new AvatarWearable(new UUID(asset), new UUID(WearableItem[i]));
                wearables[i] = wearable;
                i++;
            }
            i = 0;
            foreach (string asset in AttachmentAsset)
            {
                appearance.SetAttachment(Convert.ToInt32(AttachmentPoints[i]), AttachmentIDs[i], new UUID(asset));
                i++;
            }
            return appearance;
        }
开发者ID:shangcheng,项目名称:Aurora,代码行数:101,代码来源:AppearanceArchiver.cs

示例3: 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

示例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: ConvertXMLToAvatarAppearance

        private AvatarAppearance ConvertXMLToAvatarAppearance(OSDMap map, out string FolderNameToPlaceAppearanceIn)
        {
            AvatarAppearance appearance = new AvatarAppearance();

            appearance.AvatarHeight = (float)map["AvatarHeight"].AsReal();
            appearance.BodyAsset = map["BodyAsset"].AsUUID();
            appearance.BodyItem = map["BodyItem"].AsUUID();
            appearance.EyesAsset = map["EyesAsset"].AsUUID();
            appearance.EyesItem = map["EyesItem"].AsUUID();
            appearance.GlovesAsset = map["GlovesAsset"].AsUUID();
            appearance.GlovesItem = map["GlovesItem"].AsUUID();
            appearance.HairAsset = map["HairAsset"].AsUUID();
            appearance.HairItem = map["HairItem"].AsUUID();
            //Skip Hip Offset
            appearance.JacketAsset = map["JacketAsset"].AsUUID();
            appearance.JacketItem = map["JacketItem"].AsUUID();
            appearance.Owner = map["Owner"].AsUUID();
            appearance.PantsAsset = map["PantsAsset"].AsUUID();
            appearance.PantsItem = map["PantsItem"].AsUUID();
            appearance.Serial = map["Serial"].AsInteger();
            appearance.ShirtAsset = map["ShirtAsset"].AsUUID();
            appearance.ShirtItem = map["ShirtItem"].AsUUID();
            appearance.ShoesAsset = map["ShoesAsset"].AsUUID();
            appearance.ShoesItem = map["ShoesItem"].AsUUID();
            appearance.SkinAsset = map["SkinAsset"].AsUUID();
            appearance.SkinItem = map["SkinItem"].AsUUID();
            appearance.SkirtAsset = map["SkirtAsset"].AsUUID();
            appearance.SkirtItem = map["SkirtItem"].AsUUID();
            appearance.SocksAsset = map["SocksAsset"].AsUUID();
            appearance.SocksItem = map["SocksItem"].AsUUID();
            appearance.UnderPantsAsset = map["UnderPantsAsset"].AsUUID();
            appearance.UnderPantsItem = map["UnderPantsItem"].AsUUID();
            appearance.UnderShirtAsset = map["UnderShirtAsset"].AsUUID();
            appearance.UnderShirtItem = map["UnderShirtItem"].AsUUID();
            appearance.TattooAsset = map["TattooAsset"].AsUUID();
            appearance.TattooItem = map["TattooItem"].AsUUID();
            appearance.AlphaAsset = map["AlphaAsset"].AsUUID();
            appearance.AlphaItem = map["AlphaItem"].AsUUID();
            FolderNameToPlaceAppearanceIn = map["FolderName"].AsString();
            appearance.VisualParams = map["VisualParams"].AsBinary();

            OSDArray wearables = (OSDArray)map["AvatarWearables"];
            List<AvatarWearable> AvatarWearables = new List<AvatarWearable>();
            foreach (OSD o in wearables)
            {
                OSDMap wearable = (OSDMap)o;
                AvatarWearable wear = new AvatarWearable();
                wear.AssetID = wearable["Asset"].AsUUID();
                wear.ItemID = wearable["Item"].AsUUID();
                AvatarWearables.Add(wear);
            }
            appearance.Wearables = AvatarWearables.ToArray();

            appearance.Texture = Primitive.TextureEntry.FromOSD(map["Texture"]);

            OSDArray attachmentsArray = (OSDArray)map["Attachments"];
            foreach (OSD o in wearables)
            {
                OSDMap attachment = (OSDMap)o;
                UUID Asset = attachment["Asset"].AsUUID();
                UUID Item = attachment["Item"].AsUUID();
                int AttachmentPoint = attachment["Point"].AsInteger();

                appearance.SetAttachment(AttachmentPoint, Item, Asset);
            }
            return appearance;
        }
开发者ID:WordfromtheWise,项目名称:Aurora,代码行数:67,代码来源:AppearanceArchiver.cs


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