using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using Dalamud.Plugin.Services; using Lumina.Excel.Sheets; using Questionable.Model; using Questionable.Model.Questing; namespace Questionable.Controller.CustomDelivery; internal sealed class CustomDeliveryNpcData { private readonly List _npcs; private readonly Dictionary _npcsByRowId; public IReadOnlyList AllNpcs => _npcs; public CustomDeliveryNpcData(IDataManager dataManager) { _npcs = (from x in dataManager.GetExcelSheet() where x.RowId != 0 && x.Npc.RowId != 0 select new CustomDeliveryNpc((int)(x.RowId - 1), (ushort)x.RowId, x.Npc.Value.Singular.ToString(), x.LevelUnlock, (EExpansionVersion)x.QuestRequired.Value.Expansion.RowId, QuestId.FromRowId(x.QuestRequired.RowId))).ToList(); _npcsByRowId = _npcs.ToDictionary((CustomDeliveryNpc x) => x.NpcRowId); } public bool TryGetByRowId(ushort npcRowId, [NotNullWhen(true)] out CustomDeliveryNpc? npc) { return _npcsByRowId.TryGetValue(npcRowId, out npc); } }