Skip to content

Commit

Permalink
Handle lane change via snapping
Browse files Browse the repository at this point in the history
Since we provide lane info already in snapping, we don't actually need to figure that out in HandleMovement
  • Loading branch information
LumpBloom7 committed Oct 31, 2023
1 parent e32c53f commit b7470cc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
25 changes: 25 additions & 0 deletions osu.Game.Rulesets.Sentakki/Edit/SentakkiBlueprintContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,31 @@ public SentakkiBlueprintContainer(HitObjectComposer composer)

protected override SelectionHandler<HitObject> CreateSelectionHandler() => new SentakkiSelectionHandler();

protected override bool ApplySnapResult(SelectionBlueprint<HitObject>[] blueprints, SnapResult result)
{
if (!base.ApplySnapResult(blueprints, result))
return false;

if (blueprints.All(b => b.Item is SentakkiLanedHitObject))
{
SentakkiSnapResult senSnapResult = (SentakkiSnapResult)result;

int offset = senSnapResult.Lane - ((SentakkiLanedHitObject)blueprints.First().Item).Lane;
if (offset != 0)
{
Beatmap.PerformOnSelection(delegate (HitObject ho)
{
var lho = (SentakkiLanedHitObject)ho;

lho.Lane = (lho.Lane + offset).NormalizePath();
Beatmap.Update(ho);
});
}
}

return true;
}

public override HitObjectSelectionBlueprint CreateHitObjectBlueprintFor(HitObject hitObject)
{
switch (hitObject)
Expand Down
20 changes: 0 additions & 20 deletions osu.Game.Rulesets.Sentakki/Edit/SentakkiSelectionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,28 +57,8 @@ public SentakkiSelectionHandler()

public override bool HandleMovement(MoveSelectionEvent<HitObject> moveEvent)
{
// The lanes are arranged in a circular fashion
// Blindly deriving new angle by adding the vector to each selection point will yield unintuitive results, such as all notes moving towards the drag direction
//
// Instead, we should derive an angle delta by comparing the current mouse position and the drag origin
// The drag origin is the blueprint most closest to the mouse during the beginning of the drag, rather than the earliest note (see "SentakkiBlueprintContainer.SortForMovement")
// This allows a more intuitive "steering wheel" like lane adjustments
if (SelectedBlueprints.All(bp => bp.Item is SentakkiLanedHitObject))
{
var oldPosition = moveEvent.Blueprint.ScreenSpaceSelectionPoint;
var newPosition = moveEvent.Blueprint.ScreenSpaceSelectionPoint + moveEvent.ScreenSpaceDelta;
var playfieldCentre = ToScreenSpace(new Vector2(300));
float angleDelta = playfieldCentre.GetDegreesFromPosition(newPosition) - playfieldCentre.GetDegreesFromPosition(oldPosition);

foreach (var bp in SelectedBlueprints.ToList())
{
var laned = (SentakkiLanedHitObject)bp.Item;
float currentAngle = laned.Lane.GetRotationForLane() + angleDelta;
laned.Lane = currentAngle.GetNoteLaneFromDegrees();
}

return true;
}

if (SelectedBlueprints.All(bp => bp.Item is Touch))
{
Expand Down

0 comments on commit b7470cc

Please sign in to comment.