Merge pull request #13929 from peppy/i-deep-cloneable

Create a deep clone of score for score submission purposes
This commit is contained in:
Dan Balasescu
2021-07-19 21:58:27 +09:00
committed by GitHub
21 changed files with 118 additions and 32 deletions

View File

@ -3,11 +3,12 @@
using System;
using osu.Game.Graphics;
using osu.Game.Utils;
using osuTK.Graphics;
namespace osu.Game.Beatmaps.ControlPoints
{
public abstract class ControlPoint : IComparable<ControlPoint>
public abstract class ControlPoint : IComparable<ControlPoint>, IDeepCloneable<ControlPoint>
{
/// <summary>
/// The time at which the control point takes effect.
@ -32,7 +33,7 @@ namespace osu.Game.Beatmaps.ControlPoints
/// <summary>
/// Create an unbound copy of this control point.
/// </summary>
public ControlPoint CreateCopy()
public ControlPoint DeepClone()
{
var copy = (ControlPoint)Activator.CreateInstance(GetType());

View File

@ -10,11 +10,12 @@ using osu.Framework.Bindables;
using osu.Framework.Lists;
using osu.Framework.Utils;
using osu.Game.Screens.Edit;
using osu.Game.Utils;
namespace osu.Game.Beatmaps.ControlPoints
{
[Serializable]
public class ControlPointInfo
public class ControlPointInfo : IDeepCloneable<ControlPointInfo>
{
/// <summary>
/// All control points grouped by time.
@ -350,12 +351,12 @@ namespace osu.Game.Beatmaps.ControlPoints
}
}
public ControlPointInfo CreateCopy()
public ControlPointInfo DeepClone()
{
var controlPointInfo = new ControlPointInfo();
foreach (var point in AllControlPoints)
controlPointInfo.Add(point.Time, point.CreateCopy());
controlPointInfo.Add(point.Time, point.DeepClone());
return controlPointInfo;
}