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 @@ public class TaikoHitWindows : HitWindows
{ 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 @@ public class HitWindows
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 @@ public double HalfWindowFor(HitResult result)
/// </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());
}
}