Add rewinding support

This commit is contained in:
smoogipoo
2020-08-19 01:37:24 +09:00
parent 99315a4aa7
commit 4d4d9b7356

View File

@ -57,7 +57,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
/// <summary> /// <summary>
/// Whether the hold note has been released potentially without having caused a break. /// Whether the hold note has been released potentially without having caused a break.
/// </summary> /// </summary>
private bool hasReleased; private double? releaseTime;
public DrawableHoldNote(HoldNote hitObject) public DrawableHoldNote(HoldNote hitObject)
: base(hitObject) : base(hitObject)
@ -175,8 +175,11 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
{ {
base.Update(); base.Update();
// Decrease the size of the body while the hold note is held and the head has been hit. if (Time.Current < releaseTime)
if (Head.IsHit && !hasReleased) releaseTime = null;
// Decrease the size of the body while the hold note is held and the head has been hit. This stops at the very first release point.
if (Head.IsHit && releaseTime == null)
{ {
float heightDecrease = (float)(Math.Max(0, Time.Current - HitObject.StartTime) / HitObject.Duration); float heightDecrease = (float)(Math.Max(0, Time.Current - HitObject.StartTime) / HitObject.Duration);
bodyContainer.Height = MathHelper.Clamp(1 - heightDecrease, 0, 1); bodyContainer.Height = MathHelper.Clamp(1 - heightDecrease, 0, 1);
@ -250,7 +253,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
if (!Tail.IsHit) if (!Tail.IsHit)
HasBroken = true; HasBroken = true;
hasReleased = true; releaseTime = Time.Current;
} }
private void endHold() private void endHold()