30 lines
1.2 KiB
C#
30 lines
1.2 KiB
C#
using EFT.InventoryLogic;
|
|
using LootValueEX.Extensions;
|
|
using SPT.Reflection.Utils;
|
|
|
|
namespace LootValueEX.Utils
|
|
{
|
|
internal static class ItemUtils
|
|
{
|
|
internal static float GetArmorDurability(IEnumerable<RepairableComponent> repairableComponents) => repairableComponents.Sum(x => x.Durability);
|
|
|
|
internal static Task<Structs.TradeOfferStruct> GetBestTraderValueAsync(Item item)
|
|
{
|
|
Structs.TradeOfferStruct bestOffer = new();
|
|
item = item.UnstackItem();
|
|
foreach (TraderClass trader in ClientAppUtils.GetMainApp().GetClientBackEndSession().DisplayableTraders)
|
|
{
|
|
Structs.TradeOfferStruct currentOffer = EconomyUtils.GetTraderItemOffer(trader, item);
|
|
|
|
if (currentOffer.Equals(default) || currentOffer.Price <= 0)
|
|
continue;
|
|
|
|
if (currentOffer.PriceInRouble > bestOffer.PriceInRouble)
|
|
bestOffer = currentOffer;
|
|
}
|
|
return Task.FromResult(bestOffer);
|
|
}
|
|
public static Structs.TradeOfferStruct GetBestTraderValue(Item item) => Task.Run(() => GetBestTraderValueAsync(item)).Result;
|
|
}
|
|
}
|