feat(ui): port retail selected-item mana

Parse and route the complete 0x0264 guid/fraction/valid response, send exact 0x0263 item-mana queries, and reproduce retail meter visibility plus guid-zero cancellation for mana and health selection changes. Keep the behavior in Core state and the retained selected-object controller with wire/state/UI conformance coverage.

Co-Authored-By: Codex <codex@openai.com>
This commit is contained in:
Erik 2026-07-11 11:16:21 +02:00
parent df460f94c3
commit fa1da02783
21 changed files with 402 additions and 38 deletions

View file

@ -0,0 +1,35 @@
using System;
using System.Collections.Concurrent;
namespace AcDream.Core.Items;
/// <summary>
/// Last server-reported mana fraction for queried inventory items.
/// Retail routes <c>QueryItemManaResponse (0x0264)</c> through
/// <c>ClientUISystem::Handle_Item__QueryItemManaResponse @ 0x00563FE0</c>, including
/// the response's validity flag, before notifying the selected-object toolbar.
/// </summary>
public sealed class ItemManaState
{
private readonly ConcurrentDictionary<uint, float> _manaByGuid = new();
/// <summary>Fires for every valid or invalid query response.</summary>
public event Action<uint /*guid*/, float /*fraction*/, bool /*valid*/>? ItemManaChanged;
public float GetManaPercent(uint guid) =>
_manaByGuid.TryGetValue(guid, out float percent) ? percent : 0f;
public bool HasMana(uint guid) => _manaByGuid.ContainsKey(guid);
public void OnQueryItemManaResponse(uint itemGuid, float manaPercent, bool valid)
{
if (valid)
_manaByGuid[itemGuid] = manaPercent;
else
_manaByGuid.TryRemove(itemGuid, out _);
ItemManaChanged?.Invoke(itemGuid, manaPercent, valid);
}
public void Clear() => _manaByGuid.Clear();
}