2022-04-24 12:08:53 +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.
2022-06-17 15:37:17 +08:00
#nullable disable
2022-05-05 15:35:52 +08:00
using osu.Framework.Allocation ;
2022-04-24 12:08:53 +08:00
using osu.Framework.Bindables ;
using osu.Game.Beatmaps ;
2022-04-28 10:48:45 +08:00
using osu.Game.Rulesets.Objects ;
2022-04-24 12:08:53 +08:00
namespace osu.Game.Rulesets.Edit
{
2022-05-05 15:25:05 +08:00
/// <summary>
/// A snap provider which given a reference hit object and proposed distance from it, offers a more correct duration or distance value.
/// </summary>
2022-05-05 15:35:52 +08:00
[Cached]
2022-04-24 12:08:53 +08:00
public interface IDistanceSnapProvider : IPositionSnapProvider
{
/// <summary>
2022-05-05 15:25:05 +08:00
/// A multiplier which changes the ratio of distance travelled per time unit.
2022-05-05 16:50:17 +08:00
/// Importantly, this is provided for manual usage, and not multiplied into any of the methods exposed by this interface.
2022-04-24 12:08:53 +08:00
/// </summary>
/// <seealso cref="BeatmapInfo.DistanceSpacing"/>
2022-04-29 13:02:07 +08:00
IBindable < double > DistanceSpacingMultiplier { get ; }
2022-04-28 10:48:45 +08:00
/// <summary>
/// Retrieves the distance between two points within a timing point that are one beat length apart.
/// </summary>
/// <param name="referenceObject">An object to be used as a reference point for this operation.</param>
2022-11-01 14:00:23 +08:00
/// <param name="useReferenceSliderVelocity">Whether the <paramref name="referenceObject"/>'s slider velocity should be factored into the returned distance.</param>
2022-04-28 10:48:45 +08:00
/// <returns>The distance between two points residing in the timing point that are one beat length apart.</returns>
2022-11-01 14:00:23 +08:00
float GetBeatSnapDistanceAt ( HitObject referenceObject , bool useReferenceSliderVelocity = true ) ;
2022-04-28 10:48:45 +08:00
/// <summary>
2022-05-05 15:25:05 +08:00
/// Converts a duration to a distance without applying any snapping.
2022-04-28 10:48:45 +08:00
/// </summary>
/// <param name="referenceObject">An object to be used as a reference point for this operation.</param>
/// <param name="duration">The duration to convert.</param>
/// <returns>A value that represents <paramref name="duration"/> as a distance in the timing point.</returns>
float DurationToDistance ( HitObject referenceObject , double duration ) ;
/// <summary>
2022-05-05 15:25:05 +08:00
/// Converts a distance to a duration without applying any snapping.
2022-04-28 10:48:45 +08:00
/// </summary>
/// <param name="referenceObject">An object to be used as a reference point for this operation.</param>
/// <param name="distance">The distance to convert.</param>
/// <returns>A value that represents <paramref name="distance"/> as a duration in the timing point.</returns>
double DistanceToDuration ( HitObject referenceObject , float distance ) ;
/// <summary>
2022-05-05 15:25:05 +08:00
/// Given a distance from the provided hit object, find the valid snapped duration.
2022-04-28 10:48:45 +08:00
/// </summary>
/// <param name="referenceObject">An object to be used as a reference point for this operation.</param>
/// <param name="distance">The distance to convert.</param>
/// <returns>A value that represents <paramref name="distance"/> as a duration snapped to the closest beat of the timing point.</returns>
2022-05-05 15:25:05 +08:00
double FindSnappedDuration ( HitObject referenceObject , float distance ) ;
2022-04-28 10:48:45 +08:00
/// <summary>
2022-05-05 15:25:05 +08:00
/// Given a distance from the provided hit object, find the valid snapped distance.
2022-04-28 10:48:45 +08:00
/// </summary>
/// <param name="referenceObject">An object to be used as a reference point for this operation.</param>
/// <param name="distance">The distance to convert.</param>
2022-05-05 15:25:05 +08:00
/// <returns>
/// A value that represents <paramref name="distance"/> snapped to the closest beat of the timing point.
/// The distance will always be less than or equal to the provided <paramref name="distance"/>.
/// </returns>
float FindSnappedDistance ( HitObject referenceObject , float distance ) ;
2022-04-24 12:08:53 +08:00
}
}