Beispiel #1
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);
                    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;
        }
        /// <summary>
        /// This method is called by establishAppearance to copy inventory folders to make
        /// copies of Clothing and Bodyparts inventory folders and attaches worn attachments
        /// </summary>

        private void CopyInventoryFolders(UUID destination, UUID source, AssetType assetType, Dictionary<UUID,UUID> inventoryMap,
                                          AvatarAppearance avatarAppearance)
        {
            IInventoryService inventoryService = manager.CurrentOrFirstScene.InventoryService;

            InventoryFolderBase sourceFolder = inventoryService.GetFolderForType(source, InventoryType.Unknown, assetType);
            InventoryFolderBase destinationFolder = inventoryService.GetFolderForType (destination, InventoryType.Unknown, assetType);

            if (sourceFolder == null || destinationFolder == null)
                throw new Exception("Cannot locate folder(s)");

            // Missing source folder? This should *never* be the case
            if (sourceFolder.Type != (short)assetType)
            {
                sourceFolder = new InventoryFolderBase
                                   {
                                       ID = UUID.Random(),
                                       Name = assetType == AssetType.Clothing ? "Clothing" : "Body Parts",
                                       Owner = source,
                                       Type = (short) assetType,
                                       ParentID = inventoryService.GetRootFolder(source).ID,
                                       Version = 1
                                   };
                inventoryService.AddFolder(sourceFolder);     // store base record
                MainConsole.Instance.ErrorFormat("[RADMIN] Created folder for source {0}", source);
            }

            // Missing destination folder? This should *never* be the case
            if (destinationFolder.Type != (short)assetType)
            {
                destinationFolder = new InventoryFolderBase
                                        {
                                            ID = UUID.Random(),
                                            Name = assetType.ToString(),
                                            Owner = destination,
                                            Type = (short) assetType,
                                            ParentID = inventoryService.GetRootFolder(destination).ID,
                                            Version = 1
                                        };
                inventoryService.AddFolder(destinationFolder);     // store base record
                MainConsole.Instance.ErrorFormat("[RADMIN] Created folder for destination {0}", source);
            }

            List<InventoryFolderBase> folders = inventoryService.GetFolderContent(source, sourceFolder.ID).Folders;

            foreach (InventoryFolderBase folder in folders)
            {

                InventoryFolderBase extraFolder = new InventoryFolderBase
                                                      {
                                                          ID = UUID.Random(),
                                                          Name = folder.Name,
                                                          Owner = destination,
                                                          Type = folder.Type,
                                                          Version = folder.Version,
                                                          ParentID = destinationFolder.ID
                                                      };
                inventoryService.AddFolder(extraFolder);

                MainConsole.Instance.DebugFormat("[RADMIN] Added folder {0} to folder {1}", extraFolder.ID, sourceFolder.ID);

                List<InventoryItemBase> items = inventoryService.GetFolderContent(source, folder.ID).Items;

                foreach (InventoryItemBase item in items)
                {
                    InventoryItemBase destinationItem = new InventoryItemBase(UUID.Random(), destination)
                                                            {
                                                                Name = item.Name,
                                                                Description = item.Description,
                                                                InvType = item.InvType,
                                                                CreatorId = item.CreatorId,
                                                                CreatorData = item.CreatorData,
                                                                CreatorIdAsUuid = item.CreatorIdAsUuid,
                                                                NextPermissions = item.NextPermissions,
                                                                CurrentPermissions = item.CurrentPermissions,
                                                                BasePermissions = item.BasePermissions,
                                                                EveryOnePermissions = item.EveryOnePermissions,
                                                                GroupPermissions = item.GroupPermissions,
                                                                AssetType = item.AssetType,
                                                                AssetID = item.AssetID,
                                                                GroupID = item.GroupID,
                                                                GroupOwned = item.GroupOwned,
                                                                SalePrice = item.SalePrice,
                                                                SaleType = item.SaleType,
                                                                Flags = item.Flags,
                                                                CreationDate = item.CreationDate,
                                                                Folder = extraFolder.ID
                                                            };

                    ILLClientInventory inventoryModule = manager.CurrentOrFirstScene.RequestModuleInterface<ILLClientInventory>();
                    if (inventoryModule != null)
                        inventoryModule.AddInventoryItem(destinationItem);
                    inventoryMap.Add(item.ID, destinationItem.ID);
                    MainConsole.Instance.DebugFormat("[RADMIN]: Added item {0} to folder {1}", destinationItem.ID, extraFolder.ID);

                    // Attach item, if original is attached
                    int attachpoint = avatarAppearance.GetAttachpoint(item.ID);
                    if (attachpoint != 0)
                    {
                        avatarAppearance.SetAttachment(attachpoint, destinationItem.ID, destinationItem.AssetID);
                        MainConsole.Instance.DebugFormat("[RADMIN]: Attached {0}", destinationItem.ID);
                    }
                }
            }
        }
        private AvatarAppearance CopyWearablesAndAttachments(UUID destination, UUID source, AvatarAppearance avatarAppearance, InventoryFolderBase destinationFolder)
        {
            if (destinationFolder == null)
                throw new Exception("Cannot locate folder(s)");

            // 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 = new InventoryItemBase(wearable[ii].ItemID);
                        item = InventoryService.GetItem(item);

                        if (item != null)
                        {
                            InventoryItemBase destinationItem = new InventoryItemBase(UUID.Random(), destination)
                                                                    {
                                                                        Name = item.Name,
                                                                        Description = item.Description,
                                                                        InvType = item.InvType,
                                                                        CreatorId = item.CreatorId,
                                                                        CreatorData = item.CreatorData,
                                                                        CreatorIdAsUuid = item.CreatorIdAsUuid,
                                                                        NextPermissions = item.NextPermissions,
                                                                        CurrentPermissions = item.CurrentPermissions,
                                                                        BasePermissions = item.BasePermissions,
                                                                        EveryOnePermissions = item.EveryOnePermissions,
                                                                        GroupPermissions = item.GroupPermissions,
                                                                        AssetType = item.AssetType,
                                                                        AssetID = item.AssetID,
                                                                        GroupID = item.GroupID,
                                                                        GroupOwned = item.GroupOwned,
                                                                        SalePrice = item.SalePrice,
                                                                        SaleType = item.SaleType,
                                                                        Flags = item.Flags,
                                                                        CreationDate = item.CreationDate,
                                                                        Folder = destinationFolder.ID
                                                                    };
                            if (InventoryService != null)
                                InventoryService.AddItem(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, wearable[ii].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 = new InventoryItemBase(itemID, source);
                    item = InventoryService.GetItem(item);

                    if (item != null)
                    {
                        InventoryItemBase destinationItem = new InventoryItemBase(UUID.Random(), destination)
                        {
                            Name = item.Name,
                            Description = item.Description,
                            InvType = item.InvType,
                            CreatorId = item.CreatorId,
                            CreatorData = item.CreatorData,
                            CreatorIdAsUuid = item.CreatorIdAsUuid,
                            NextPermissions = item.NextPermissions,
                            CurrentPermissions = item.CurrentPermissions,
                            BasePermissions = item.BasePermissions,
                            EveryOnePermissions = item.EveryOnePermissions,
                            GroupPermissions = item.GroupPermissions,
                            AssetType = item.AssetType,
                            AssetID = item.AssetID,
                            GroupID = item.GroupID,
                            GroupOwned = item.GroupOwned,
                            SalePrice = item.SalePrice,
                            SaleType = item.SaleType,
                            Flags = item.Flags,
                            CreationDate = item.CreationDate,
                            Folder = destinationFolder.ID
                        };
                        if (InventoryService != null)
                            InventoryService.AddItem(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;
        }
        /// <summary>
        /// This method is called by establishAppearance to do a copy all inventory items
        /// worn or attached to the Clothing inventory folder of the receiving avatar.
        /// In parallel the avatar wearables and attachments are updated.
        /// </summary>

        private void CopyWearablesAndAttachments(UUID destination, UUID source, AvatarAppearance avatarAppearance)
        {
            IInventoryService inventoryService = manager.CurrentOrFirstScene.InventoryService;

            // Get Clothing folder of receiver
            InventoryFolderBase destinationFolder = inventoryService.GetFolderForType (destination, InventoryType.Wearable, AssetType.Clothing);

            if (destinationFolder == null)
                throw new Exception("Cannot locate folder(s)");

            // Missing destination folder? This should *never* be the case
            if (destinationFolder.Type != (short)AssetType.Clothing)
            {
                destinationFolder = new InventoryFolderBase
                                        {
                                            ID = UUID.Random(),
                                            Name = "Clothing",
                                            Owner = destination,
                                            Type = (short) AssetType.Clothing,
                                            ParentID = inventoryService.GetRootFolder(destination).ID,
                                            Version = 1
                                        };

                inventoryService.AddFolder(destinationFolder);     // store base record
                MainConsole.Instance.ErrorFormat("[RADMIN] Created folder for destination {0}", source);
            }

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

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

                    if (item != null)
                    {
                        InventoryItemBase destinationItem = new InventoryItemBase(UUID.Random(), destination)
                                                                {
                                                                    Name = item.Name,
                                                                    Description = item.Description,
                                                                    InvType = item.InvType,
                                                                    CreatorId = item.CreatorId,
                                                                    CreatorData = item.CreatorData,
                                                                    CreatorIdAsUuid = item.CreatorIdAsUuid,
                                                                    NextPermissions = item.NextPermissions,
                                                                    CurrentPermissions = item.CurrentPermissions,
                                                                    BasePermissions = item.BasePermissions,
                                                                    EveryOnePermissions = item.EveryOnePermissions,
                                                                    GroupPermissions = item.GroupPermissions,
                                                                    AssetType = item.AssetType,
                                                                    AssetID = item.AssetID,
                                                                    GroupID = item.GroupID,
                                                                    GroupOwned = item.GroupOwned,
                                                                    SalePrice = item.SalePrice,
                                                                    SaleType = item.SaleType,
                                                                    Flags = item.Flags,
                                                                    CreationDate = item.CreationDate,
                                                                    Folder = destinationFolder.ID
                                                                };
                        ILLClientInventory inventoryModule = manager.CurrentOrFirstScene.RequestModuleInterface<ILLClientInventory>();
                        if (inventoryModule != null)
                            inventoryModule.AddInventoryItem(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, wearable[0].AssetID);
                        avatarAppearance.SetWearable(i, newWearable);
                    }
                    else
                    {
                        MainConsole.Instance.WarnFormat("[RADMIN]: Error transferring {0} to folder {1}", wearable[0].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 = new InventoryItemBase(itemID, source);
                    item = inventoryService.GetItem(item);

                    if (item != null)
                    {
                        InventoryItemBase destinationItem = new InventoryItemBase(UUID.Random(), destination)
                                                                {
                                                                    Name = item.Name,
                                                                    Description = item.Description,
                                                                    InvType = item.InvType,
                                                                    CreatorId = item.CreatorId,
                                                                    CreatorData = item.CreatorData,
                                                                    CreatorIdAsUuid = item.CreatorIdAsUuid,
                                                                    NextPermissions = item.NextPermissions,
                                                                    CurrentPermissions = item.CurrentPermissions,
                                                                    BasePermissions = item.BasePermissions,
                                                                    EveryOnePermissions = item.EveryOnePermissions,
                                                                    GroupPermissions = item.GroupPermissions,
                                                                    AssetType = item.AssetType,
                                                                    AssetID = item.AssetID,
                                                                    GroupID = item.GroupID,
                                                                    GroupOwned = item.GroupOwned,
                                                                    SalePrice = item.SalePrice,
                                                                    SaleType = item.SaleType,
                                                                    Flags = item.Flags,
                                                                    CreationDate = item.CreationDate,
                                                                    Folder = destinationFolder.ID
                                                                };
                        ILLClientInventory inventoryModule = manager.CurrentOrFirstScene.RequestModuleInterface<ILLClientInventory>();
                        if (inventoryModule != null)
                            inventoryModule.AddInventoryItem(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);
                    }
                }
            }
        }
        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 = new InventoryItemBase(wearable[ii].ItemID);
                        item = InventoryService.GetItem(item);

                        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, wearable[ii].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 = new InventoryItemBase(itemID, source);
                    item = InventoryService.GetItem(item);

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