1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 10:52:53 +08:00

Autodetect LowestSuccessfulHitResult

This commit is contained in:
Ivan Pavluk 2018-12-12 17:15:59 +07:00
parent e49e2fda9e
commit 28b033bd99
2 changed files with 13 additions and 5 deletions

View File

@ -17,8 +17,6 @@ namespace osu.Game.Rulesets.Taiko.Objects
{ HitResult.Miss, (270, 190, 140) },
};
protected override HitResult LowestSuccessfulHitResult => HitResult.Good;
public override bool IsHitResultAllowed(HitResult result)
{
switch (result)

View File

@ -51,9 +51,19 @@ namespace osu.Game.Rulesets.Objects
public double Miss { get; protected set; }
/// <summary>
/// The <see cref="HitResult"/> with the largest hit window that produces a successful hit.
/// Retrieves the <see cref="HitResult"/> with the largest hit window that produces a successful hit.
/// </summary>
protected virtual HitResult LowestSuccessfulHitResult => HitResult.Meh;
/// <returns>The lowest allowed successful <see cref="HitResult"/>.</returns>
protected HitResult LowestSuccessfulHitResult()
{
for (var result = HitResult.Meh; result <= HitResult.Perfect; ++result)
{
if (IsHitResultAllowed(result))
return result;
}
return HitResult.None;
}
/// <summary>
/// Check whether it is possible to achieve the provided <see cref="HitResult"/>.
@ -137,6 +147,6 @@ namespace osu.Game.Rulesets.Objects
/// </summary>
/// <param name="timeOffset">The time offset.</param>
/// <returns>Whether the <see cref="HitObject"/> can be hit at any point in the future from this time offset.</returns>
public bool CanBeHit(double timeOffset) => timeOffset <= HalfWindowFor(LowestSuccessfulHitResult);
public bool CanBeHit(double timeOffset) => timeOffset <= HalfWindowFor(LowestSuccessfulHitResult());
}
}