feat(D.5.1): ItemRepository.EnrichItem (icon/name/type from CreateObject)
Adds EnrichItem(objectId, iconId, name, type) — enriches an existing stub created from PlayerDescription with the fuller data carried by its CreateObject message. Returns false when the item isn't tracked yet (phase 1: enrich-existing only). Raises ItemPropertiesUpdated on success so bound widgets (the toolbar) re-render. Two xUnit tests: enrich-existing updates IconId/Name/raises event (true), unknown-id returns false. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
da171cb4e3
commit
f8da98b67f
2 changed files with 40 additions and 0 deletions
|
|
@ -136,6 +136,23 @@ public sealed class ItemRepository
|
|||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enrich an already-known item (a stub created from PlayerDescription) with the
|
||||
/// fuller data carried by its CreateObject (icon, name, type). Returns false if the
|
||||
/// item isn't tracked yet — phase 1 enriches existing items only; full
|
||||
/// CreateObject ingestion of newly-acquired items is the inventory phase.
|
||||
/// Raises ItemPropertiesUpdated on success so bound widgets (the toolbar) re-render.
|
||||
/// </summary>
|
||||
public bool EnrichItem(uint objectId, uint iconId, string name, ItemType type)
|
||||
{
|
||||
if (!_items.TryGetValue(objectId, out var item)) return false;
|
||||
if (iconId != 0) item.IconId = iconId;
|
||||
if (!string.IsNullOrEmpty(name)) item.Name = name;
|
||||
if (type != default) item.Type = type;
|
||||
ItemPropertiesUpdated?.Invoke(item);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Apply a <see cref="PropertyBundle"/> patch (e.g. from an
|
||||
/// <c>IdentifyObjectResponse</c>) to an existing item. Individual
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue