using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using Dalamud.Plugin.Services; using Lumina.Excel; using Lumina.Excel.Sheets; namespace Questionable.Data; internal sealed class FishingData { private readonly Dictionary _itemToSpot; public FishingData(IDataManager dataManager) { ExcelSheet excelSheet = dataManager.GetExcelSheet(); Dictionary dictionary = new Dictionary(); foreach (FishingSpot item in excelSheet) { if (item.RowId == 0 || item.TerritoryType.RowId == 0) { continue; } FishingSpotInfo value = new FishingSpotInfo(item.RowId, (ushort)item.TerritoryType.RowId, item.X, item.Z, item.GatheringLevel); foreach (RowRef item2 in item.Item) { if (item2.RowId != 0 && (!dictionary.TryGetValue(item2.RowId, out var value2) || value2.GatheringLevel > value.GatheringLevel)) { dictionary[item2.RowId] = value; } } } _itemToSpot = dictionary; } public bool TryGetFishingSpot(uint itemId, [NotNullWhen(true)] out FishingSpotInfo? spot) { if (_itemToSpot.TryGetValue(itemId, out var value)) { spot = value; return true; } spot = null; return false; } }