Create SnapResult class to hold various snapping results

This commit is contained in:
Dean Herbert
2020-05-20 18:19:21 +09:00
parent 3354d48a38
commit c46bfc2532
10 changed files with 70 additions and 61 deletions

View File

@ -8,13 +8,11 @@ namespace osu.Game.Rulesets.Edit
public interface IPositionSnapProvider
{
/// <summary>
/// Given a position (local to the provider), find a valid time snap
/// Given a position, find a valid time snap.
/// </summary>
/// <param name="position">The local position to be snapped.</param>
/// <param name="screenSpacePosition">The screen-space position to be snapped.</param>
/// <returns>The time and position post-snapping.</returns>
(Vector2 position, double time) SnapPositionToValidTime(Vector2 position);
(Vector2 position, double time) SnapScreenSpacePositionToValidTime(Vector2 screenSpacePosition);
SnapResult SnapScreenSpacePositionToValidTime(Vector2 screenSpacePosition);
/// <summary>
/// Retrieves the distance between two points within a timing point that are one beat length apart.
@ -55,4 +53,23 @@ namespace osu.Game.Rulesets.Edit
/// <returns>A value that represents <paramref name="distance"/> snapped to the closest beat of the timing point.</returns>
float GetSnappedDistanceFromDistance(double referenceTime, float distance);
}
public class SnapResult
{
/// <summary>
/// The screen space position, potentially altered for snapping.
/// </summary>
public Vector2 ScreenSpacePosition;
/// <summary>
/// The resultant time for snapping, if a value could be attained.
/// </summary>
public double? Time;
public SnapResult(Vector2 screenSpacePosition, double? time)
{
ScreenSpacePosition = screenSpacePosition;
Time = time;
}
}
}