Skip to content

Commit

Permalink
Merge pull request #568 from LumpBloom7/Hold-input-checks
Browse files Browse the repository at this point in the history
Improve Hold release checks
  • Loading branch information
LumpBloom7 authored Apr 12, 2024
2 parents b1c3e6f + c011b9d commit 21b1808
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableHold.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
Expand Down Expand Up @@ -71,7 +71,6 @@ protected override void OnFree()
base.OnFree();
HoldStartTime = null;
TotalHoldTime = 0;
pressedCount = 0;
}

protected override void UpdateInitialTransforms()
Expand Down Expand Up @@ -218,8 +217,24 @@ private void endHold()
HoldStartTime = null;
}

// Tracks how many inputs are pressing on this HitObject currently
private int pressedCount = 0;
private SentakkiInputManager sentakkiActionInputManager = null!;
internal SentakkiInputManager SentakkiActionInputManager => sentakkiActionInputManager ??= (SentakkiInputManager)GetContainingInputManager();

private int pressedCount
{
get
{
int count = 0;
foreach (var pressedAction in SentakkiActionInputManager.PressedActions)
{
if (pressedAction == SentakkiAction.Key1 + HitObject.Lane)
++count;
}

return count;
}
}

public bool OnPressed(KeyBindingPressEvent<SentakkiAction> e)
{
if (AllJudged)
Expand All @@ -228,8 +243,6 @@ public bool OnPressed(KeyBindingPressEvent<SentakkiAction> e)
if (e.Action != SentakkiAction.Key1 + HitObject.Lane)
return false;

pressedCount++;

if (beginHoldAt(Time.Current - Head.HitObject.StartTime))
{
Head.UpdateResult();
Expand All @@ -250,7 +263,8 @@ public void OnReleased(KeyBindingReleaseEvent<SentakkiAction> e)
return;

// We only release the hold once ALL inputs are released
if (--pressedCount != 0)
// We check for 1 here as drawables receive the event before the counter decrements
if (pressedCount > 1)
return;

endHold();
Expand Down

0 comments on commit 21b1808

Please sign in to comment.