qstbak/Questionable/Questionable.Data/FishingData.cs
2026-08-17 20:27:25 +10:00

62 lines
1.6 KiB
C#

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<uint, FishingSpotInfo> _itemToSpot;
public FishingData(IDataManager dataManager)
{
ExcelSheet<FishingSpot> excelSheet = dataManager.GetExcelSheet<FishingSpot>();
Dictionary<uint, FishingSpotInfo> dictionary = new Dictionary<uint, FishingSpotInfo>();
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<Item> 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)
{
FishingSpotInfo value;
int num = ((!_itemToSpot.TryGetValue(itemId, out value)) ? 254023319 : 254023316);
while (true)
{
int num2 = num;
int num3 = 254023318;
int num4 = num2;
int num5 = num4 + num3;
int num6 = num4 & num3;
switch (num5 - (num6 + num6))
{
case 1:
spot = null;
return false;
case 2:
spot = value;
return true;
case 0:
goto IL_0067;
}
continue;
IL_0067:
num = 254023316;
}
}
}