From 0741831f3daf80133b7718c4db2a477dbc92a5aa Mon Sep 17 00:00:00 2001 From: Yui Date: Wed, 23 Oct 2024 20:58:19 -0300 Subject: [PATCH] fix: fixed item usages in medkits and simple meds --- Plugin/Extensions/ItemExtensions.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Plugin/Extensions/ItemExtensions.cs b/Plugin/Extensions/ItemExtensions.cs index 9a3b3dd..937425c 100644 --- a/Plugin/Extensions/ItemExtensions.cs +++ b/Plugin/Extensions/ItemExtensions.cs @@ -29,11 +29,7 @@ namespace LootValueEX.Extensions if (item == null) return string.Empty; StringBuilder prehashString = new StringBuilder(); - if (item.IsContainer) - { - Plugin.Log.LogDebug($"Loop called on {item.LocalizedName()}"); - item.GetAllItems().Where(prop => !prop.Equals(item)).ExecuteForEach(prop => prehashString.Append(prop.GetCustomHash())); - } + item.GetAllItems().Where(prop => !prop.Equals(item)).ExecuteForEach(prop => prehashString.Append(prop.GetCustomHash())); string itemHashTemplate = string.Format("{0}|{1}|{2}|{3}", prehashString.ToString(), item.TemplateId, item.GetDurability(), item.GetUses()); return Utils.HashingUtils.ConvertToSha256(itemHashTemplate); } @@ -70,12 +66,13 @@ namespace LootValueEX.Extensions return -1f; switch (item.Template) { - case KeycardTemplate key: + case KeycardTemplate: KeyComponent keyComponent = item.GetItemComponent(); return keyComponent.Template.MaximumNumberOfUsage - keyComponent.NumberOfUsages; - case SimpleMedClass: case Meds2Class: - return item.GetItemAttribute(EItemAttributeId.HpResource); + if (item.TryGetItemComponent(out MedKitComponent medKitComponent)) + return medKitComponent.HpResource; + return -1f; default: return -1f; }