punish v6.8.18.0
This commit is contained in:
commit
cfb4dea47e
316 changed files with 554088 additions and 0 deletions
91
Questionable/Questionable.Data/GatheringData.cs
Normal file
91
Questionable/Questionable.Data/GatheringData.cs
Normal file
|
@ -0,0 +1,91 @@
|
|||
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 = (from x in dataManager.GetExcelSheet<GatheringItem>()
|
||||
where x.RowId != 0 && x.Item.RowId != 0
|
||||
select x).ToDictionary((GatheringItem x) => x.RowId, (GatheringItem x) => x.Item.RowId);
|
||||
foreach (GatheringPointBase item in dataManager.GetExcelSheet<GatheringPointBase>())
|
||||
{
|
||||
foreach (RowRef item2 in item.Item.Where((RowRef x) => x.RowId != 0))
|
||||
{
|
||||
if (!dictionary.TryGetValue(item2.RowId, out var value))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
uint rowId = item.GatheringType.RowId;
|
||||
if (rowId <= 1)
|
||||
{
|
||||
_minerGatheringPoints[value] = new GatheringPointId((ushort)item.RowId);
|
||||
continue;
|
||||
}
|
||||
rowId = item.GatheringType.RowId;
|
||||
if (rowId - 2 <= 1)
|
||||
{
|
||||
_botanistGatheringPoints[value] = new GatheringPointId((ushort)item.RowId);
|
||||
}
|
||||
}
|
||||
}
|
||||
_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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue