Fix IMod now using reference equality as well

This commit is contained in:
Salman Ahmed 2020-12-28 15:19:28 +03:00
parent 43f8f3638a
commit 5efcdbd431
4 changed files with 8 additions and 4 deletions

View File

@ -52,7 +52,8 @@ namespace osu.Game.Online.API
return resultMod;
}
public bool Equals(APIMod other) => Acronym == other?.Acronym;
public bool Equals(IMod other) => other is APIMod them && Equals(them);
public bool Equals(APIMod other) => ((IMod)this).Equals(other);
public override string ToString()
{

View File

@ -1,11 +1,12 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using Newtonsoft.Json;
namespace osu.Game.Rulesets.Mods
{
public interface IMod
public interface IMod : IEquatable<IMod>
{
/// <summary>
/// The shortened name of this mod.

View File

@ -149,6 +149,7 @@ namespace osu.Game.Rulesets.Mods
return copy;
}
public bool Equals(Mod other) => GetType() == other?.GetType();
public bool Equals(IMod other) => other is Mod them && Equals(them);
public bool Equals(Mod other) => Acronym == other?.Acronym;
}
}

View File

@ -256,7 +256,8 @@ namespace osu.Game.Scoring
{
public string Acronym { get; set; }
public bool Equals(DeserializedMod other) => Acronym == other?.Acronym;
bool IEquatable<IMod>.Equals(IMod other) => other is DeserializedMod them && Equals(them);
public bool Equals(DeserializedMod other) => ((IMod)this).Equals(other);
}
public override string ToString() => $"{User} playing {Beatmap}";