remove attachments from current appearence if they are not found in inventory

This commit is contained in:
UbitUmarov
2025-04-20 23:52:12 +01:00
parent bc59e3a3e7
commit 8b962b19db
4 changed files with 37 additions and 7 deletions

View File

@@ -700,7 +700,29 @@ namespace OpenSim.Framework
}
}
}
return false;
}
public bool RemoveAttachment(int attachPoint, UUID itemID)
{
lock (m_attachments)
{
if(m_attachments.TryGetValue(attachPoint, out List<AvatarAttachment> lst) && lst is not null)
{
int index = lst.FindIndex(delegate(AvatarAttachment a) { return a.ItemID.Equals(itemID); });
if (index >= 0)
{
// Remove it from the list of attachments at that attach point
lst.RemoveAt(index);
// And remove the list if there are no more attachments here
if (lst.Count == 0)
m_attachments.Remove(attachPoint);
return true;
}
}
}
return false;
}