Snap to stack in osu! composer when dragging to any of the items on it

Previously it would be required to drag to the starting position of the
stack which feels weird.
This commit is contained in:
Bartłomiej Dach 2024-07-09 13:58:58 +02:00
parent ec9040798f
commit 9cc0e0137b
No known key found for this signature in database
1 changed files with 6 additions and 0 deletions

View File

@ -295,6 +295,12 @@ private bool snapToVisibleBlueprints(Vector2 screenSpacePosition, out SnapResult
if (Vector2.Distance(closestSnapPosition, screenSpacePosition) < snapRadius)
{
// if the snap target is a stacked object, snap to its unstacked position rather than its stacked position.
// this is intended to make working with stacks easier (because thanks to this, you can drag an object to any
// of the items on the stack to add an object to it, rather than having to drag to the position of the *first* object on it at all times).
if (b.Item is OsuHitObject osuObject && osuObject.StackOffset != Vector2.Zero)
closestSnapPosition = b.ToScreenSpace(b.ToLocalSpace(closestSnapPosition) - osuObject.StackOffset);
// only return distance portion, since time is not really valid
snapResult = new SnapResult(closestSnapPosition, null, playfield);
return true;