1
0
mirror of https://github.com/ppy/osu.git synced 2026-06-04 07:03:39 +08:00

Fix IMod now using reference equality as well

This commit is contained in:
Salman Ahmed
2020-12-28 15:19:28 +03:00
Unverified
parent 43f8f3638a
commit 5efcdbd431
4 changed files with 8 additions and 4 deletions
+2 -1
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()
{
+2 -1
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.
+2 -1
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;
}
}
+2 -1
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}";