fix: fixed item usages in medkits and simple meds

This commit is contained in:
Yui 2024-10-23 20:58:19 -03:00
parent 01d3da1e8c
commit 0741831f3d
Signed by: yui
GPG Key ID: F368D23A0ABA04B4

View File

@ -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()));
}
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<KeyComponent>();
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;
}