2019-10-25 07:50:21 +00: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.
2021-09-01 09:05:10 +00:00
using osu.Game.Rulesets.Objects ;
2019-10-25 07:50:21 +00:00
using osuTK ;
namespace osu.Game.Rulesets.Edit
{
2020-05-20 08:48:43 +00:00
public interface IPositionSnapProvider
2019-10-25 07:50:21 +00:00
{
2020-05-20 08:48:43 +00:00
/// <summary>
2020-11-24 08:14:39 +00:00
/// Given a position, find a valid time and position snap.
2020-05-20 08:48:43 +00:00
/// </summary>
2020-11-24 08:14:39 +00:00
/// <remarks>
/// This call should be equivalent to running <see cref="SnapScreenSpacePositionToValidPosition"/> with any additional logic that can be performed without the time immutability restriction.
/// </remarks>
2020-05-20 09:19:21 +00:00
/// <param name="screenSpacePosition">The screen-space position to be snapped.</param>
2020-05-20 08:48:43 +00:00
/// <returns>The time and position post-snapping.</returns>
2020-05-20 09:19:21 +00:00
SnapResult SnapScreenSpacePositionToValidTime ( Vector2 screenSpacePosition ) ;
2019-10-25 07:50:21 +00:00
2020-11-24 08:14:39 +00:00
/// <summary>
/// Given a position, find a value position snap, restricting time to its input value.
/// </summary>
/// <param name="screenSpacePosition">The screen-space position to be snapped.</param>
/// <returns>The position post-snapping. Time will always be null.</returns>
SnapResult SnapScreenSpacePositionToValidPosition ( Vector2 screenSpacePosition ) ;
2019-10-25 07:50:21 +00:00
/// <summary>
/// Retrieves the distance between two points within a timing point that are one beat length apart.
/// </summary>
2021-09-06 12:30:15 +00:00
/// <param name="referenceObject">An object to be used as a reference point for this operation.</param>
2019-10-25 07:50:21 +00:00
/// <returns>The distance between two points residing in the timing point that are one beat length apart.</returns>
2021-09-01 09:05:10 +00:00
float GetBeatSnapDistanceAt ( HitObject referenceObject ) ;
2019-10-25 07:50:21 +00:00
/// <summary>
/// Converts a duration to a distance.
/// </summary>
2021-09-06 12:30:15 +00:00
/// <param name="referenceObject">An object to be used as a reference point for this operation.</param>
2019-10-25 07:50:21 +00:00
/// <param name="duration">The duration to convert.</param>
/// <returns>A value that represents <paramref name="duration"/> as a distance in the timing point.</returns>
2021-09-01 09:05:10 +00:00
float DurationToDistance ( HitObject referenceObject , double duration ) ;
2019-10-25 07:50:21 +00:00
/// <summary>
/// Converts a distance to a duration.
/// </summary>
2021-09-06 12:30:15 +00:00
/// <param name="referenceObject">An object to be used as a reference point for this operation.</param>
2019-10-25 07:50:21 +00:00
/// <param name="distance">The distance to convert.</param>
/// <returns>A value that represents <paramref name="distance"/> as a duration in the timing point.</returns>
2021-09-01 09:05:10 +00:00
double DistanceToDuration ( HitObject referenceObject , float distance ) ;
2019-10-25 07:50:21 +00:00
/// <summary>
/// Converts a distance to a snapped duration.
/// </summary>
2021-09-06 12:30:15 +00:00
/// <param name="referenceObject">An object to be used as a reference point for this operation.</param>
2019-10-25 07:50:21 +00:00
/// <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>
2021-09-01 09:05:10 +00:00
double GetSnappedDurationFromDistance ( HitObject referenceObject , float distance ) ;
2019-10-25 07:50:21 +00:00
/// <summary>
/// Converts an unsnapped distance to a snapped distance.
2020-08-25 09:56:15 +00:00
/// The returned distance will always be floored (as to never exceed the provided <paramref name="distance"/>.
2019-10-25 07:50:21 +00:00
/// </summary>
2021-09-06 12:30:15 +00:00
/// <param name="referenceObject">An object to be used as a reference point for this operation.</param>
2019-10-25 07:50:21 +00:00
/// <param name="distance">The distance to convert.</param>
/// <returns>A value that represents <paramref name="distance"/> snapped to the closest beat of the timing point.</returns>
2021-09-01 09:05:10 +00:00
float GetSnappedDistanceFromDistance ( HitObject referenceObject , float distance ) ;
2019-10-25 07:50:21 +00:00
}
}