Fix inventory link deduplication with AssetType.Link
This commit is contained in:
parent
a37bc42a0e
commit
9788254f6f
1 changed files with 31 additions and 10 deletions
|
|
@ -131,21 +131,42 @@ namespace BetterSecondBot.Static
|
|||
{
|
||||
if (contents.Count > 0)
|
||||
{
|
||||
HashSet<UUID> seen = [];
|
||||
HashSet<UUID> seenIds = [];
|
||||
foreach (InventoryBase item in contents)
|
||||
{
|
||||
if (seen.Contains(item.UUID))
|
||||
if (item is InventoryItem itm)
|
||||
{
|
||||
continue;
|
||||
UUID effectiveID = itm.UUID;
|
||||
// If it's a link, the AssetUUID is the UUID of the item it points to
|
||||
if (itm.AssetType == AssetType.Link)
|
||||
{
|
||||
effectiveID = itm.AssetUUID;
|
||||
}
|
||||
|
||||
if (seenIds.Contains(effectiveID))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
seenIds.Add(effectiveID);
|
||||
|
||||
mapitem = new InventoryMapItem
|
||||
{
|
||||
name = item.Name,
|
||||
id = item.UUID.ToString(),
|
||||
typename = item.GetType().Name
|
||||
};
|
||||
entrys.Add(mapitem);
|
||||
}
|
||||
seen.Add(item.UUID);
|
||||
mapitem = new InventoryMapItem
|
||||
else if (item is InventoryFolder fold)
|
||||
{
|
||||
name = item.Name,
|
||||
id = item.UUID.ToString(),
|
||||
typename = item.GetType().Name
|
||||
};
|
||||
entrys.Add(mapitem);
|
||||
mapitem = new InventoryMapItem
|
||||
{
|
||||
name = fold.Name,
|
||||
id = fold.UUID.ToString(),
|
||||
typename = "Folder"
|
||||
};
|
||||
entrys.Add(mapitem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue