Add deep cloning support to Score/ScoreInfo/Replay

This commit is contained in:
Dean Herbert
2021-07-19 13:02:40 +09:00
parent 3c028ce05c
commit e507faef29
4 changed files with 67 additions and 3 deletions

View File

@ -18,7 +18,7 @@ using osu.Game.Utils;
namespace osu.Game.Scoring
{
public class ScoreInfo : IHasFiles<ScoreFileInfo>, IHasPrimaryKey, ISoftDelete, IEquatable<ScoreInfo>
public class ScoreInfo : IHasFiles<ScoreFileInfo>, IHasPrimaryKey, ISoftDelete, IEquatable<ScoreInfo>, IDeepCloneable<ScoreInfo>
{
public int ID { get; set; }
@ -242,6 +242,15 @@ namespace osu.Game.Scoring
}
}
public ScoreInfo DeepClone()
{
var clone = (ScoreInfo)MemberwiseClone();
clone.Statistics = new Dictionary<HitResult, int>(clone.Statistics);
return clone;
}
public override string ToString() => $"{User} playing {Beatmap}";
public bool Equals(ScoreInfo other)