// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. #nullable disable using System; using Newtonsoft.Json; using osu.Game.Graphics; using osu.Game.Utils; using osuTK.Graphics; namespace osu.Game.Beatmaps.ControlPoints { public abstract class ControlPoint : IComparable, IDeepCloneable { /// /// The time at which the control point takes effect. /// [JsonIgnore] public double Time { get; set; } public void AttachGroup(ControlPointGroup pointGroup) => Time = pointGroup.Time; public int CompareTo(ControlPoint other) => Time.CompareTo(other.Time); public virtual Color4 GetRepresentingColour(OsuColour colours) => colours.Yellow; /// /// Determines whether this results in a meaningful change when placed alongside another. /// /// An existing control point to compare with. /// Whether this is redundant when placed alongside . public abstract bool IsRedundant(ControlPoint existing); /// /// Create an unbound copy of this control point. /// public ControlPoint DeepClone() { var copy = (ControlPoint)Activator.CreateInstance(GetType()); copy.CopyFrom(this); return copy; } public virtual void CopyFrom(ControlPoint other) { Time = other.Time; } } }