feat: get best trader offer for items

TODO: Make a better conversion for USD/EUR to RUB
This commit is contained in:
Yui
2024-11-08 17:17:10 -03:00
parent a86213d3a6
commit db4003caa7
8 changed files with 132 additions and 6 deletions

View File

@@ -25,7 +25,8 @@ namespace LootValueEX.Patches.Screens
Stopwatch sw = Stopwatch.StartNew();
foreach(EFT.InventoryLogic.Item item in profile.Inventory.GetPlayerItems(EFT.InventoryLogic.EPlayerItems.Equipment))
{
Plugin.Log.LogDebug($"Equip Process: {item.LocalizedName()} ({item.TemplateId}): {await item.GetCustomHashAsync()}");
//Plugin.Log.LogDebug($"Equip Process: {item.LocalizedName()} ({item.TemplateId}): {await item.GetCustomHashAsync()}");
continue;
}
sw.Stop();
Plugin.Log.LogDebug($"Equipment processing finished in {sw.ElapsedMilliseconds}ms");
@@ -43,7 +44,8 @@ namespace LootValueEX.Patches.Screens
Stopwatch sw = Stopwatch.StartNew();
foreach (EFT.InventoryLogic.Item item in lootItemClass.GetAllItems())
{
Plugin.Log.LogDebug($"LootItemClass process: {item.LocalizedName()} ({item.TemplateId}): {await item.GetCustomHashAsync()}");
//Plugin.Log.LogDebug($"LootItemClass process: {item.LocalizedName()} ({item.TemplateId}): {await item.GetCustomHashAsync()}");
continue;
}
Plugin.Log.LogDebug($"LootItemClass processing finished in {sw.ElapsedMilliseconds}ms");
tcsLoot.SetResult(true);

View File

@@ -19,12 +19,10 @@ namespace LootValueEX.Patches.Tooltips
[PatchPostfix]
public static void AlterText(SimpleTooltip __instance, string text)
{
StackTrace stackTrace = new StackTrace();
Plugin.Log.LogDebug("Stacktrace of tooltip call: \n" + stackTrace.ToString());
if (GridItemTooltipPatch.PatchTooltip)
{
text += $"<br>TemplateID: {GridItemTooltipPatch.HoveredItem?.TemplateId}<br>Template: {GridItemTooltipPatch.HoveredItem?.Template}<br>Item hashsum: {GridItemTooltipPatch.HoveredItem?.GetHashSum()}<br>Custom hash: {GridItemTooltipPatch.HoveredItem?.GetCustomHash()}<br>Item durability: {GridItemTooltipPatch.HoveredItem?.GetDurability()}<br>Item uses: {GridItemTooltipPatch.HoveredItem?.GetUses()}<br><color=#ff0fff><b>GridItemView</b></color>";
Plugin.Log.LogDebug(GridItemTooltipPatch.HoveredItem?.AttributesToString());
Structs.TradeOfferStruct tradeOffer = Utils.ItemUtils.GetBestTraderValue(GridItemTooltipPatch.HoveredItem);
text += $"<br>Hash: {GridItemTooltipPatch.HoveredItem?.GetCustomHash()}<br>Trader: {tradeOffer.TraderID}<br>Value: {tradeOffer.Price}<br>Currency: {tradeOffer.CurrencyID}<br>Price in rubles: {tradeOffer.PriceInRouble}<br><color=#ff0fff><b>GridItemView</b></color>";
}
if (InsuranceSlotPatch.PatchTooltip)
{

View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using SPT.Reflection.Patching;
namespace LootValueEX.Patches
{
internal class TraderClassPatch : ModulePatch
{
protected override MethodBase GetTargetMethod() => typeof(TraderClass).GetConstructors().First();
[PatchPostfix]
private static void GenerateSupplyData(ref TraderClass __instance)
{
Plugin.Log.LogDebug($"Generating Assortment Data for trader {__instance.Id}");
__instance.RefreshAssortment(true, false);
}
}
}