mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 10:33:30 +08:00
Snap based on end position/time of the previous object
This commit is contained in:
parent
c92332d2e4
commit
6da581f3fe
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using JetBrains.Annotations;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Screens.Edit.Compose.Components;
|
||||
|
||||
@ -10,7 +11,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
public class OsuDistanceSnapGrid : CircularDistanceSnapGrid
|
||||
{
|
||||
public OsuDistanceSnapGrid(OsuHitObject hitObject, [CanBeNull] OsuHitObject nextHitObject = null)
|
||||
: base(hitObject.StackedPosition, hitObject.StartTime, nextHitObject?.StartTime)
|
||||
: base(hitObject.StackedEndPosition, hitObject.GetEndTime(), nextHitObject?.StartTime)
|
||||
{
|
||||
Masking = true;
|
||||
}
|
||||
|
@ -92,7 +92,24 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
return null;
|
||||
|
||||
OsuHitObject sourceObject = EditorBeatmap.HitObjects[sourceIndex];
|
||||
OsuHitObject targetObject = sourceIndex + targetOffset < EditorBeatmap.HitObjects.Count ? EditorBeatmap.HitObjects[sourceIndex + targetOffset] : null;
|
||||
|
||||
int targetIndex = sourceIndex + targetOffset;
|
||||
OsuHitObject targetObject = null;
|
||||
|
||||
// Keep advancing the target object while its start time falls before the end time of the source object
|
||||
while (true)
|
||||
{
|
||||
if (targetIndex >= EditorBeatmap.HitObjects.Count)
|
||||
break;
|
||||
|
||||
if (EditorBeatmap.HitObjects[targetIndex].StartTime >= sourceObject.GetEndTime())
|
||||
{
|
||||
targetObject = EditorBeatmap.HitObjects[targetIndex];
|
||||
break;
|
||||
}
|
||||
|
||||
targetIndex++;
|
||||
}
|
||||
|
||||
return new OsuDistanceSnapGrid(sourceObject, targetObject);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user