mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 16:59:53 +09:00
Limit shake duration to ensure it doesn't overlap miss window
This commit is contained in:
@ -89,7 +89,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
var result = HitObject.HitWindows.ResultFor(timeOffset);
|
var result = HitObject.HitWindows.ResultFor(timeOffset);
|
||||||
if (result == HitResult.None)
|
if (result == HitResult.None)
|
||||||
{
|
{
|
||||||
Shake();
|
Shake(Math.Abs(timeOffset) - HitObject.HitWindows.HalfWindowFor(HitResult.Miss));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
private OsuInputManager osuActionInputManager;
|
private OsuInputManager osuActionInputManager;
|
||||||
internal OsuInputManager OsuActionInputManager => osuActionInputManager ?? (osuActionInputManager = GetContainingInputManager() as OsuInputManager);
|
internal OsuInputManager OsuActionInputManager => osuActionInputManager ?? (osuActionInputManager = GetContainingInputManager() as OsuInputManager);
|
||||||
|
|
||||||
protected virtual void Shake() => shakeContainer.Shake();
|
protected virtual void Shake(double maximumLength) => shakeContainer.Shake(maximumLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ComboResult
|
public enum ComboResult
|
||||||
|
@ -30,8 +30,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
Position = slider.CurvePositionAt(completionProgress);
|
Position = slider.CurvePositionAt(completionProgress);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action OnShake;
|
public Action<double> OnShake;
|
||||||
|
|
||||||
protected override void Shake() => OnShake?.Invoke();
|
protected override void Shake(double maximumLength) => OnShake?.Invoke(maximumLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,16 +14,26 @@ namespace osu.Game.Graphics.Containers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Shake the contents of this container.
|
/// Shake the contents of this container.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Shake()
|
/// <param name="maximumLength">The maximum length the shake should last.</param>
|
||||||
|
public void Shake(double maximumLength)
|
||||||
{
|
{
|
||||||
const float shake_amount = 8;
|
const float shake_amount = 8;
|
||||||
const float shake_duration = 30;
|
const float shake_duration = 30;
|
||||||
|
|
||||||
this.MoveToX(shake_amount, shake_duration / 2, Easing.OutSine).Then()
|
// if we don't have enough time, don't bother shaking.
|
||||||
.MoveToX(-shake_amount, shake_duration, Easing.InOutSine).Then()
|
if (maximumLength < shake_duration * 2)
|
||||||
.MoveToX(shake_amount, shake_duration, Easing.InOutSine).Then()
|
return;
|
||||||
.MoveToX(-shake_amount, shake_duration, Easing.InOutSine).Then()
|
|
||||||
.MoveToX(0, shake_duration / 2, Easing.InSine);
|
var sequence = this.MoveToX(shake_amount, shake_duration / 2, Easing.OutSine).Then()
|
||||||
|
.MoveToX(-shake_amount, shake_duration, Easing.InOutSine).Then();
|
||||||
|
|
||||||
|
// if we don't have enough time for the second shake, skip it.
|
||||||
|
if (maximumLength > shake_duration * 4)
|
||||||
|
sequence = sequence
|
||||||
|
.MoveToX(shake_amount, shake_duration, Easing.InOutSine).Then()
|
||||||
|
.MoveToX(-shake_amount, shake_duration, Easing.InOutSine).Then();
|
||||||
|
|
||||||
|
sequence.MoveToX(0, shake_duration / 2, Easing.InSine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user