Skip to content

Commit

Permalink
Populate Attachments from COF as well, as it is a canonical source
Browse files Browse the repository at this point in the history
  • Loading branch information
cinderblocks committed Jan 25, 2025
1 parent 3032d89 commit f1d3534
Showing 1 changed file with 46 additions and 12 deletions.
58 changes: 46 additions & 12 deletions LibreMetaverse/AppearanceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ public bool ServerBakingRegion()

/// <summary>
/// Returns a List of worn items in COF. Also populates <see cref="Wearables"/>
/// and fires <see cref="OnAgentWearables"/>
/// and <see cref="Attachments"/> before firing <see cref="OnAgentWearables"/>
/// </summary>
/// <returns><see cref="List{T}"/> of <see cref="InventoryBase"/> in COF</returns>
public List<InventoryBase> RequestAgentWorn()
Expand All @@ -619,7 +619,7 @@ public List<InventoryBase> RequestAgentWorn()
return null;
}
// Fetch from cache...
List<InventoryBase> contents = Client.Inventory.Store.GetContents(cof.UUID);
var contents = Client.Inventory.Store.GetContents(cof.UUID);

// If that fails, fetch from server...
if (contents == null || contents.Count == 0)
Expand All @@ -631,20 +631,44 @@ public List<InventoryBase> RequestAgentWorn()
var wearables = new MultiValueDictionary<WearableType, WearableData>();
foreach (var item in contents)
{
if (item is InventoryWearable wearable)
switch (item)
{
InventoryWearable w = wearable;
if (wearable.IsLink() && Client.Inventory.Store.Contains(wearable.ActualUUID))
case InventoryWearable wearable:
{
w = Client.Inventory.Store[wearable.AssetUUID] as InventoryWearable;
var w = wearable;
if (wearable.IsLink() && Client.Inventory.Store.Contains(wearable.ActualUUID))
{
w = Client.Inventory.Store[wearable.ActualUUID] as InventoryWearable;
}
wearables.Add(w.WearableType, new WearableData()
{
ItemID = w.UUID,
AssetID = w.ActualUUID,
AssetType = w.AssetType,
WearableType = w.WearableType
});
break;
}
case InventoryAttachment attachment:
{
var a = attachment;
if (attachment.IsLink() && Client.Inventory.Store.Contains(attachment.ActualUUID))
{
a = Client.Inventory.Store[attachment.ActualUUID] as InventoryAttachment;
}
Attachments.AddOrUpdate(a.ActualUUID, a.AttachmentPoint, (id, point) => a.AttachmentPoint);
break;
}
wearables.Add(w.WearableType, new WearableData()
case InventoryObject attachedObject:
{
ItemID = w.UUID,
AssetID = w.AssetUUID,
AssetType = w.AssetType,
WearableType = w.WearableType
});
var a = attachedObject;
if (attachedObject.IsLink() && Client.Inventory.Store.Contains(attachedObject.ActualUUID))
{
a = Client.Inventory.Store[attachedObject.ActualUUID] as InventoryObject;
}
Attachments.AddOrUpdate(a.ActualUUID, a.AttachPoint, (id, point) => a.AttachPoint);
break;
}
}
}
lock (Wearables) { Wearables = wearables; }
Expand Down Expand Up @@ -1228,6 +1252,16 @@ private bool GatherAgentAttachments()
return true;
}

public bool isItemAttached(InventoryItem item)
{
return isItemAttached(item.ActualUUID);
}

public bool isItemAttached(UUID key)
{
return Attachments.ContainsKey(key);
}

/// <summary>
/// Returns a collection of the agents currently worn attachments
/// </summary>
Expand Down

0 comments on commit f1d3534

Please sign in to comment.