Compare commits

..

2 Commits

Author SHA1 Message Date
Yui
ee5bbbb098
feat: added support for hashing of mags 2024-10-23 22:14:33 -03:00
Yui
0741831f3d
fix: fixed item usages in medkits and simple meds 2024-10-23 20:58:19 -03:00

View File

@ -4,7 +4,7 @@ using System.Text;
using KeycardTemplate = GClass2623;
using ArmorTemplate = GClass2550;
using ArmoredRigTemplate = GClass2602;
using SimpleMedClass = GClass2631;
using MagazineTemplate = GClass2586;
namespace LootValueEX.Extensions
{
@ -29,10 +29,10 @@ 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()));
if (item.Template.Equals(typeof(MagazineTemplate))){
MagazineTemplate magTemplate = (MagazineTemplate)item.Template;
magTemplate.Cartridges.ExecuteForEach(prop => prop.Items.ExecuteForEach(ammo => prehashString.Append(ammo.GetCustomHash())));
}
string itemHashTemplate = string.Format("{0}|{1}|{2}|{3}", prehashString.ToString(), item.TemplateId, item.GetDurability(), item.GetUses());
return Utils.HashingUtils.ConvertToSha256(itemHashTemplate);
@ -70,12 +70,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;
}