1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-07 01:07:24 +08:00
osu-lazer/osu.Game/Beatmaps/ControlPoints/ControlPoint.cs

51 lines
1.7 KiB
C#
Raw Normal View History

2019-10-25 18:58:42 +08:00
// 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.
2018-04-13 17:19:50 +08:00
using System;
using Newtonsoft.Json;
using osu.Game.Graphics;
using osu.Game.Utils;
using osuTK.Graphics;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Beatmaps.ControlPoints
{
public abstract class ControlPoint : IComparable<ControlPoint>, IDeepCloneable<ControlPoint>
2018-04-13 17:19:50 +08:00
{
/// <summary>
/// The time at which the control point takes effect.
/// </summary>
[JsonIgnore]
2021-09-10 13:35:53 +08:00
public double Time { get; set; }
2018-04-13 17:19:50 +08:00
2021-09-10 13:35:53 +08:00
public void AttachGroup(ControlPointGroup pointGroup) => Time = pointGroup.Time;
2019-10-25 18:48:01 +08:00
2018-04-13 17:19:50 +08:00
public int CompareTo(ControlPoint other) => Time.CompareTo(other.Time);
public virtual Color4 GetRepresentingColour(OsuColour colours) => colours.Yellow;
2020-04-08 16:42:35 +08:00
/// <summary>
2020-04-17 16:06:12 +08:00
/// Determines whether this <see cref="ControlPoint"/> results in a meaningful change when placed alongside another.
2020-04-08 16:42:35 +08:00
/// </summary>
2020-04-10 00:34:40 +08:00
/// <param name="existing">An existing control point to compare with.</param>
2020-04-17 16:06:12 +08:00
/// <returns>Whether this <see cref="ControlPoint"/> is redundant when placed alongside <paramref name="existing"/>.</returns>
public abstract bool IsRedundant(ControlPoint existing);
/// <summary>
2021-01-07 18:06:10 +08:00
/// Create an unbound copy of this control point.
/// </summary>
public ControlPoint DeepClone()
{
var copy = (ControlPoint)Activator.CreateInstance(GetType());
copy.CopyFrom(this);
return copy;
}
public virtual void CopyFrom(ControlPoint other)
{
2021-09-10 13:35:53 +08:00
Time = other.Time;
}
2018-04-13 17:19:50 +08:00
}
}