go an other way like the npc module

master
Christopher 2020-07-11 14:12:45 +02:00
parent c413e4f6ff
commit e4bb40d6ee
1 changed files with 7 additions and 30 deletions

View File

@ -102,6 +102,9 @@ namespace OpenSim.Modules.Appearance2Avatar
foreach (SceneObjectGroup _attachment in _allAttachments)
m_scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, _attachment);
if (m_scene.AttachmentsModule != null)
m_scene.AttachmentsModule.DeleteAttachmentsFromScene(sp, false);
//Remove current outfit from inventory
InventoryFolderBase _outfitFolder = m_scene.InventoryService.GetFolderForType(sp.UUID, FolderType.CurrentOutfit);
@ -110,7 +113,7 @@ namespace OpenSim.Modules.Appearance2Avatar
InventoryCollection _outfitFolderContend = m_scene.InventoryService.GetFolderContent(sp.UUID, _outfitFolder.ID);
List<UUID> _itemIDs = new List<UUID>();
foreach (InventoryItemBase item in _outfitFolderContend.Items.ToArray())
foreach (InventoryItemBase item in _outfitFolderContend.Items)
if (item.InvType == (int)AssetType.Object)
_itemIDs.Add(item.ID);
@ -118,41 +121,15 @@ namespace OpenSim.Modules.Appearance2Avatar
m_scene.InventoryService.UpdateFolder(_outfitFolder);
}
//Load Appearance
OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(noteCardContend);
AvatarAppearance _appearance = new AvatarAppearance(appearanceOsd);
//Add Attachments
m_scene.AvatarFactory.SetAppearance(sp, _appearance, WearableCacheItem.FromOSD(appearanceOsd, m_assetCache));
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.Link;
_item.Name = "Unknown Attachment";
_item.Owner = sp.UUID;
_item.Folder = _outfitFolder.ID;
m_scene.InventoryService.AddItem(_item);
}
m_scene.InventoryService.UpdateFolder(_outfitFolder);
}
AvatarAppearance newAppearance = new AvatarAppearance(_appearance, true);
sp.Appearance = newAppearance;
//Send Update
m_log.Info("[" + Name + "] Info: Send update to all clients");
m_scene.AttachmentsModule.RezAttachments(sp);
foreach (ScenePresence presens in m_scene.GetScenePresences())
m_scene.AvatarFactory.SendAppearance(presens.UUID);
m_scene.AvatarFactory.SendAppearance(sp.UUID);
}
}
else