diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableHit.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableHit.cs index 1b8d95c0cf..349e8e8fb0 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableHit.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableHit.cs @@ -87,7 +87,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables switch (State.Value) { case ArmedState.Idle: - this.Delay(HitObject.HitWindows.Miss / 2).Expire(); + this.Delay(HitObject.HitWindows.HalfWindowFor(HitResult.Miss)).Expire(); break; case ArmedState.Miss: this.FadeOut(100) diff --git a/osu.Game/Rulesets/Objects/HitWindows.cs b/osu.Game/Rulesets/Objects/HitWindows.cs index 1d09a3ad51..2762be4a54 100644 --- a/osu.Game/Rulesets/Objects/HitWindows.cs +++ b/osu.Game/Rulesets/Objects/HitWindows.cs @@ -65,37 +65,64 @@ namespace osu.Game.Rulesets.Objects } /// - /// Retrieves the hit result for a time offset. + /// Retrieves the for a time offset. /// - /// The time offset. This should always be a positive value indicating the absolute time offset. + /// The time offset. /// The hit result, or null if doesn't result in a judgement. public HitResult? ResultFor(double timeOffset) { timeOffset = Math.Abs(timeOffset); - if (timeOffset <= Perfect / 2) + if (timeOffset <= HalfWindowFor(HitResult.Perfect)) return HitResult.Perfect; - if (timeOffset <= Great / 2) + if (timeOffset <= HalfWindowFor(HitResult.Great)) return HitResult.Great; - if (timeOffset <= Good / 2) + if (timeOffset <= HalfWindowFor(HitResult.Good)) return HitResult.Good; - if (timeOffset <= Ok / 2) + if (timeOffset <= HalfWindowFor(HitResult.Ok)) return HitResult.Ok; - if (timeOffset <= Meh / 2) + if (timeOffset <= HalfWindowFor(HitResult.Meh)) return HitResult.Meh; - if (timeOffset <= Miss / 2) + if (timeOffset <= HalfWindowFor(HitResult.Miss)) return HitResult.Miss; return null; } + /// + /// Retrieves half the hit window for a . + /// This is useful if the of the hit window for one half of the hittable range of a is required. + /// + /// The expected . + /// One half of the hit window for . + public double HalfWindowFor(HitResult result) + { + switch (result) + { + case HitResult.Perfect: + return Perfect / 2; + case HitResult.Great: + return Great / 2; + case HitResult.Good: + return Good / 2; + case HitResult.Ok: + return Ok / 2; + case HitResult.Meh: + return Meh / 2; + case HitResult.Miss: + return Miss / 2; + default: + throw new ArgumentException(nameof(result)); + } + } + /// /// Given a time offset, whether the can ever be hit in the future. /// This happens if > . /// /// The time offset. /// Whether the can be hit at any point in the future from this time offset. - public bool CanBeHit(double timeOffset) => timeOffset <= Meh / 2; + public bool CanBeHit(double timeOffset) => timeOffset <= HalfWindowFor(HitResult.Meh); /// /// Multiplies all hit windows by a value.