1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 19:03:08 +08:00

Remove holding property in favor of a nullable hold start time.

This commit is contained in:
smoogipooo 2017-05-26 18:56:21 +09:00
parent e4b59314ea
commit f294fef29b
2 changed files with 8 additions and 28 deletions

View File

@ -27,33 +27,15 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
private readonly Container<DrawableHoldNoteTick> tickContainer; private readonly Container<DrawableHoldNoteTick> tickContainer;
/// <summary> /// <summary>
/// Time at which the user started holding this hold note. /// Time at which the user started holding this hold note. Null if the user is not holding this hold note.
/// </summary> /// </summary>
private double holdStartTime; private double? holdStartTime;
/// <summary> /// <summary>
/// Whether the hold note has been released too early and shouldn't give full score for the release. /// Whether the hold note has been released too early and shouldn't give full score for the release.
/// </summary> /// </summary>
private bool hasBroken; private bool hasBroken;
private bool _holding;
/// <summary>
/// Whether the user is currently holding the hold note.
/// </summary>
private bool holding
{
get { return _holding; }
set
{
if (_holding == value)
return;
_holding = value;
if (holding)
holdStartTime = Time.Current;
}
}
public DrawableHoldNote(HoldNote hitObject, Bindable<Key> key = null) public DrawableHoldNote(HoldNote hitObject, Bindable<Key> key = null)
: base(hitObject, key) : base(hitObject, key)
{ {
@ -91,7 +73,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
{ {
var drawableTick = new DrawableHoldNoteTick(tick) var drawableTick = new DrawableHoldNoteTick(tick)
{ {
IsHolding = () => holding,
HoldStartTime = () => holdStartTime HoldStartTime = () => holdStartTime
}; };
@ -142,7 +123,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
// The user has pressed during the body of the hold note, after the head note and its hit windows have passed // The user has pressed during the body of the hold note, after the head note and its hit windows have passed
// and within the limited range of the above if-statement. This state will be managed by the head note if the // and within the limited range of the above if-statement. This state will be managed by the head note if the
// user has pressed during the hit windows of the head note. // user has pressed during the hit windows of the head note.
holding = true; holdStartTime = Time.Current;
return true; return true;
} }
@ -150,13 +131,13 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
protected override bool OnKeyUp(InputState state, KeyUpEventArgs args) protected override bool OnKeyUp(InputState state, KeyUpEventArgs args)
{ {
// Make sure that the user started holding the key during the hold note // Make sure that the user started holding the key during the hold note
if (!holding) if (!holdStartTime.HasValue)
return false; return false;
if (args.Key != Key) if (args.Key != Key)
return false; return false;
holding = false; holdStartTime = null;
// If the key has been released too early, the user should not receive full score for the release // If the key has been released too early, the user should not receive full score for the release
if (!tail.Judged) if (!tail.Judged)
@ -196,7 +177,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
// The head note also handles early hits before the body, but we want accurate early hits to count as the body being held // 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 // The body doesn't handle these early early hits, so we have to explicitly set the holding state here
holdNote.holding = true; holdNote.holdStartTime = Time.Current;
return true; return true;
} }
@ -234,7 +215,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
protected override bool OnKeyUp(InputState state, KeyUpEventArgs args) protected override bool OnKeyUp(InputState state, KeyUpEventArgs args)
{ {
// Make sure that the user started holding the key during the hold note // Make sure that the user started holding the key during the hold note
if (!holdNote.holding) if (!holdNote.holdStartTime.HasValue)
return false; return false;
if (Judgement.Result != HitResult.None) if (Judgement.Result != HitResult.None)

View File

@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
/// <summary> /// <summary>
/// References the time at which the user started holding the hold note. /// References the time at which the user started holding the hold note.
/// </summary> /// </summary>
public Func<double> HoldStartTime; public Func<double?> HoldStartTime;
/// <summary> /// <summary>
/// References whether the user is currently holding the hold note. /// References whether the user is currently holding the hold note.
@ -90,7 +90,6 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
if (Time.Current < HitObject.StartTime) if (Time.Current < HitObject.StartTime)
return; return;
if (HoldStartTime?.Invoke() > HitObject.StartTime) if (HoldStartTime?.Invoke() > HitObject.StartTime)
return; return;