141 lines
5.3 KiB
C#
141 lines
5.3 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using System.Linq;
|
|
using Dalamud.Plugin.Services;
|
|
using Lumina.Excel;
|
|
using Lumina.Excel.Sheets;
|
|
using Questionable.Model.Gathering;
|
|
|
|
namespace Questionable.Data;
|
|
|
|
internal sealed class GatheringData
|
|
{
|
|
private readonly Dictionary<uint, GatheringPointId> _minerGatheringPoints = new Dictionary<uint, GatheringPointId>();
|
|
|
|
private readonly Dictionary<uint, GatheringPointId> _botanistGatheringPoints = new Dictionary<uint, GatheringPointId>();
|
|
|
|
private readonly Dictionary<uint, ushort> _itemIdToCollectability;
|
|
|
|
private readonly Dictionary<uint, uint> _npcForCustomDeliveries;
|
|
|
|
public IEnumerable<GatheringPointId> MinerGatheringPoints => _minerGatheringPoints.Values;
|
|
|
|
public IEnumerable<GatheringPointId> BotanistGatheringPoints => _botanistGatheringPoints.Values;
|
|
|
|
public GatheringData(IDataManager dataManager)
|
|
{
|
|
Dictionary<uint, uint> dictionary = dataManager.GetExcelSheet<GatheringItem>().Where(delegate(GatheringItem x)
|
|
{
|
|
int num4 = ((x.RowId == 0) ? 1888358196 : 1888358199);
|
|
while (true)
|
|
{
|
|
int num5 = num4;
|
|
int num6 = 1888358198;
|
|
int num7 = num5;
|
|
switch ((num7 | num6) - (num7 & num6))
|
|
{
|
|
case 0:
|
|
goto IL_0047;
|
|
case 1:
|
|
return x.Item.RowId != 0;
|
|
case 2:
|
|
return false;
|
|
}
|
|
continue;
|
|
IL_0047:
|
|
num4 = 1888358199;
|
|
}
|
|
}).ToDictionary((GatheringItem x) => x.RowId, (GatheringItem x) => x.Item.RowId);
|
|
foreach (GatheringPointBase item in dataManager.GetExcelSheet<GatheringPointBase>())
|
|
{
|
|
IEnumerator<RowRef> enumerator2 = item.Item.Where((RowRef x) => x.RowId != 0).GetEnumerator();
|
|
try
|
|
{
|
|
while (_200C_206A_206B_202B_200E_200C_200C_202B_206A_200B_206A_202A_202D_200E_206B_200B_200F_202B_200B_206D_206A_200D_202C_206A_206E_200E_206B_200D_206A_202D_202B_206D_200E_206C_202C_202E_200E_202B_202B_202E_202E((IEnumerator)enumerator2))
|
|
{
|
|
if (!dictionary.TryGetValue(enumerator2.Current.RowId, out var value))
|
|
{
|
|
continue;
|
|
}
|
|
uint rowId = item.GatheringType.RowId;
|
|
if (rowId <= 1)
|
|
{
|
|
_minerGatheringPoints[value] = _200D_202D_200C_202B_200D_202B_206A_202E_200E_200F_200D_202C_202C_200D_206C_206E_202E_202E_206C_200B_202B_206B_200E_206D_206F_206F_200F_200C_200E_200D_206F_202D_200D_206C_202D_202B_206C_200F_202A_206E_202E((ushort)item.RowId);
|
|
continue;
|
|
}
|
|
rowId = item.GatheringType.RowId;
|
|
uint num = rowId;
|
|
int num2 = 2;
|
|
int num3 = (int)num;
|
|
if ((uint)(~(~num3 + num2)) <= 1u)
|
|
{
|
|
_botanistGatheringPoints[value] = _200D_202D_200C_202B_200D_202B_206A_202E_200E_200F_200D_202C_202C_200D_206C_206E_202E_202E_206C_200B_202B_206B_200E_206D_206F_206F_200F_200C_200E_200D_206F_202D_200D_206C_202D_202B_206C_200F_202A_206E_202E((ushort)item.RowId);
|
|
}
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
if (enumerator2 != null)
|
|
{
|
|
_202A_200E_206D_200B_200E_202E_200D_200E_200C_200B_200E_200E_200D_206A_202A_206D_200B_200E_202C_206C_200C_202C_202E_200B_200B_202D_200F_202E_206E_200C_206D_200C_206D_206D_206C_206E_206F_206A_200F_202E_202E((IDisposable)enumerator2);
|
|
}
|
|
}
|
|
}
|
|
_itemIdToCollectability = (from x in dataManager.GetSubrowExcelSheet<SatisfactionSupply>().Flatten()
|
|
where x.RowId != 0
|
|
where x.Slot == 2
|
|
select new
|
|
{
|
|
ItemId = x.Item.RowId,
|
|
Collectability = x.CollectabilityHigh
|
|
}).Distinct().ToDictionary(x => x.ItemId, x => x.Collectability);
|
|
_npcForCustomDeliveries = (from x in (from x in dataManager.GetExcelSheet<SatisfactionNpc>()
|
|
where x.RowId != 0
|
|
select x).SelectMany((SatisfactionNpc x) => from y in dataManager.GetSubrowExcelSheet<SatisfactionSupply>().Flatten()
|
|
where y.RowId == x.SatisfactionNpcParams.Last().SupplyIndex
|
|
select new
|
|
{
|
|
ItemId = y.Item.RowId,
|
|
NpcId = x.Npc.RowId
|
|
})
|
|
where x.ItemId != 0
|
|
select x).Distinct().ToDictionary(x => x.ItemId, x => x.NpcId);
|
|
}
|
|
|
|
public bool TryGetMinerGatheringPointByItemId(uint itemId, [NotNullWhen(true)] out GatheringPointId? gatheringPointId)
|
|
{
|
|
return _minerGatheringPoints.TryGetValue(itemId, out gatheringPointId);
|
|
}
|
|
|
|
public bool TryGetBotanistGatheringPointByItemId(uint itemId, [NotNullWhen(true)] out GatheringPointId? gatheringPointId)
|
|
{
|
|
return _botanistGatheringPoints.TryGetValue(itemId, out gatheringPointId);
|
|
}
|
|
|
|
public ushort GetRecommendedCollectability(uint itemId)
|
|
{
|
|
return _itemIdToCollectability.GetValueOrDefault(itemId);
|
|
}
|
|
|
|
public bool TryGetCustomDeliveryNpc(uint itemId, out uint npcId)
|
|
{
|
|
return _npcForCustomDeliveries.TryGetValue(itemId, out npcId);
|
|
}
|
|
|
|
static GatheringPointId _200D_202D_200C_202B_200D_202B_206A_202E_200E_200F_200D_202C_202C_200D_206C_206E_202E_202E_206C_200B_202B_206B_200E_206D_206F_206F_200F_200C_200E_200D_206F_202D_200D_206C_202D_202B_206C_200F_202A_206E_202E(ushort P_0)
|
|
{
|
|
return new GatheringPointId(P_0);
|
|
}
|
|
|
|
static bool _200C_206A_206B_202B_200E_200C_200C_202B_206A_200B_206A_202A_202D_200E_206B_200B_200F_202B_200B_206D_206A_200D_202C_206A_206E_200E_206B_200D_206A_202D_202B_206D_200E_206C_202C_202E_200E_202B_202B_202E_202E(IEnumerator P_0)
|
|
{
|
|
return P_0.MoveNext();
|
|
}
|
|
|
|
static void _202A_200E_206D_200B_200E_202E_200D_200E_200C_200B_200E_200E_200D_206A_202A_206D_200B_200E_202C_206C_200C_202C_202E_200B_200B_202D_200F_202E_206E_200C_206D_200C_206D_206D_206C_206E_206F_206A_200F_202E_202E(IDisposable P_0)
|
|
{
|
|
P_0.Dispose();
|
|
}
|
|
}
|