Fix RoleLoadout equality (#28737)

* Fix RoleLoadout equality

Knew it was janky but thought SequenceEqual was better than it is so we just do it manually.

* Also implement this
This commit is contained in:
metalgearsloth
2024-06-15 16:52:49 +10:00
committed by GitHub
parent a3d9f7291d
commit f0fbedd640
2 changed files with 37 additions and 2 deletions

View File

@@ -295,7 +295,25 @@ public sealed partial class RoleLoadout : IEquatable<RoleLoadout>
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return Role.Equals(other.Role) && SelectedLoadouts.SequenceEqual(other.SelectedLoadouts) && Points == other.Points;
if (!Role.Equals(other.Role) ||
SelectedLoadouts.Count != other.SelectedLoadouts.Count ||
Points != other.Points)
{
return false;
}
// Tried using SequenceEqual but it stinky so.
foreach (var (key, value) in SelectedLoadouts)
{
if (!other.SelectedLoadouts.TryGetValue(key, out var otherValue) ||
!otherValue.SequenceEqual(value))
{
return false;
}
}
return true;
}
public override bool Equals(object? obj)