2019-10-25 10:58:42 +00:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-01-24 08:43:03 +00:00
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2017-05-23 06:20:32 +00:00
|
|
|
using System;
|
2021-08-31 06:05:10 +00:00
|
|
|
using Newtonsoft.Json;
|
2020-10-01 10:29:34 +00:00
|
|
|
using osu.Game.Graphics;
|
2021-07-19 03:38:22 +00:00
|
|
|
using osu.Game.Utils;
|
2020-10-01 10:29:34 +00:00
|
|
|
using osuTK.Graphics;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2017-05-23 04:55:18 +00:00
|
|
|
namespace osu.Game.Beatmaps.ControlPoints
|
|
|
|
{
|
2022-10-18 07:01:04 +00:00
|
|
|
public abstract class ControlPoint : IComparable<ControlPoint>, IDeepCloneable<ControlPoint>, IEquatable<ControlPoint>, IControlPoint
|
2017-05-23 04:55:18 +00:00
|
|
|
{
|
2021-08-31 06:05:10 +00:00
|
|
|
[JsonIgnore]
|
2021-09-10 05:35:53 +00:00
|
|
|
public double Time { get; set; }
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2021-09-10 05:35:53 +00:00
|
|
|
public void AttachGroup(ControlPointGroup pointGroup) => Time = pointGroup.Time;
|
2019-10-25 10:48:01 +00:00
|
|
|
|
2022-12-16 09:16:26 +00:00
|
|
|
public int CompareTo(ControlPoint? other) => Time.CompareTo(other?.Time);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2020-10-01 10:29:34 +00:00
|
|
|
public virtual Color4 GetRepresentingColour(OsuColour colours) => colours.Yellow;
|
|
|
|
|
2020-04-08 08:42:35 +00:00
|
|
|
/// <summary>
|
2020-04-17 08:06:12 +00:00
|
|
|
/// Determines whether this <see cref="ControlPoint"/> results in a meaningful change when placed alongside another.
|
2020-04-08 08:42:35 +00:00
|
|
|
/// </summary>
|
2020-04-09 16:34:40 +00:00
|
|
|
/// <param name="existing">An existing control point to compare with.</param>
|
2020-04-17 08:06:12 +00:00
|
|
|
/// <returns>Whether this <see cref="ControlPoint"/> is redundant when placed alongside <paramref name="existing"/>.</returns>
|
2022-06-20 07:52:01 +00:00
|
|
|
public abstract bool IsRedundant(ControlPoint? existing);
|
2021-01-04 07:37:07 +00:00
|
|
|
|
|
|
|
/// <summary>
|
2021-01-07 10:06:10 +00:00
|
|
|
/// Create an unbound copy of this control point.
|
2021-01-04 07:37:07 +00:00
|
|
|
/// </summary>
|
2021-07-19 03:38:22 +00:00
|
|
|
public ControlPoint DeepClone()
|
2021-01-04 07:37:07 +00:00
|
|
|
{
|
2022-12-16 09:16:26 +00:00
|
|
|
var copy = (ControlPoint)Activator.CreateInstance(GetType())!;
|
2021-01-04 07:37:07 +00:00
|
|
|
|
|
|
|
copy.CopyFrom(this);
|
|
|
|
|
|
|
|
return copy;
|
|
|
|
}
|
|
|
|
|
|
|
|
public virtual void CopyFrom(ControlPoint other)
|
|
|
|
{
|
2021-09-10 05:35:53 +00:00
|
|
|
Time = other.Time;
|
2021-01-04 07:37:07 +00:00
|
|
|
}
|
2022-06-20 05:56:04 +00:00
|
|
|
|
|
|
|
public sealed override bool Equals(object? obj)
|
|
|
|
=> obj is ControlPoint otherControlPoint
|
|
|
|
&& Equals(otherControlPoint);
|
|
|
|
|
|
|
|
public virtual bool Equals(ControlPoint? other)
|
2022-06-21 03:05:28 +00:00
|
|
|
{
|
|
|
|
if (ReferenceEquals(other, null)) return false;
|
|
|
|
if (ReferenceEquals(other, this)) return true;
|
|
|
|
|
|
|
|
return Time == other.Time;
|
|
|
|
}
|
2022-06-20 05:56:04 +00:00
|
|
|
|
|
|
|
// ReSharper disable once NonReadonlyMemberInGetHashCode
|
|
|
|
public override int GetHashCode() => Time.GetHashCode();
|
2017-05-23 04:55:18 +00:00
|
|
|
}
|
|
|
|
}
|