using System; using System.Collections.Generic; namespace AcDream.Core.Items; /// /// Mutable client-side model of the 18 toolbar shortcut slots — port of retail /// ShortCutManager::shortCuts_[18] (acclient.h:36492). Holds the bound object guid per /// slot (0 = empty). Loaded from the login shortcut list, then mutated by drag-drop (lift /// removes, drop places); the server is notified via AddShortcut/RemoveShortcut so the store /// stays the client's source of truth within a session (retail: client owns the array). /// Item shortcuts only — entries with ObjGuid 0 (spell-only) are skipped on Load. Pure model /// (no Core.Net dependency): callers project their wire entries to (slot, objGuid) pairs. /// public sealed class ShortcutStore { public const int SlotCount = 18; private readonly uint[] _objIds = new uint[SlotCount]; /// Replace all slots from a (slot, objectGuid) sequence (item entries only; /// ObjGuid 0 and out-of-range slots are skipped). public void Load(IEnumerable<(int Slot, uint ObjGuid)> entries) { Array.Clear(_objIds); foreach (var (slot, objGuid) in entries) if ((uint)slot < SlotCount && objGuid != 0) _objIds[slot] = objGuid; } /// Bound object guid at , or 0 (empty / out of range). public uint Get(int slot) => (uint)slot < SlotCount ? _objIds[slot] : 0u; public bool IsEmpty(int slot) => Get(slot) == 0u; public void Set(int slot, uint objId) { if ((uint)slot < SlotCount) _objIds[slot] = objId; } public void Remove(int slot) { if ((uint)slot < SlotCount) _objIds[slot] = 0u; } }