117 lines
2.6 KiB
C#
117 lines
2.6 KiB
C#
using System.Collections.Generic;
|
|
using Dalamud.Plugin.Services;
|
|
using LLib.Shop.Model;
|
|
using LLib.Shop.Searchers;
|
|
|
|
namespace LLib.Shop;
|
|
|
|
public sealed class VendorResolver
|
|
{
|
|
private readonly GilShopSearcher _gilShopSearcher;
|
|
|
|
private readonly SpecialShopSearcher _specialShopSearcher;
|
|
|
|
private readonly GCShopSearcher _gcShopSearcher;
|
|
|
|
public VendorResolver(IDataManager dataManager, NpcPositionCache positionCache)
|
|
{
|
|
_gilShopSearcher = new GilShopSearcher(dataManager, positionCache);
|
|
_specialShopSearcher = new SpecialShopSearcher(dataManager, positionCache);
|
|
_gcShopSearcher = new GCShopSearcher(dataManager, positionCache);
|
|
}
|
|
|
|
public IReadOnlyList<ShopSearchResult> FindVendorsForItem(uint itemId)
|
|
{
|
|
List<ShopSearchResult> list = new List<ShopSearchResult>();
|
|
list.AddRange(_gilShopSearcher.Search(itemId));
|
|
list.AddRange(_specialShopSearcher.Search(itemId));
|
|
list.AddRange(_gcShopSearcher.Search(itemId));
|
|
return list;
|
|
}
|
|
|
|
public IReadOnlyList<ShopSearchResult> FindVendorsForItem(uint itemId, EShopType shopType)
|
|
{
|
|
int num;
|
|
List<ShopSearchResult> result = default(List<ShopSearchResult>);
|
|
switch (shopType)
|
|
{
|
|
default:
|
|
num = -1685291890;
|
|
goto IL_001d;
|
|
case EShopType.SpecialShop:
|
|
result = _specialShopSearcher.Search(itemId);
|
|
num = -1685291895;
|
|
goto IL_001d;
|
|
case EShopType.GCShop:
|
|
goto IL_006c;
|
|
case EShopType.GilShop:
|
|
goto IL_00ab;
|
|
IL_001d:
|
|
while (true)
|
|
{
|
|
int num2 = num;
|
|
int num3 = -1685291889;
|
|
int num4 = num2;
|
|
switch ((num4 | num3) - (num4 & num3))
|
|
{
|
|
case 6:
|
|
return result;
|
|
case 4:
|
|
goto end_IL_001d;
|
|
case 2:
|
|
goto IL_006c;
|
|
case 0:
|
|
result = new List<ShopSearchResult>();
|
|
num = -1685291895;
|
|
break;
|
|
case 5:
|
|
num = -1685291890;
|
|
break;
|
|
case 1:
|
|
num = -1685291889;
|
|
break;
|
|
case 3:
|
|
goto IL_00ab;
|
|
}
|
|
continue;
|
|
end_IL_001d:
|
|
break;
|
|
}
|
|
goto case EShopType.SpecialShop;
|
|
IL_00ab:
|
|
result = _gilShopSearcher.Search(itemId);
|
|
num = -1685291895;
|
|
goto IL_001d;
|
|
IL_006c:
|
|
result = _gcShopSearcher.Search(itemId);
|
|
num = -1685291895;
|
|
goto IL_001d;
|
|
}
|
|
}
|
|
|
|
public ShopSearchResult? FindGilVendor(uint itemId)
|
|
{
|
|
List<ShopSearchResult> list = _gilShopSearcher.Search(itemId);
|
|
int num = ((list.Count > 0) ? 274593349 : 274593348);
|
|
while (true)
|
|
{
|
|
int num2 = num;
|
|
int num3 = 274593349;
|
|
int num4 = num2;
|
|
int num5 = num4 + num3;
|
|
int num6 = num4 & num3;
|
|
switch (num5 - (num6 + num6))
|
|
{
|
|
case 2:
|
|
goto IL_0056;
|
|
case 1:
|
|
return null;
|
|
case 0:
|
|
return list[0];
|
|
}
|
|
continue;
|
|
IL_0056:
|
|
num = 274593348;
|
|
}
|
|
}
|
|
}
|