-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate head/tail notes from hold note class
- Loading branch information
Showing
3 changed files
with
127 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteHead.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using osu.Game.Rulesets.Scoring; | ||
|
||
namespace osu.Game.Rulesets.Mania.Objects.Drawables | ||
{ | ||
/// <summary> | ||
/// The head of a <see cref="DrawableHoldNote"/>. | ||
/// </summary> | ||
public class DrawableHoldNoteHead : DrawableNote | ||
{ | ||
private readonly DrawableHoldNote holdNote; | ||
|
||
public DrawableHoldNoteHead(DrawableHoldNote holdNote) | ||
: base(holdNote.HitObject.Head) | ||
{ | ||
this.holdNote = holdNote; | ||
} | ||
|
||
public override bool OnPressed(ManiaAction action) | ||
{ | ||
if (!base.OnPressed(action)) | ||
return false; | ||
|
||
// If the key has been released too early, the user should not receive full score for the release | ||
if (Result.Type == HitResult.Miss) | ||
holdNote.HasBroken = true; | ||
|
||
// The head note also handles early hits before the body, but we want accurate early hits to count as the body being held | ||
// The body doesn't handle these early early hits, so we have to explicitly set the holding state here | ||
holdNote.BeginHold(); | ||
|
||
return true; | ||
} | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTail.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System.Diagnostics; | ||
using osu.Game.Rulesets.Scoring; | ||
|
||
namespace osu.Game.Rulesets.Mania.Objects.Drawables | ||
{ | ||
/// <summary> | ||
/// The tail of a <see cref="DrawableHoldNote"/>. | ||
/// </summary> | ||
public class DrawableHoldNoteTail : DrawableNote | ||
{ | ||
/// <summary> | ||
/// Lenience of release hit windows. This is to make cases where the hold note release | ||
/// is timed alongside presses of other hit objects less awkward. | ||
/// Todo: This shouldn't exist for non-LegacyBeatmapDecoder beatmaps | ||
/// </summary> | ||
private const double release_window_lenience = 1.5; | ||
|
||
private readonly DrawableHoldNote holdNote; | ||
|
||
public DrawableHoldNoteTail(DrawableHoldNote holdNote) | ||
: base(holdNote.HitObject.Tail) | ||
{ | ||
this.holdNote = holdNote; | ||
} | ||
|
||
protected override void CheckForResult(bool userTriggered, double timeOffset) | ||
{ | ||
Debug.Assert(HitObject.HitWindows != null); | ||
|
||
// Factor in the release lenience | ||
timeOffset /= release_window_lenience; | ||
|
||
if (!userTriggered) | ||
{ | ||
if (!HitObject.HitWindows.CanBeHit(timeOffset)) | ||
ApplyResult(r => r.Type = HitResult.Miss); | ||
|
||
return; | ||
} | ||
|
||
var result = HitObject.HitWindows.ResultFor(timeOffset); | ||
if (result == HitResult.None) | ||
return; | ||
|
||
ApplyResult(r => | ||
{ | ||
if (holdNote.HasBroken && (result == HitResult.Perfect || result == HitResult.Perfect)) | ||
result = HitResult.Good; | ||
r.Type = result; | ||
}); | ||
} | ||
|
||
public override bool OnPressed(ManiaAction action) => false; // Tail doesn't handle key down | ||
|
||
public override bool OnReleased(ManiaAction action) | ||
{ | ||
// Make sure that the user started holding the key during the hold note | ||
if (!holdNote.HoldStartTime.HasValue) | ||
return false; | ||
|
||
if (action != Action.Value) | ||
return false; | ||
|
||
UpdateResult(true); | ||
|
||
// Handled by the hold note, which will set holding = false | ||
return false; | ||
} | ||
} | ||
} |