2024-11-06 21:45:58 +01:00
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Reflection;
|
2024-11-04 05:37:34 +01:00
|
|
|
|
using EFT;
|
|
|
|
|
using EFT.HealthSystem;
|
|
|
|
|
using EFT.UI;
|
|
|
|
|
using LootValueEX.Extensions;
|
|
|
|
|
using SPT.Reflection.Patching;
|
|
|
|
|
|
|
|
|
|
namespace LootValueEX.Patches.Screens
|
|
|
|
|
{
|
|
|
|
|
internal class InventoryScreenPatch : ModulePatch
|
|
|
|
|
{
|
|
|
|
|
protected override MethodBase GetTargetMethod() => typeof(InventoryScreen).GetMethods().SingleOrDefault(method => method.Name == "Show" && method.GetParameters()[0].ParameterType == typeof(IHealthController));
|
|
|
|
|
|
|
|
|
|
[PatchPostfix]
|
|
|
|
|
private static void PatchPostfix(ref Profile ___profile_0, ref LootItemClass ___lootItemClass)
|
|
|
|
|
{
|
2024-11-06 21:45:58 +01:00
|
|
|
|
Profile profile = ___profile_0;
|
|
|
|
|
|
|
|
|
|
TaskCompletionSource<bool> tcsInventory = new();
|
|
|
|
|
CancellationTokenSource ctsInventory = new CancellationTokenSource(5000);
|
|
|
|
|
Task<bool> taskInventory = tcsInventory.Task;
|
|
|
|
|
Task.Factory.StartNew(async () =>
|
|
|
|
|
{
|
|
|
|
|
Stopwatch sw = Stopwatch.StartNew();
|
|
|
|
|
foreach(EFT.InventoryLogic.Item item in profile.Inventory.GetPlayerItems(EFT.InventoryLogic.EPlayerItems.Equipment))
|
|
|
|
|
{
|
2024-11-08 21:17:10 +01:00
|
|
|
|
//Plugin.Log.LogDebug($"Equip Process: {item.LocalizedName()} ({item.TemplateId}): {await item.GetCustomHashAsync()}");
|
|
|
|
|
continue;
|
2024-11-06 21:45:58 +01:00
|
|
|
|
}
|
|
|
|
|
sw.Stop();
|
|
|
|
|
Plugin.Log.LogDebug($"Equipment processing finished in {sw.ElapsedMilliseconds}ms");
|
|
|
|
|
tcsInventory.SetResult(true);
|
|
|
|
|
}, ctsInventory.Token);
|
|
|
|
|
|
2024-11-04 05:37:34 +01:00
|
|
|
|
if(___lootItemClass != null)
|
2024-11-06 21:45:58 +01:00
|
|
|
|
{
|
|
|
|
|
LootItemClass lootItemClass = ___lootItemClass;
|
|
|
|
|
TaskCompletionSource<bool> tcsLoot = new();
|
|
|
|
|
CancellationTokenSource ctsLoot = new CancellationTokenSource(5000);
|
|
|
|
|
Task<bool> taskLoot = tcsLoot.Task;
|
|
|
|
|
Task.Factory.StartNew(async () =>
|
|
|
|
|
{
|
|
|
|
|
Stopwatch sw = Stopwatch.StartNew();
|
|
|
|
|
foreach (EFT.InventoryLogic.Item item in lootItemClass.GetAllItems())
|
|
|
|
|
{
|
2024-11-08 21:17:10 +01:00
|
|
|
|
//Plugin.Log.LogDebug($"LootItemClass process: {item.LocalizedName()} ({item.TemplateId}): {await item.GetCustomHashAsync()}");
|
|
|
|
|
continue;
|
2024-11-06 21:45:58 +01:00
|
|
|
|
}
|
|
|
|
|
Plugin.Log.LogDebug($"LootItemClass processing finished in {sw.ElapsedMilliseconds}ms");
|
|
|
|
|
tcsLoot.SetResult(true);
|
|
|
|
|
}, ctsLoot.Token);
|
|
|
|
|
}
|
2024-11-04 05:37:34 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|