2019-01-24 16:43:03 +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
|
|
|
|
2022-06-20 13:56:04 +08:00
|
|
|
using System;
|
2019-10-28 13:44:45 +08:00
|
|
|
using osu.Framework.Bindables;
|
2020-10-01 18:29:34 +08:00
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Beatmaps.ControlPoints
|
|
|
|
{
|
2021-08-31 22:59:36 +08:00
|
|
|
/// <remarks>
|
|
|
|
/// Note that going forward, this control point type should always be assigned directly to HitObjects.
|
|
|
|
/// </remarks>
|
2022-06-20 13:56:04 +08:00
|
|
|
public class DifficultyControlPoint : ControlPoint, IEquatable<DifficultyControlPoint>
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2020-07-18 10:53:04 +08:00
|
|
|
public static readonly DifficultyControlPoint DEFAULT = new DifficultyControlPoint
|
|
|
|
{
|
2021-08-31 22:59:36 +08:00
|
|
|
SliderVelocityBindable = { Disabled = true },
|
2020-07-18 10:53:04 +08:00
|
|
|
};
|
|
|
|
|
2019-10-28 13:44:45 +08:00
|
|
|
/// <summary>
|
2021-08-31 22:59:36 +08:00
|
|
|
/// The slider velocity at this control point.
|
2019-10-28 13:44:45 +08:00
|
|
|
/// </summary>
|
2021-08-31 22:59:36 +08:00
|
|
|
public readonly BindableDouble SliderVelocityBindable = new BindableDouble(1)
|
2019-10-28 13:44:45 +08:00
|
|
|
{
|
|
|
|
MinValue = 0.1,
|
|
|
|
MaxValue = 10
|
|
|
|
};
|
|
|
|
|
2023-09-07 16:41:28 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Whether or not slider ticks should be generated at this control point.
|
|
|
|
/// This exists for backwards compatibility with maps that abuse NaN slider velocity behavior on osu!stable (e.g. /b/2628991).
|
|
|
|
/// </summary>
|
|
|
|
public bool GenerateTicks { get; set; } = true;
|
|
|
|
|
2021-04-14 19:54:29 +08:00
|
|
|
public override Color4 GetRepresentingColour(OsuColour colours) => colours.Lime1;
|
2020-10-01 18:29:34 +08:00
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
/// <summary>
|
2021-09-06 20:30:15 +08:00
|
|
|
/// The slider velocity at this control point.
|
2018-04-13 17:19:50 +08:00
|
|
|
/// </summary>
|
2021-08-31 22:59:36 +08:00
|
|
|
public double SliderVelocity
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
2021-08-31 22:59:36 +08:00
|
|
|
get => SliderVelocityBindable.Value;
|
|
|
|
set => SliderVelocityBindable.Value = value;
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
|
2024-06-11 15:14:46 +08:00
|
|
|
public DifficultyControlPoint()
|
|
|
|
{
|
|
|
|
SliderVelocityBindable.BindValueChanged(_ => RaiseChanged());
|
|
|
|
}
|
|
|
|
|
2022-06-20 15:52:01 +08:00
|
|
|
public override bool IsRedundant(ControlPoint? existing)
|
2020-04-17 16:04:09 +08:00
|
|
|
=> existing is DifficultyControlPoint existingDifficulty
|
2023-09-07 16:41:28 +08:00
|
|
|
&& GenerateTicks == existingDifficulty.GenerateTicks
|
2021-08-31 22:59:36 +08:00
|
|
|
&& SliderVelocity == existingDifficulty.SliderVelocity;
|
2021-01-04 15:37:07 +08:00
|
|
|
|
|
|
|
public override void CopyFrom(ControlPoint other)
|
|
|
|
{
|
2021-08-31 22:59:36 +08:00
|
|
|
SliderVelocity = ((DifficultyControlPoint)other).SliderVelocity;
|
2023-09-07 16:41:28 +08:00
|
|
|
GenerateTicks = ((DifficultyControlPoint)other).GenerateTicks;
|
2021-01-04 15:37:07 +08:00
|
|
|
|
|
|
|
base.CopyFrom(other);
|
|
|
|
}
|
2022-06-20 13:56:04 +08:00
|
|
|
|
|
|
|
public override bool Equals(ControlPoint? other)
|
|
|
|
=> other is DifficultyControlPoint otherDifficultyControlPoint
|
|
|
|
&& Equals(otherDifficultyControlPoint);
|
|
|
|
|
|
|
|
public bool Equals(DifficultyControlPoint? other)
|
|
|
|
=> base.Equals(other)
|
2023-09-07 16:41:28 +08:00
|
|
|
&& GenerateTicks == other.GenerateTicks
|
2022-06-20 13:56:04 +08:00
|
|
|
&& SliderVelocity == other.SliderVelocity;
|
|
|
|
|
2023-09-07 16:41:28 +08:00
|
|
|
// ReSharper disable once NonReadonlyMemberInGetHashCode
|
|
|
|
public override int GetHashCode() => HashCode.Combine(base.GetHashCode(), SliderVelocity, GenerateTicks);
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
}
|