feat: added custom item hashing

This commit is contained in:
Yui
2024-10-23 12:07:04 -03:00
parent ab8c1967b8
commit 01d3da1e8c
2 changed files with 6 additions and 5 deletions

View File

@@ -24,17 +24,18 @@ namespace LootValueEX.Extensions
return -1f;
}
}
internal static string CustomHash(this Item? item)
internal static string GetCustomHash(this Item? item)
{
if (item == null)
return string.Empty;
StringBuilder prehashString = new StringBuilder();
if (item.IsContainer)
{
return "0";
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}", item.TemplateId, item.GetDurability(), item.GetUses(), item.StackObjectsCount);
return "0";
string itemHashTemplate = string.Format("{0}|{1}|{2}|{3}", prehashString.ToString(), item.TemplateId, item.GetDurability(), item.GetUses());
return Utils.HashingUtils.ConvertToSha256(itemHashTemplate);
}
#if DEBUG
internal static string AttributesToString(this Item? item)