mirror of
https://github.com/ppy/osu
synced 2024-12-27 17:32:56 +00:00
Add back interface equality but limit to only matching types
This commit is contained in:
parent
1988b263c6
commit
9207b87b76
@ -163,6 +163,8 @@ namespace osu.Game.Beatmaps
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Equals(IBeatmapInfo other) => other is BeatmapInfo b && Equals(b);
|
||||
|
||||
public bool AudioEquals(BeatmapInfo other) => other != null && BeatmapSet != null && other.BeatmapSet != null &&
|
||||
BeatmapSet.Hash == other.BeatmapSet.Hash &&
|
||||
(Metadata ?? BeatmapSet.Metadata).AudioFile == (other.Metadata ?? other.BeatmapSet.Metadata).AudioFile;
|
||||
|
@ -78,6 +78,8 @@ namespace osu.Game.Beatmaps
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Equals(IBeatmapSetInfo other) => other is BeatmapSetInfo b && Equals(b);
|
||||
|
||||
#region Implementation of IHasOnlineID
|
||||
|
||||
int IHasOnlineID<int>.OnlineID => OnlineID ?? -1;
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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 osu.Game.Database;
|
||||
using osu.Game.Rulesets;
|
||||
|
||||
@ -11,7 +12,7 @@ namespace osu.Game.Beatmaps
|
||||
/// <summary>
|
||||
/// A single beatmap difficulty.
|
||||
/// </summary>
|
||||
public interface IBeatmapInfo : IHasOnlineID<int>
|
||||
public interface IBeatmapInfo : IHasOnlineID<int>, IEquatable<IBeatmapInfo>
|
||||
{
|
||||
/// <summary>
|
||||
/// The user-specified name given to this beatmap.
|
||||
|
@ -12,7 +12,7 @@ namespace osu.Game.Beatmaps
|
||||
/// <summary>
|
||||
/// A representation of a collection of beatmap difficulties, generally packaged as an ".osz" archive.
|
||||
/// </summary>
|
||||
public interface IBeatmapSetInfo : IHasOnlineID<int>
|
||||
public interface IBeatmapSetInfo : IHasOnlineID<int>, IEquatable<IBeatmapSetInfo>
|
||||
{
|
||||
/// <summary>
|
||||
/// The date when this beatmap was imported.
|
||||
|
@ -106,6 +106,8 @@ namespace osu.Game.Models
|
||||
return ID == other.ID;
|
||||
}
|
||||
|
||||
public bool Equals(IBeatmapInfo? other) => other is RealmBeatmap b && Equals(b);
|
||||
|
||||
public bool AudioEquals(RealmBeatmap? other) => other != null
|
||||
&& BeatmapSet != null
|
||||
&& other.BeatmapSet != null
|
||||
|
@ -64,6 +64,8 @@ namespace osu.Game.Models
|
||||
|
||||
public override string ToString() => Metadata?.GetDisplayString() ?? base.ToString();
|
||||
|
||||
public bool Equals(IBeatmapSetInfo? other) => other is RealmBeatmapSet b && Equals(b);
|
||||
|
||||
IEnumerable<IBeatmapInfo> IBeatmapSetInfo.Beatmaps => Beatmaps;
|
||||
|
||||
IEnumerable<INamedFileUsage> IBeatmapSetInfo.Files => Files;
|
||||
|
@ -103,5 +103,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
public string Hash => throw new NotImplementedException();
|
||||
|
||||
#endregion
|
||||
|
||||
public bool Equals(IBeatmapInfo? other) => other is APIBeatmap b && Equals(b);
|
||||
}
|
||||
}
|
||||
|
@ -141,5 +141,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
double IBeatmapSetInfo.MaxBPM => BPM;
|
||||
|
||||
#endregion
|
||||
|
||||
public bool Equals(IBeatmapSetInfo? other) => other is APIBeatmapSet b && Equals(b);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user