mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 09:27:29 +08:00
Use empty hitwindows instead of null
This commit is contained in:
parent
93d2c3d7a1
commit
51bf600ea7
@ -93,7 +93,7 @@ namespace osu.Game.Rulesets.Catch.Objects
|
||||
Scale = 1.0f - 0.7f * (difficulty.CircleSize - 5) / 5;
|
||||
}
|
||||
|
||||
protected override HitWindows CreateHitWindows() => null;
|
||||
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||
}
|
||||
|
||||
public enum FruitVisualRepresentation
|
||||
|
@ -101,6 +101,6 @@ namespace osu.Game.Rulesets.Mania.Objects
|
||||
|
||||
public override Judgement CreateJudgement() => new HoldNoteJudgement();
|
||||
|
||||
protected override HitWindows CreateHitWindows() => null;
|
||||
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,6 @@ namespace osu.Game.Rulesets.Mania.Objects
|
||||
{
|
||||
public override Judgement CreateJudgement() => new HoldNoteTickJudgement();
|
||||
|
||||
protected override HitWindows CreateHitWindows() => null;
|
||||
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,6 @@ namespace osu.Game.Rulesets.Osu.Objects
|
||||
|
||||
public override Judgement CreateJudgement() => new OsuJudgement();
|
||||
|
||||
protected override HitWindows CreateHitWindows() => null;
|
||||
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -205,6 +205,6 @@ namespace osu.Game.Rulesets.Osu.Objects
|
||||
|
||||
public override Judgement CreateJudgement() => new OsuJudgement();
|
||||
|
||||
protected override HitWindows CreateHitWindows() => null;
|
||||
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,6 @@ namespace osu.Game.Rulesets.Osu.Objects
|
||||
|
||||
public override Judgement CreateJudgement() => new OsuSliderTailJudgement();
|
||||
|
||||
protected override HitWindows CreateHitWindows() => null;
|
||||
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,6 @@ namespace osu.Game.Rulesets.Osu.Objects
|
||||
|
||||
public override Judgement CreateJudgement() => new OsuJudgement();
|
||||
|
||||
protected override HitWindows CreateHitWindows() => null;
|
||||
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,6 @@ namespace osu.Game.Rulesets.Osu.Objects
|
||||
|
||||
public override Judgement CreateJudgement() => new OsuJudgement();
|
||||
|
||||
protected override HitWindows CreateHitWindows() => null;
|
||||
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -88,6 +88,6 @@ namespace osu.Game.Rulesets.Taiko.Objects
|
||||
|
||||
public override Judgement CreateJudgement() => new TaikoDrumRollJudgement();
|
||||
|
||||
protected override HitWindows CreateHitWindows() => null;
|
||||
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,6 @@ namespace osu.Game.Rulesets.Taiko.Objects
|
||||
|
||||
public override Judgement CreateJudgement() => new TaikoDrumRollTickJudgement();
|
||||
|
||||
protected override HitWindows CreateHitWindows() => null;
|
||||
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,6 @@ namespace osu.Game.Rulesets.Taiko.Objects
|
||||
{
|
||||
public override Judgement CreateJudgement() => new TaikoStrongJudgement();
|
||||
|
||||
protected override HitWindows CreateHitWindows() => null;
|
||||
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,6 @@ namespace osu.Game.Rulesets.Taiko.Objects
|
||||
|
||||
public override Judgement CreateJudgement() => new TaikoSwellJudgement();
|
||||
|
||||
protected override HitWindows CreateHitWindows() => null;
|
||||
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,6 @@ namespace osu.Game.Rulesets.Taiko.Objects
|
||||
{
|
||||
public override Judgement CreateJudgement() => new TaikoSwellTickJudgement();
|
||||
|
||||
protected override HitWindows CreateHitWindows() => null;
|
||||
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,6 @@ namespace osu.Game.Rulesets.Objects
|
||||
/// <summary>
|
||||
/// The hit windows for this <see cref="HitObject"/>.
|
||||
/// </summary>
|
||||
[CanBeNull]
|
||||
public HitWindows HitWindows { get; set; }
|
||||
|
||||
private readonly List<HitObject> nestedHitObjects = new List<HitObject>();
|
||||
@ -113,11 +112,8 @@ namespace osu.Game.Rulesets.Objects
|
||||
nestedHitObjects.Sort((h1, h2) => h1.StartTime.CompareTo(h2.StartTime));
|
||||
|
||||
foreach (var h in nestedHitObjects)
|
||||
{
|
||||
h.HitWindows = HitWindows;
|
||||
h.ApplyDefaults(controlPointInfo, difficulty);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||
{
|
||||
@ -147,7 +143,7 @@ namespace osu.Game.Rulesets.Objects
|
||||
/// This will only be invoked if <see cref="HitWindows"/> hasn't been set externally (e.g. from a <see cref="BeatmapConverter{T}"/>.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
[CanBeNull]
|
||||
[NotNull]
|
||||
protected virtual HitWindows CreateHitWindows() => new HitWindows();
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,6 @@ namespace osu.Game.Rulesets.Objects.Legacy.Mania
|
||||
{
|
||||
public float X { get; set; }
|
||||
|
||||
protected override HitWindows CreateHitWindows() => null;
|
||||
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,6 @@ namespace osu.Game.Rulesets.Objects.Legacy.Mania
|
||||
|
||||
public double Duration => EndTime - StartTime;
|
||||
|
||||
protected override HitWindows CreateHitWindows() => null;
|
||||
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,6 @@ namespace osu.Game.Rulesets.Objects.Legacy.Mania
|
||||
{
|
||||
public float X { get; set; }
|
||||
|
||||
protected override HitWindows CreateHitWindows() => null;
|
||||
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,6 @@ namespace osu.Game.Rulesets.Objects.Legacy.Mania
|
||||
|
||||
public float X { get; set; }
|
||||
|
||||
protected override HitWindows CreateHitWindows() => null;
|
||||
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,6 @@ namespace osu.Game.Rulesets.Objects.Legacy.Osu
|
||||
|
||||
public int ComboOffset { get; set; }
|
||||
|
||||
protected override HitWindows CreateHitWindows() => null;
|
||||
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,6 @@ namespace osu.Game.Rulesets.Objects.Legacy.Osu
|
||||
|
||||
public int ComboOffset { get; set; }
|
||||
|
||||
protected override HitWindows CreateHitWindows() => null;
|
||||
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Osu
|
||||
|
||||
public float Y => Position.Y;
|
||||
|
||||
protected override HitWindows CreateHitWindows() => null;
|
||||
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||
|
||||
public bool NewCombo { get; set; }
|
||||
|
||||
|
@ -10,6 +10,6 @@ namespace osu.Game.Rulesets.Objects.Legacy.Taiko
|
||||
/// </summary>
|
||||
internal sealed class ConvertHit : HitObject
|
||||
{
|
||||
protected override HitWindows CreateHitWindows() => null;
|
||||
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,6 @@ namespace osu.Game.Rulesets.Objects.Legacy.Taiko
|
||||
/// </summary>
|
||||
internal sealed class ConvertSlider : Legacy.ConvertSlider
|
||||
{
|
||||
protected override HitWindows CreateHitWindows() => null;
|
||||
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,6 @@ namespace osu.Game.Rulesets.Objects.Legacy.Taiko
|
||||
|
||||
public double Duration => EndTime - StartTime;
|
||||
|
||||
protected override HitWindows CreateHitWindows() => null;
|
||||
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
|
||||
@ -30,6 +31,17 @@ namespace osu.Game.Rulesets.Scoring
|
||||
private double meh;
|
||||
private double miss;
|
||||
|
||||
/// <summary>
|
||||
/// An empty <see cref="HitWindows"/> with only <see cref="HitResult.Miss"/> and <see cref="HitResult.Perfect"/>.
|
||||
/// No time values are provided (meaning instantaneous hit or miss).
|
||||
/// </summary>
|
||||
public static HitWindows Empty => new EmptyHitWindows();
|
||||
|
||||
public HitWindows()
|
||||
{
|
||||
Debug.Assert(GetRanges().Length >= 1, $"{nameof(HitWindows)}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the <see cref="HitResult"/> with the largest hit window that produces a successful hit.
|
||||
/// </summary>
|
||||
@ -168,6 +180,29 @@ namespace osu.Game.Rulesets.Scoring
|
||||
/// Defaults are provided but can be overridden to customise for a ruleset.
|
||||
/// </summary>
|
||||
protected virtual DifficultyRange[] GetRanges() => base_ranges;
|
||||
|
||||
public class EmptyHitWindows : HitWindows
|
||||
{
|
||||
private static readonly DifficultyRange[] ranges =
|
||||
{
|
||||
new DifficultyRange(HitResult.Perfect, 0, 0, 0),
|
||||
new DifficultyRange(HitResult.Miss, 0, 0, 0),
|
||||
};
|
||||
|
||||
public override bool IsHitResultAllowed(HitResult result)
|
||||
{
|
||||
switch (result)
|
||||
{
|
||||
case HitResult.Great:
|
||||
case HitResult.Miss:
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override DifficultyRange[] GetRanges() => ranges;
|
||||
}
|
||||
}
|
||||
|
||||
public struct DifficultyRange
|
||||
|
@ -426,11 +426,11 @@ namespace osu.Game.Rulesets.UI
|
||||
{
|
||||
foreach (var h in Objects)
|
||||
{
|
||||
if (h.HitWindows != null)
|
||||
if (h.HitWindows.WindowFor(HitResult.Miss) > 0)
|
||||
return h.HitWindows;
|
||||
|
||||
foreach (var n in h.NestedHitObjects)
|
||||
if (n.HitWindows != null)
|
||||
if (h.HitWindows.WindowFor(HitResult.Miss) > 0)
|
||||
return n.HitWindows;
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ namespace osu.Game.Screens.Play.HUD
|
||||
|
||||
private void onNewJudgement(JudgementResult result)
|
||||
{
|
||||
if (result.HitObject.HitWindows == null)
|
||||
if (result.HitObject.HitWindows.WindowFor(HitResult.Miss) == 0)
|
||||
return;
|
||||
|
||||
foreach (var c in Children)
|
||||
|
Loading…
Reference in New Issue
Block a user