Exemplo n.º 1
0
        private void RemapWornItems(UUID botID, AvatarAppearance appearance)
        {
            // save before Clear calls
            List <AvatarWearable>   wearables   = appearance.GetWearables();
            List <AvatarAttachment> attachments = appearance.GetAttachments();

            appearance.ClearWearables();
            appearance.ClearAttachments();

            // Remap bot outfit with new item IDs
            foreach (AvatarWearable w in wearables)
            {
                AvatarWearable newWearable = new AvatarWearable(w);
                // store a reversible back-link to the original inventory item ID.
                newWearable.ItemID = w.ItemID ^ botID;
                appearance.SetWearable(newWearable);
            }

            foreach (AvatarAttachment a in attachments)
            {
                // store a reversible back-link to the original inventory item ID.
                UUID itemID = a.ItemID ^ botID;
                appearance.SetAttachment(a.AttachPoint, true, itemID, a.AssetID);
            }
        }
Exemplo n.º 2
0
        // TODO: unused
        // private void UpdateAvatarAppearance(UUID avatarID, int wearableType, UUID itemID, UUID assetID)
        // {
        //     AvatarAppearance appearance = GetAppearance(avatarID);
        //     appearance.Wearables[wearableType].AssetID = assetID;
        //     appearance.Wearables[wearableType].ItemID = itemID;
        //     m_userDataBaseService.UpdateUserAppearance(avatarID, appearance);
        // }

        // TODO: unused
        // private void UpdateAvatarAttachment(UUID avatarID, int attachmentPoint, UUID itemID, UUID assetID)
        // {
        //     AvatarAppearance appearance = GetAppearance(avatarID);
        //     appearance.SetAttachment(attachmentPoint, itemID, assetID);
        //     m_userDataBaseService.UpdateUserAppearance(avatarID, appearance);
        // }

        private void RemoveClothesAndAttachments(UUID avatarID)
        {
            AvatarAppearance appearance = GetAppearance(avatarID);

            appearance.ClearWearables();
            appearance.ClearAttachments();
            m_userDataBaseService.UpdateUserAppearance(avatarID, appearance);
        }
