mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 14:46:38 +09:00
Use empty hitwindows instead of null
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user