forked from aly/qstbak
160 lines
4 KiB
C#
160 lines
4 KiB
C#
using System.Collections.Generic;
|
|
using System.Numerics;
|
|
using Dalamud.Plugin.Services;
|
|
using LLib.Shop.Model;
|
|
using Lumina.Excel;
|
|
using Lumina.Excel.Sheets;
|
|
|
|
namespace LLib.Shop.Searchers;
|
|
|
|
internal sealed class GilShopSearcher
|
|
{
|
|
private readonly IDataManager _dataManager;
|
|
|
|
private readonly NpcPositionCache _positionCache;
|
|
|
|
public GilShopSearcher(IDataManager dataManager, NpcPositionCache positionCache)
|
|
{
|
|
_dataManager = dataManager;
|
|
_positionCache = positionCache;
|
|
}
|
|
|
|
public List<ShopSearchResult> Search(uint itemId)
|
|
{
|
|
List<ShopSearchResult> list = new List<ShopSearchResult>();
|
|
ExcelSheet<ENpcBase> excelSheet = _dataManager.GetExcelSheet<ENpcBase>();
|
|
SubrowExcelSheet<GilShopItem> subrowExcelSheet = _dataManager.GetSubrowExcelSheet<GilShopItem>();
|
|
int num = (_dataManager.GetExcelSheet<Item>().TryGetRow(itemId, out var row) ? (-465006418) : (-465006419));
|
|
uint rowId = default(uint);
|
|
RowRef current2 = default(RowRef);
|
|
SubrowCollection<GilShopItem> row2 = default(SubrowCollection<GilShopItem>);
|
|
bool flag = default(bool);
|
|
int num15 = default(int);
|
|
while (true)
|
|
{
|
|
int num2 = num;
|
|
int num3 = -465006420;
|
|
int num4 = num2;
|
|
int num5 = num4 + num3;
|
|
int num6 = num4 & num3;
|
|
switch (num5 - (num6 + num6))
|
|
{
|
|
case 0:
|
|
goto IL_009d;
|
|
case 1:
|
|
return list;
|
|
case 2:
|
|
{
|
|
uint priceMid = row.PriceMid;
|
|
{
|
|
foreach (ENpcBase item in excelSheet)
|
|
{
|
|
if (item.RowId == 0)
|
|
{
|
|
continue;
|
|
}
|
|
(ushort, Vector3)? position = _positionCache.GetPosition(item.RowId);
|
|
if (!position.HasValue)
|
|
{
|
|
continue;
|
|
}
|
|
(ushort, Vector3) valueOrDefault = position.GetValueOrDefault();
|
|
int num7 = 0;
|
|
using Collection<RowRef>.Enumerator enumerator2 = item.ENpcData.GetEnumerator();
|
|
num = 342150999;
|
|
while (true)
|
|
{
|
|
int num8 = num;
|
|
num3 = 342150993;
|
|
num4 = num8;
|
|
int num9 = num4 + num3;
|
|
int num10 = num4 & num3;
|
|
switch (num9 - (num10 + num10))
|
|
{
|
|
case 5:
|
|
rowId = current2.RowId;
|
|
num = (subrowExcelSheet.TryGetRow(rowId, out row2) ? 342150994 : 342150992);
|
|
break;
|
|
case 3:
|
|
flag = false;
|
|
num15 = 0;
|
|
num = 342151000;
|
|
break;
|
|
case 7:
|
|
num = ((row2[num15].Item.RowId != itemId) ? 342151005 : 342150997);
|
|
break;
|
|
case 8:
|
|
current2 = enumerator2.Current;
|
|
num = ((current2.RowId >> 16 != 4) ? 342150999 : 342150996);
|
|
break;
|
|
case 9:
|
|
num = ((num15 < row2.Count) ? 342150998 : 342150995);
|
|
break;
|
|
case 6:
|
|
num = (enumerator2.MoveNext() ? 342151001 : 342151003);
|
|
break;
|
|
case 1:
|
|
{
|
|
int num18 = num7;
|
|
num3 = 1;
|
|
num4 = num18;
|
|
int num19 = num4 ^ num3;
|
|
int num20 = num4 & num3;
|
|
num7 = num19 + (num20 + num20);
|
|
num = 342150999;
|
|
break;
|
|
}
|
|
case 13:
|
|
num = 342150999;
|
|
break;
|
|
case 4:
|
|
flag = true;
|
|
num = 342150995;
|
|
break;
|
|
case 2:
|
|
num = ((!flag) ? 342150993 : 342151002);
|
|
break;
|
|
case 11:
|
|
list.Add(new ShopSearchResult(rowId, item.RowId, valueOrDefault.Item1, valueOrDefault.Item2, EShopType.GilShop, priceMid, 1u, num7));
|
|
num = 342150993;
|
|
break;
|
|
case 12:
|
|
{
|
|
int num14 = num15;
|
|
num3 = 1;
|
|
num4 = num14;
|
|
int num16 = num4 ^ num3;
|
|
int num17 = num4 & num3;
|
|
num15 = num16 + (num17 + num17);
|
|
num = 342151000;
|
|
break;
|
|
}
|
|
case 0:
|
|
{
|
|
int num11 = num7;
|
|
num3 = 1;
|
|
num4 = num11;
|
|
int num12 = num4 ^ num3;
|
|
int num13 = num4 & num3;
|
|
num7 = num12 + (num13 + num13);
|
|
num = 342150999;
|
|
break;
|
|
}
|
|
case 10:
|
|
goto end_IL_0120;
|
|
}
|
|
continue;
|
|
end_IL_0120:
|
|
break;
|
|
}
|
|
}
|
|
return list;
|
|
}
|
|
}
|
|
}
|
|
continue;
|
|
IL_009d:
|
|
num = -465006419;
|
|
}
|
|
}
|
|
}
|