forked from aly/qstbak
274 lines
7.6 KiB
C#
274 lines
7.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Numerics;
|
|
using System.Runtime.CompilerServices;
|
|
using Dalamud.Plugin.Services;
|
|
using LLib.Shop.Model;
|
|
using Lumina.Excel;
|
|
using Lumina.Excel.Sheets;
|
|
|
|
namespace LLib.Shop.Searchers;
|
|
|
|
internal sealed class GCShopSearcher
|
|
{
|
|
private static readonly uint[] SealItemIds;
|
|
|
|
private static readonly uint[] QuartermasterNpcIds;
|
|
|
|
private readonly IDataManager _dataManager;
|
|
|
|
private readonly NpcPositionCache _positionCache;
|
|
|
|
public GCShopSearcher(IDataManager dataManager, NpcPositionCache positionCache)
|
|
{
|
|
_dataManager = dataManager;
|
|
_positionCache = positionCache;
|
|
}
|
|
|
|
public List<ShopSearchResult> Search(uint itemId)
|
|
{
|
|
List<ShopSearchResult> list = new List<ShopSearchResult>();
|
|
SubrowExcelSheet<GCScripShopItem> subrowExcelSheet = _dataManager.GetSubrowExcelSheet<GCScripShopItem>();
|
|
ExcelSheet<GCScripShopCategory> excelSheet = _dataManager.GetExcelSheet<GCScripShopCategory>();
|
|
ExcelSheet<GCShop> excelSheet2 = _dataManager.GetExcelSheet<GCShop>();
|
|
Dictionary<uint, uint> dictionary = new Dictionary<uint, uint>();
|
|
int num;
|
|
using (ExcelSheet<GCShop>.Enumerator enumerator = excelSheet2.GetEnumerator())
|
|
{
|
|
num = 1051383977;
|
|
uint rowId = default(uint);
|
|
GCShop current = default(GCShop);
|
|
while (true)
|
|
{
|
|
int num2 = num;
|
|
int num3 = 1051383979;
|
|
int num4 = num2;
|
|
switch ((num4 | num3) - (num4 & num3))
|
|
{
|
|
case 0:
|
|
num = 1051383977;
|
|
break;
|
|
case 2:
|
|
num = (enumerator.MoveNext() ? 1051383983 : 1051383976);
|
|
break;
|
|
case 1:
|
|
dictionary.TryAdd(rowId, current.RowId);
|
|
num = 1051383977;
|
|
break;
|
|
case 4:
|
|
current = enumerator.Current;
|
|
rowId = current.GrandCompany.RowId;
|
|
num = ((rowId == 0) ? 1051383977 : 1051383978);
|
|
break;
|
|
case 3:
|
|
goto end_IL_0063;
|
|
}
|
|
continue;
|
|
end_IL_0063:
|
|
break;
|
|
}
|
|
}
|
|
Dictionary<uint, uint> dictionary2 = new Dictionary<uint, uint>();
|
|
using (SubrowExcelSheet<GCScripShopItem>.Enumerator enumerator2 = subrowExcelSheet.GetEnumerator())
|
|
{
|
|
num = 754964801;
|
|
uint num8 = default(uint);
|
|
uint value2 = default(uint);
|
|
uint rowId3 = default(uint);
|
|
uint value = default(uint);
|
|
SubrowCollection<GCScripShopItem> current2 = default(SubrowCollection<GCScripShopItem>);
|
|
uint rowId2 = default(uint);
|
|
int num7 = default(int);
|
|
GCScripShopCategory row = default(GCScripShopCategory);
|
|
uint costGCSeals = default(uint);
|
|
GCScripShopItem gCScripShopItem = default(GCScripShopItem);
|
|
while (true)
|
|
{
|
|
int num5 = num;
|
|
int num3 = 754964806;
|
|
int num4 = num5;
|
|
switch ((num4 | num3) - (num4 & num3))
|
|
{
|
|
case 17:
|
|
num8 = 1u;
|
|
num = 754964805;
|
|
break;
|
|
case 2:
|
|
num = ((!dictionary2.TryGetValue(num8, out value2)) ? 754964815 : 754964813);
|
|
break;
|
|
case 6:
|
|
num = ((!dictionary2.TryGetValue(rowId3, out value)) ? 754964803 : 754964822);
|
|
break;
|
|
case 13:
|
|
current2 = enumerator2.Current;
|
|
rowId2 = current2.RowId;
|
|
num7 = 0;
|
|
num = 754964808;
|
|
break;
|
|
case 10:
|
|
{
|
|
uint num9 = num8;
|
|
num3 = 1;
|
|
num4 = (int)num9;
|
|
int num10 = num4 ^ num3;
|
|
int num11 = num4 & num3;
|
|
num8 = (uint)(num10 + (num11 + num11));
|
|
num = 754964805;
|
|
break;
|
|
}
|
|
case 0:
|
|
rowId3 = row.GrandCompany.RowId;
|
|
num = ((rowId3 != 0) ? 754964800 : 754964823);
|
|
break;
|
|
case 14:
|
|
num = ((num7 < current2.Count) ? 754964809 : 754964801);
|
|
break;
|
|
case 1:
|
|
costGCSeals = gCScripShopItem.CostGCSeals;
|
|
num = ((!excelSheet.TryGetRow(rowId2, out row)) ? 754964810 : 754964806);
|
|
break;
|
|
case 8:
|
|
num = 754964810;
|
|
break;
|
|
case 9:
|
|
dictionary2[num8] = costGCSeals;
|
|
num = 754964812;
|
|
break;
|
|
case 7:
|
|
num = (enumerator2.MoveNext() ? 754964811 : 754964820);
|
|
break;
|
|
case 4:
|
|
num = 754964801;
|
|
break;
|
|
case 11:
|
|
num = ((costGCSeals >= value2) ? 754964812 : 754964815);
|
|
break;
|
|
case 5:
|
|
dictionary2[rowId3] = costGCSeals;
|
|
num = 754964810;
|
|
break;
|
|
case 3:
|
|
num = ((num8 < (uint)QuartermasterNpcIds.Length) ? 754964804 : 754964814);
|
|
break;
|
|
case 16:
|
|
num = ((costGCSeals >= value) ? 754964810 : 754964803);
|
|
break;
|
|
case 15:
|
|
gCScripShopItem = current2[num7];
|
|
num = ((gCScripShopItem.Item.RowId != itemId) ? 754964810 : 754964807);
|
|
break;
|
|
case 12:
|
|
{
|
|
int num6 = num7;
|
|
num3 = 1;
|
|
num4 = num6;
|
|
num7 = (num4 | num3) + (num4 & num3);
|
|
num = 754964808;
|
|
break;
|
|
}
|
|
case 18:
|
|
goto end_IL_014c;
|
|
}
|
|
continue;
|
|
end_IL_014c:
|
|
break;
|
|
}
|
|
}
|
|
num = ((dictionary2.Count != 0) ? (-231383589) : (-231383590));
|
|
(ushort, Vector3)? position = default((ushort, Vector3)?);
|
|
uint num14 = default(uint);
|
|
uint num16 = default(uint);
|
|
uint price = default(uint);
|
|
uint currencyItemId = default(uint);
|
|
while (true)
|
|
{
|
|
int num12 = num;
|
|
int num3 = -231383589;
|
|
int num4 = num12;
|
|
switch ((num4 | num3) - (num4 & num3))
|
|
{
|
|
case 2:
|
|
goto IL_046f;
|
|
case 1:
|
|
return list;
|
|
case 0:
|
|
{
|
|
using Dictionary<uint, uint>.Enumerator enumerator3 = dictionary2.GetEnumerator();
|
|
num = 1589717565;
|
|
while (true)
|
|
{
|
|
int num13 = num;
|
|
num3 = 1589717566;
|
|
num4 = num13;
|
|
int num15;
|
|
switch ((num4 | num3) - (num4 & num3))
|
|
{
|
|
case 6:
|
|
{
|
|
(ushort, Vector3) valueOrDefault = position.GetValueOrDefault();
|
|
dictionary.TryGetValue(num14, out var value3);
|
|
list.Add(new ShopSearchResult(value3, num16, valueOrDefault.Item1, valueOrDefault.Item2, EShopType.GCShop, price, currencyItemId));
|
|
num = 1589717565;
|
|
break;
|
|
}
|
|
case 1:
|
|
num15 = 0;
|
|
goto IL_0563;
|
|
case 7:
|
|
num = 1589717565;
|
|
break;
|
|
case 3:
|
|
num = (enumerator3.MoveNext() ? 1589717564 : 1589717563);
|
|
break;
|
|
case 0:
|
|
num15 = (int)SealItemIds[num14];
|
|
goto IL_0563;
|
|
case 2:
|
|
{
|
|
enumerator3.Current.Deconstruct(out var key, out var value4);
|
|
num14 = key;
|
|
price = value4;
|
|
num = ((num14 >= (uint)QuartermasterNpcIds.Length) ? 1589717565 : 1589717562);
|
|
break;
|
|
}
|
|
case 4:
|
|
num16 = QuartermasterNpcIds[num14];
|
|
num = ((num16 == 0) ? 1589717565 : 1589717558);
|
|
break;
|
|
case 8:
|
|
num = ((num14 < (uint)SealItemIds.Length) ? 1589717566 : 1589717567);
|
|
break;
|
|
case 5:
|
|
{
|
|
return list;
|
|
}
|
|
IL_0563:
|
|
currencyItemId = (uint)num15;
|
|
position = _positionCache.GetPosition(num16);
|
|
num = ((!position.HasValue) ? 1589717565 : 1589717560);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
continue;
|
|
IL_046f:
|
|
num = -231383590;
|
|
}
|
|
}
|
|
|
|
static GCShopSearcher()
|
|
{
|
|
uint[] array = new uint[4];
|
|
_200F_206D_202A_206E_202D_200C_206D_200D_200B_202E_202B_206B_206B_206E_202B_206A_202B_206D_202C_200E_206F_200C_200B_202B_200C_202B_206C_202C_202E_200F_206D_200B_202B_202B_206E_206B_206A_200D_206A_200F_202E((Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
|
|
SealItemIds = array;
|
|
uint[] array2 = new uint[4];
|
|
_200F_206D_202A_206E_202D_200C_206D_200D_200B_202E_202B_206B_206B_206E_202B_206A_202B_206D_202C_200E_206F_200C_200B_202B_200C_202B_206C_202C_202E_200F_206D_200B_202B_202B_206E_206B_206A_200D_206A_200F_202E((Array)array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
|
|
QuartermasterNpcIds = array2;
|
|
}
|
|
|
|
static void _200F_206D_202A_206E_202D_200C_206D_200D_200B_202E_202B_206B_206B_206E_202B_206A_202B_206D_202C_200E_206F_200C_200B_202B_200C_202B_206C_202C_202E_200F_206D_200B_202B_202B_206E_206B_206A_200D_206A_200F_202E(Array P_0, RuntimeFieldHandle P_1)
|
|
{
|
|
RuntimeHelpers.InitializeArray(P_0, P_1);
|
|
}
|
|
}
|