remove and add to outfit folder

master
Christopher 2020-07-10 20:21:16 +02:00
parent d97aea9ac9
commit df9c30b609
1 changed files with 32 additions and 2 deletions

View File

@ -102,16 +102,46 @@ namespace OpenSim.Modules.Appearance2Avatar
foreach (SceneObjectGroup _attachment in _allAttachments) foreach (SceneObjectGroup _attachment in _allAttachments)
m_scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, _attachment); m_scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, _attachment);
//Remove current outfit from inventory
InventoryFolderBase _outfitFolder = m_scene.InventoryService.GetFolderForType(sp.UUID, FolderType.CurrentOutfit);
if(_outfitFolder != null)
{
InventoryCollection _outfitFolderContend = m_scene.InventoryService.GetFolderContent(sp.UUID, _outfitFolder.ID);
List<UUID> _itemIDs = new List<UUID>();
foreach (InventoryItemBase item in _outfitFolderContend.Items.ToArray())
_itemIDs.Add(item.ID);
m_scene.InventoryService.DeleteItems(sp.UUID, _itemIDs);
}
//Load Appearance //Load Appearance
m_log.Info(noteCardContend);
m_log.Info("[" + Name + "] Info: Deserialize notecard.");
OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(noteCardContend); OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(noteCardContend);
AvatarAppearance _appearance = new AvatarAppearance(appearanceOsd); AvatarAppearance _appearance = new AvatarAppearance(appearanceOsd);
//Add Attachments
m_scene.AvatarFactory.SetAppearance(sp, _appearance, WearableCacheItem.FromOSD(appearanceOsd, m_assetCache)); m_scene.AvatarFactory.SetAppearance(sp, _appearance, WearableCacheItem.FromOSD(appearanceOsd, m_assetCache));
m_scene.AvatarService.SetAppearance(sp.UUID, _appearance); m_scene.AvatarService.SetAppearance(sp.UUID, _appearance);
//Add items to current outfit inventory
if (_outfitFolder != null)
{
List<AvatarAttachment> _attachments = _appearance.GetAttachments();
foreach(AvatarAttachment attachment in _attachments)
{
InventoryItemBase _item = new InventoryItemBase();
_item.AssetID = attachment.AssetID;
_item.AssetType = (int)AssetType.Object;
_item.Name = "Unknown Attachment";
_item.Owner = sp.UUID;
_item.Folder = _outfitFolder.ID;
m_scene.InventoryService.AddItem(_item);
}
}
//Send Update //Send Update
m_log.Info("[" + Name + "] Info: Send update to all clients"); m_log.Info("[" + Name + "] Info: Send update to all clients");
foreach (ScenePresence presens in m_scene.GetScenePresences()) foreach (ScenePresence presens in m_scene.GetScenePresences())