Exemplo n.º 3
0
        public AvatarAppearance ToAvatarAppearance(UUID owner)
        {
            AvatarAppearance appearance = new AvatarAppearance(owner);

            if (Data.Count == 0)
                return appearance;

            appearance.ClearWearables();
            try
            {
                if (Data.ContainsKey("Serial"))
                    appearance.Serial = Int32.Parse(Data["Serial"]);

                if (Data.ContainsKey("AvatarHeight"))
                    appearance.AvatarHeight = float.Parse(Data["AvatarHeight"]);

                // Legacy Wearables
                if (Data.ContainsKey("BodyItem"))
                    appearance.Wearables[AvatarWearable.BODY].Wear(
                            UUID.Parse(Data["BodyItem"]),
                            UUID.Parse(Data["BodyAsset"]));

                if (Data.ContainsKey("SkinItem"))
                    appearance.Wearables[AvatarWearable.SKIN].Wear(
                            UUID.Parse(Data["SkinItem"]),
                            UUID.Parse(Data["SkinAsset"]));

                if (Data.ContainsKey("HairItem"))
                    appearance.Wearables[AvatarWearable.HAIR].Wear(
                            UUID.Parse(Data["HairItem"]),
                            UUID.Parse(Data["HairAsset"]));

                if (Data.ContainsKey("EyesItem"))
                    appearance.Wearables[AvatarWearable.EYES].Wear(
                            UUID.Parse(Data["EyesItem"]),
                            UUID.Parse(Data["EyesAsset"]));

                if (Data.ContainsKey("ShirtItem"))
                    appearance.Wearables[AvatarWearable.SHIRT].Wear(
                            UUID.Parse(Data["ShirtItem"]),
                            UUID.Parse(Data["ShirtAsset"]));

                if (Data.ContainsKey("PantsItem"))
                    appearance.Wearables[AvatarWearable.PANTS].Wear(
                            UUID.Parse(Data["PantsItem"]),
                            UUID.Parse(Data["PantsAsset"]));

                if (Data.ContainsKey("ShoesItem"))
                    appearance.Wearables[AvatarWearable.SHOES].Wear(
                            UUID.Parse(Data["ShoesItem"]),
                            UUID.Parse(Data["ShoesAsset"]));

                if (Data.ContainsKey("SocksItem"))
                    appearance.Wearables[AvatarWearable.SOCKS].Wear(
                            UUID.Parse(Data["SocksItem"]),
                            UUID.Parse(Data["SocksAsset"]));

                if (Data.ContainsKey("JacketItem"))
                    appearance.Wearables[AvatarWearable.JACKET].Wear(
                            UUID.Parse(Data["JacketItem"]),
                            UUID.Parse(Data["JacketAsset"]));

                if (Data.ContainsKey("GlovesItem"))
                    appearance.Wearables[AvatarWearable.GLOVES].Wear(
                            UUID.Parse(Data["GlovesItem"]),
                            UUID.Parse(Data["GlovesAsset"]));

                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;
        }
Exemplo n.º 4
0
        public AvatarAppearance ToAvatarAppearance()
        {
            AvatarAppearance appearance = new AvatarAppearance();

            if (Data.Count == 0)
            {
                return(appearance);
            }

            appearance.ClearWearables();
            try
            {
                if (Data.ContainsKey("Serial"))
                {
                    appearance.Serial = Int32.Parse(Data["Serial"]);
                }

                if (Data.ContainsKey("AvatarHeight"))
                {
                    appearance.AvatarHeight = float.Parse(Data["AvatarHeight"]);
                }

                // Legacy Wearables
                if (Data.ContainsKey("BodyItem"))
                {
                    appearance.Wearables[AvatarWearable.BODY].Wear(
                        UUID.Parse(Data["BodyItem"]),
                        UUID.Parse(Data["BodyAsset"]));
                }

                if (Data.ContainsKey("SkinItem"))
                {
                    appearance.Wearables[AvatarWearable.SKIN].Wear(
                        UUID.Parse(Data["SkinItem"]),
                        UUID.Parse(Data["SkinAsset"]));
                }

                if (Data.ContainsKey("HairItem"))
                {
                    appearance.Wearables[AvatarWearable.HAIR].Wear(
                        UUID.Parse(Data["HairItem"]),
                        UUID.Parse(Data["HairAsset"]));
                }

                if (Data.ContainsKey("EyesItem"))
                {
                    appearance.Wearables[AvatarWearable.EYES].Wear(
                        UUID.Parse(Data["EyesItem"]),
                        UUID.Parse(Data["EyesAsset"]));
                }

                if (Data.ContainsKey("ShirtItem"))
                {
                    appearance.Wearables[AvatarWearable.SHIRT].Wear(
                        UUID.Parse(Data["ShirtItem"]),
                        UUID.Parse(Data["ShirtAsset"]));
                }

                if (Data.ContainsKey("PantsItem"))
                {
                    appearance.Wearables[AvatarWearable.PANTS].Wear(
                        UUID.Parse(Data["PantsItem"]),
                        UUID.Parse(Data["PantsAsset"]));
                }

                if (Data.ContainsKey("ShoesItem"))
                {
                    appearance.Wearables[AvatarWearable.SHOES].Wear(
                        UUID.Parse(Data["ShoesItem"]),
                        UUID.Parse(Data["ShoesAsset"]));
                }

                if (Data.ContainsKey("SocksItem"))
                {
                    appearance.Wearables[AvatarWearable.SOCKS].Wear(
                        UUID.Parse(Data["SocksItem"]),
                        UUID.Parse(Data["SocksAsset"]));
                }

                if (Data.ContainsKey("JacketItem"))
                {
                    appearance.Wearables[AvatarWearable.JACKET].Wear(
                        UUID.Parse(Data["JacketItem"]),
                        UUID.Parse(Data["JacketAsset"]));
                }

                if (Data.ContainsKey("GlovesItem"))
                {
                    appearance.Wearables[AvatarWearable.GLOVES].Wear(
                        UUID.Parse(Data["GlovesItem"]),
                        UUID.Parse(Data["GlovesAsset"]));
                }

                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;
                }

                // 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);
        }
Exemplo n.º 5
0
        public AvatarAppearance ToAvatarAppearance()
        {
            AvatarAppearance appearance = new AvatarAppearance();

            if (Data.Count == 0)
            {
                return(appearance);
            }

            appearance.ClearWearables();
            try
            {
                if (Data.ContainsKey("Serial"))
                {
                    appearance.Serial = Int32.Parse(Data["Serial"]);
                }

                if (Data.ContainsKey("AvatarHeight"))
                {
                    float h = float.Parse(Data["AvatarHeight"]);
                    if (h == 0f)
                    {
                        h = 1.9f;
                    }
                    appearance.SetSize(new Vector3(0.45f, 0.6f, h));
                }

                // Legacy Wearables
                if (Data.ContainsKey("BodyItem"))
                {
                    appearance.Wearables[AvatarWearable.BODY].Wear(
                        UUID.Parse(Data["BodyItem"]),
                        UUID.Parse(Data["BodyAsset"]));
                }

                if (Data.ContainsKey("SkinItem"))
                {
                    appearance.Wearables[AvatarWearable.SKIN].Wear(
                        UUID.Parse(Data["SkinItem"]),
                        UUID.Parse(Data["SkinAsset"]));
                }

                if (Data.ContainsKey("HairItem"))
                {
                    appearance.Wearables[AvatarWearable.HAIR].Wear(
                        UUID.Parse(Data["HairItem"]),
                        UUID.Parse(Data["HairAsset"]));
                }

                if (Data.ContainsKey("EyesItem"))
                {
                    appearance.Wearables[AvatarWearable.EYES].Wear(
                        UUID.Parse(Data["EyesItem"]),
                        UUID.Parse(Data["EyesAsset"]));
                }

                if (Data.ContainsKey("ShirtItem"))
                {
                    appearance.Wearables[AvatarWearable.SHIRT].Wear(
                        UUID.Parse(Data["ShirtItem"]),
                        UUID.Parse(Data["ShirtAsset"]));
                }

                if (Data.ContainsKey("PantsItem"))
                {
                    appearance.Wearables[AvatarWearable.PANTS].Wear(
                        UUID.Parse(Data["PantsItem"]),
                        UUID.Parse(Data["PantsAsset"]));
                }

                if (Data.ContainsKey("ShoesItem"))
                {
                    appearance.Wearables[AvatarWearable.SHOES].Wear(
                        UUID.Parse(Data["ShoesItem"]),
                        UUID.Parse(Data["ShoesAsset"]));
                }

                if (Data.ContainsKey("SocksItem"))
                {
                    appearance.Wearables[AvatarWearable.SOCKS].Wear(
                        UUID.Parse(Data["SocksItem"]),
                        UUID.Parse(Data["SocksAsset"]));
                }

                if (Data.ContainsKey("JacketItem"))
                {
                    appearance.Wearables[AvatarWearable.JACKET].Wear(
                        UUID.Parse(Data["JacketItem"]),
                        UUID.Parse(Data["JacketAsset"]));
                }

                if (Data.ContainsKey("GlovesItem"))
                {
                    appearance.Wearables[AvatarWearable.GLOVES].Wear(
                        UUID.Parse(Data["GlovesItem"]),
                        UUID.Parse(Data["GlovesAsset"]));
                }

                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[vps.Length];

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

                    appearance.VisualParams = binary;
                }

                AvatarWearable[] wearables = appearance.Wearables;
                int currentLength          = wearables.Length;
                foreach (KeyValuePair <string, string> _kvp in Data)
                {
                    // New style wearables
                    if (_kvp.Key.StartsWith("Wearable ") && _kvp.Key.Length > 9)
                    {
                        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]);
                        if (index >= currentLength)
                        {
                            Array.Resize(ref wearables, index + 1);
                            for (int i = currentLength; i < wearables.Length; i++)
                            {
                                wearables[i] = new AvatarWearable();
                            }
                            currentLength = wearables.Length;
                        }
                        wearables[index].Add(itemID, assetID);
                        continue;
                    }
                    // Attachments
                    if (_kvp.Key.StartsWith("_ap_") && _kvp.Key.Length > 4)
                    {
                        string pointStr = _kvp.Key.Substring(4);
                        int    point    = 0;
                        if (Int32.TryParse(pointStr, out point))
                        {
                            List <string> idList = new List <string>(_kvp.Value.Split(new char[] { ',' }));

                            appearance.SetAttachment(point, UUID.Zero, UUID.Zero);
                            foreach (string id in idList)
                            {
                                UUID uuid = UUID.Zero;
                                if (UUID.TryParse(id, out uuid))
                                {
                                    appearance.SetAttachment(point | 0x80, 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);
        }
Exemplo n.º 6
0
        public AvatarAppearance ToAvatarAppearance(UUID owner)
        {
            AvatarAppearance appearance = new AvatarAppearance(owner);

            if (Data.Count == 0)
            {
                return(appearance);
            }

            appearance.ClearWearables();
            try
            {
                if (Data.ContainsKey("Serial"))
                {
                    appearance.Serial = Int32.Parse(Data["Serial"]);
                }

                if (Data.ContainsKey("AvatarHeight"))
                {
                    appearance.AvatarHeight = float.Parse(Data["AvatarHeight"]);
                }

                // Legacy Wearables
                if (Data.ContainsKey("BodyItem"))
                {
                    appearance.Wearables[AvatarWearable.BODY].Wear(
                        UUID.Parse(Data["BodyItem"]),
                        UUID.Parse(Data["BodyAsset"]));
                }

                if (Data.ContainsKey("SkinItem"))
                {
                    appearance.Wearables[AvatarWearable.SKIN].Wear(
                        UUID.Parse(Data["SkinItem"]),
                        UUID.Parse(Data["SkinAsset"]));
                }

                if (Data.ContainsKey("HairItem"))
                {
                    appearance.Wearables[AvatarWearable.HAIR].Wear(
                        UUID.Parse(Data["HairItem"]),
                        UUID.Parse(Data["HairAsset"]));
                }

                if (Data.ContainsKey("EyesItem"))
                {
                    appearance.Wearables[AvatarWearable.EYES].Wear(
                        UUID.Parse(Data["EyesItem"]),
                        UUID.Parse(Data["EyesAsset"]));
                }

                if (Data.ContainsKey("ShirtItem"))
                {
                    appearance.Wearables[AvatarWearable.SHIRT].Wear(
                        UUID.Parse(Data["ShirtItem"]),
                        UUID.Parse(Data["ShirtAsset"]));
                }

                if (Data.ContainsKey("PantsItem"))
                {
                    appearance.Wearables[AvatarWearable.PANTS].Wear(
                        UUID.Parse(Data["PantsItem"]),
                        UUID.Parse(Data["PantsAsset"]));
                }

                if (Data.ContainsKey("ShoesItem"))
                {
                    appearance.Wearables[AvatarWearable.SHOES].Wear(
                        UUID.Parse(Data["ShoesItem"]),
                        UUID.Parse(Data["ShoesAsset"]));
                }

                if (Data.ContainsKey("SocksItem"))
                {
                    appearance.Wearables[AvatarWearable.SOCKS].Wear(
                        UUID.Parse(Data["SocksItem"]),
                        UUID.Parse(Data["SocksAsset"]));
                }

                if (Data.ContainsKey("JacketItem"))
                {
                    appearance.Wearables[AvatarWearable.JACKET].Wear(
                        UUID.Parse(Data["JacketItem"]),
                        UUID.Parse(Data["JacketAsset"]));
                }

                if (Data.ContainsKey("GlovesItem"))
                {
                    appearance.Wearables[AvatarWearable.GLOVES].Wear(
                        UUID.Parse(Data["GlovesItem"]),
                        UUID.Parse(Data["GlovesAsset"]));
                }

                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[] { ',' });
                    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[] { ':' });
                        if (wearIndices.Length == 2 && wearIndices[1].Length == 1)
                        {
                            int index = Convert.ToInt32(wearIndices[0]);

                            string[] ids     = _kvp.Value.Split(new[] { ':' });
                            UUID     itemID  = new UUID(ids[0]);
                            UUID     assetID = new UUID(ids[1]);
                            appearance.Wearables[index].Add(itemID, assetID);
                        }
                        else
                        {
                            //For when we get stuff like 0020_0_x003A_0
                            var index2 = wearIndices[1].Split('_');
                            int index  = Convert.ToInt32(index2[1]);

                            string[] ids     = _kvp.Value.Split(new[] { ':' });
                            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>();
                Dictionary <string, string> attchsAssets = new Dictionary <string, string>();
#if (!ISWIN)
                foreach (KeyValuePair <string, string> _kvp in Data)
                {
                    if (_kvp.Key.StartsWith("_ap_"))
                    {
                        attchs[_kvp.Key] = _kvp.Value;
                    }
                    if (_kvp.Key.StartsWith("_apa_"))
                    {
                        attchsAssets[_kvp.Key] = _kvp.Value;
                    }
                }
#else
                foreach (KeyValuePair <string, string> _kvp in Data.Where(_kvp => _kvp.Key.StartsWith("_ap_")))
                {
                    attchs[_kvp.Key] = _kvp.Value;
                }
#endif

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

                    UUID uuid = UUID.Zero;
                    UUID.TryParse(_kvp.Value, out uuid);
                    UUID assetuuid = UUID.Zero;
                    if (attchsAssets.ContainsKey(_kvp.Key))
                    {
                        UUID.TryParse(attchsAssets[_kvp.Key], out uuid);
                    }

                    appearance.SetAttachment(point, uuid, assetuuid);
                }

                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);
        }