mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 01:09:57 +09:00
Refactor flow of snapping through HitObjectComposer
This commit is contained in:
@ -2,9 +2,11 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osuTK;
|
||||
|
||||
@ -12,6 +14,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
public abstract class CircularDistanceSnapGrid : DistanceSnapGrid
|
||||
{
|
||||
[Resolved]
|
||||
private HitObjectComposer composer { get; set; }
|
||||
|
||||
protected CircularDistanceSnapGrid(HitObject hitObject, Vector2 centrePosition)
|
||||
: base(hitObject, centrePosition)
|
||||
{
|
||||
@ -63,7 +68,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
}
|
||||
}
|
||||
|
||||
public override Vector2 GetSnappedPosition(Vector2 position)
|
||||
public override (Vector2 position, double time) GetSnappedPosition(Vector2 position)
|
||||
{
|
||||
Vector2 direction = position - CentrePosition;
|
||||
|
||||
@ -76,7 +81,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
int radialCount = Math.Max(1, (int)Math.Round(distance / radius));
|
||||
|
||||
Vector2 normalisedDirection = direction * new Vector2(1f / distance);
|
||||
return CentrePosition + normalisedDirection * radialCount * radius;
|
||||
Vector2 snappedPosition = CentrePosition + normalisedDirection * radialCount * radius;
|
||||
|
||||
return (snappedPosition, StartTime + composer.GetSnappedDurationFromDistance(StartTime, (snappedPosition - CentrePosition).Length));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user