diff --git a/Plugin/Extensions/ItemExtensions.cs b/Plugin/Extensions/ItemExtensions.cs index f0b8cce..d6d6add 100644 --- a/Plugin/Extensions/ItemExtensions.cs +++ b/Plugin/Extensions/ItemExtensions.cs @@ -15,9 +15,15 @@ namespace LootValueEX.Extensions /// /// The item to check. /// True if the item has been examined, false otherwise. - internal static bool IsExamined(this Item? item) => item != null && ClientAppUtils.GetMainApp().GetClientBackEndSession().Profile.Examined(item); - internal static bool IsStacked(this Item? item) => item != null && (item.StackObjectsCount > 1 || item.UnlimitedCount); - internal static string PrehashTemplate(this Item? item) => string.Format("{0}|{1}|{2}", item?.TemplateId, item.GetDurability(), item.GetUses()); + internal static bool IsExamined(this Item? item) => item != null && + ClientAppUtils.GetMainApp().GetClientBackEndSession() + .Profile.Examined(item); + + internal static bool IsStacked(this Item? item) => + item != null && (item.StackObjectsCount > 1 || item.UnlimitedCount); + + internal static string PrehashTemplate(this Item? item) => + string.Format("{0}|{1}|{2}", item?.TemplateId, item.GetDurability(), item.GetUses()); internal static Item? UnstackItem(this Item? item) { @@ -31,7 +37,7 @@ namespace LootValueEX.Extensions itemClone.StackObjectsCount = 1; itemClone.UnlimitedCount = false; return itemClone; - } + } /// /// Retrieves the value of a specific attribute from an item. @@ -73,10 +79,13 @@ namespace LootValueEX.Extensions MagazineTemplate magTemplate = (MagazineTemplate)item.Template; magTemplate.Cartridges.DoMap(s => s.Items.DoMap(i => prehashString.Append(i.PrehashTemplate()))); } + prehashString.Append(item.PrehashTemplate()); return await Task.Run(() => Utils.HashingUtils.ConvertToSha256(prehashString.ToString())); } - internal static string GetCustomHash(this Item? item) => Task.Run(() => item?.GetCustomHashAsync()).Result ?? string.Empty; + + internal static string GetCustomHash(this Item? item) => + Task.Run(() => item?.GetCustomHashAsync()).Result ?? string.Empty; #if DEBUG internal static string AttributesToString(this Item? item) { @@ -87,7 +96,9 @@ namespace LootValueEX.Extensions return String.Empty; StringBuilder sb = new StringBuilder(); - item.Attributes.ForEach(attr => sb.Append($"\n{attr.Id}\n\tName: {attr.Name}\n\tBase Value: {attr.Base()}\n\tString value: {attr.StringValue()}\n\tDisplay Type: {attr.DisplayType()}")); + item.Attributes.ForEach(attr => + sb.Append( + $"\n{attr.Id}\n\tName: {attr.Name}\n\tBase Value: {attr.Base()}\n\tString value: {attr.StringValue()}\n\tDisplay Type: {attr.DisplayType()}")); return sb.ToString(); } #endif @@ -110,7 +121,8 @@ namespace LootValueEX.Extensions { case ArmoredRigTemplate armoredRig: case ArmorTemplate armor: - return Utils.ItemUtils.GetArmorDurability(item.GetItemComponentsInChildren(true)); + return Utils.ItemUtils.GetArmorDurability( + item.GetItemComponentsInChildren(true)); default: return item.GetItemAttribute(EItemAttributeId.Durability); } @@ -124,7 +136,6 @@ namespace LootValueEX.Extensions /// /// The item to retrieve the number of uses for. /// The number of uses remaining for the item, or -1f if the item is null. - internal static float GetUses(this Item? item) { if (item == null) @@ -150,4 +161,4 @@ namespace LootValueEX.Extensions } } } -} +} \ No newline at end of file diff --git a/Plugin/Patches/Screens/InventoryScreenPatch.cs b/Plugin/Patches/Screens/InventoryScreenPatch.cs index 7ed2a93..5a0f597 100644 --- a/Plugin/Patches/Screens/InventoryScreenPatch.cs +++ b/Plugin/Patches/Screens/InventoryScreenPatch.cs @@ -5,6 +5,7 @@ using EFT.HealthSystem; using EFT.UI; using LootValueEX.Extensions; using SPT.Reflection.Patching; +// ReSharper disable InconsistentNaming namespace LootValueEX.Patches.Screens { diff --git a/Plugin/Patches/TraderClassPatch.cs b/Plugin/Patches/TraderClassPatch.cs index 1dc2471..3c5d3eb 100644 --- a/Plugin/Patches/TraderClassPatch.cs +++ b/Plugin/Patches/TraderClassPatch.cs @@ -16,7 +16,7 @@ namespace LootValueEX.Patches private static void GenerateSupplyData(ref TraderClass __instance) { Plugin.Log.LogDebug($"Generating Assortment Data for trader {__instance.Id}"); - __instance.RefreshAssortment(true, false); + __instance.RefreshAssortment(true, true); } } } diff --git a/Plugin/Utils/EconomyUtils.cs b/Plugin/Utils/EconomyUtils.cs index 6a02515..c2829bc 100644 --- a/Plugin/Utils/EconomyUtils.cs +++ b/Plugin/Utils/EconomyUtils.cs @@ -10,10 +10,10 @@ using EFTCurrencyUtils = GClass2531; namespace LootValueEX.Utils { - internal class EconomyUtils + internal static class EconomyUtils { - public static float ConvertToRuble(string id, float amount) + internal static float ConvertToRuble(string id, float amount) { if (!EFTCurrencyUtils.TryGetCurrencyType(id, out ECurrencyType currencyType)) return 0f; @@ -22,7 +22,7 @@ namespace LootValueEX.Utils return amount * (float)Singleton.Instance.GetBasePrice(id); } - public static Structs.TradeOfferStruct GetTraderItemOffer(TraderClass trader, Item item) + internal static Structs.TradeOfferStruct GetTraderItemOffer(TraderClass trader, Item item) { Plugin.Log.LogDebug($"GetTraderItemOffer: {item.LocalizedName()} - {trader.LocalizedName}"); TraderClass.GStruct244? tradeOffer = trader.GetUserItemPrice(item); diff --git a/Plugin/Utils/HashingUtils.cs b/Plugin/Utils/HashingUtils.cs index 8d0856a..2348a86 100644 --- a/Plugin/Utils/HashingUtils.cs +++ b/Plugin/Utils/HashingUtils.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace LootValueEX.Utils { - internal class HashingUtils + internal static class HashingUtils { internal static string ConvertToSha256(string value) { diff --git a/Plugin/Utils/ItemUtils.cs b/Plugin/Utils/ItemUtils.cs index bb2daa2..0374c3d 100644 --- a/Plugin/Utils/ItemUtils.cs +++ b/Plugin/Utils/ItemUtils.cs @@ -4,9 +4,9 @@ using SPT.Reflection.Utils; namespace LootValueEX.Utils { - internal class ItemUtils + internal static class ItemUtils { - public static float GetArmorDurability(IEnumerable repairableComponents) + internal static float GetArmorDurability(IEnumerable repairableComponents) { float totalDurability = 0; foreach (RepairableComponent component in repairableComponents) @@ -16,7 +16,7 @@ namespace LootValueEX.Utils return totalDurability; } - public static Task GetBestTraderValueAsync(Item item) + internal static Task GetBestTraderValueAsync(Item item) { Structs.TradeOfferStruct bestOffer = new(); item = item.UnstackItem();