feat: added custom item hashing
This commit is contained in:
parent
ab8c1967b8
commit
01d3da1e8c
|
@ -24,17 +24,18 @@ namespace LootValueEX.Extensions
|
||||||
return -1f;
|
return -1f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
internal static string CustomHash(this Item? item)
|
internal static string GetCustomHash(this Item? item)
|
||||||
{
|
{
|
||||||
if (item == null)
|
if (item == null)
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
StringBuilder prehashString = new StringBuilder();
|
StringBuilder prehashString = new StringBuilder();
|
||||||
if (item.IsContainer)
|
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);
|
string itemHashTemplate = string.Format("{0}|{1}|{2}|{3}", prehashString.ToString(), item.TemplateId, item.GetDurability(), item.GetUses());
|
||||||
return "0";
|
return Utils.HashingUtils.ConvertToSha256(itemHashTemplate);
|
||||||
}
|
}
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
internal static string AttributesToString(this Item? item)
|
internal static string AttributesToString(this Item? item)
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace LootValueEX.Patches
|
||||||
Plugin.Log.LogDebug("Stacktrace of tooltip call: \n" + stackTrace.ToString());
|
Plugin.Log.LogDebug("Stacktrace of tooltip call: \n" + stackTrace.ToString());
|
||||||
if (GridItemTooltipPatch.PatchTooltip)
|
if (GridItemTooltipPatch.PatchTooltip)
|
||||||
{
|
{
|
||||||
text += $"<br>TemplateID: {GridItemTooltipPatch.HoveredItem?.TemplateId}<br>Template: {GridItemTooltipPatch.HoveredItem?.Template}<br>Item hashsum: {GridItemTooltipPatch.HoveredItem?.GetHashSum()}<br>Item durability: {GridItemTooltipPatch.HoveredItem?.GetDurability()}<br>Item uses: {GridItemTooltipPatch.HoveredItem?.GetUses()}<br><color=#ff0fff><b>GridItemView</b></color>";
|
text += $"<br>TemplateID: {GridItemTooltipPatch.HoveredItem?.TemplateId}<br>Template: {GridItemTooltipPatch.HoveredItem?.Template}<br>Item hashsum: {GridItemTooltipPatch.HoveredItem?.GetHashSum()}<br>Custom hash: {GridItemTooltipPatch.HoveredItem?.GetCustomHash()}<br>Item durability: {GridItemTooltipPatch.HoveredItem?.GetDurability()}<br>Item uses: {GridItemTooltipPatch.HoveredItem?.GetUses()}<br><color=#ff0fff><b>GridItemView</b></color>";
|
||||||
Plugin.Log.LogDebug(GridItemTooltipPatch.HoveredItem?.AttributesToString());
|
Plugin.Log.LogDebug(GridItemTooltipPatch.HoveredItem?.AttributesToString());
|
||||||
}
|
}
|
||||||
if (InsuranceSlotPatch.PatchTooltip)
|
if (InsuranceSlotPatch.PatchTooltip)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user