feat: make ReagentId hash by value (#39494)

This commit is contained in:
Perry Fraser
2025-08-11 18:44:10 -04:00
committed by GitHub
parent de7486b8db
commit 915d815254

View File

@@ -75,7 +75,21 @@ public partial struct ReagentId : IEquatable<ReagentId>
public override int GetHashCode()
{
return HashCode.Combine(Prototype, Data);
// We need to make sure we take the hash code of Data by value in order
// for hashed key lookups to work properly
var hash = 17;
unchecked
{
if (Data?.Count != 0)
{
foreach (var data in Data ?? [])
{
hash = hash * 23 + data.GetHashCode();
}
}
}
return HashCode.Combine(Prototype, hash);
}
public string ToString(FixedPoint2 quantity)