1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:27:29 +08:00

Apply NRT to new LegacyHitPolicy class (and other implementations)

This commit is contained in:
Dean Herbert 2023-09-01 16:54:35 +09:00
parent 38e3459391
commit c75b14c729
3 changed files with 14 additions and 11 deletions

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
#nullable disable
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI;
@ -14,7 +12,7 @@ namespace osu.Game.Rulesets.Osu.UI
/// </summary>
public class AnyOrderHitPolicy : IHitPolicy
{
public IHitObjectContainer HitObjectContainer { get; set; }
public IHitObjectContainer HitObjectContainer { get; set; } = null!;
public ClickAction CheckHittable(DrawableHitObject hitObject, double time, HitResult result) => ClickAction.Hit;

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
#nullable disable
using System;
using System.Linq;
using osu.Game.Rulesets.Objects;
@ -22,7 +20,7 @@ namespace osu.Game.Rulesets.Osu.UI
/// </summary>
public class LegacyHitPolicy : IHitPolicy
{
public IHitObjectContainer HitObjectContainer { get; set; }
public IHitObjectContainer? HitObjectContainer { get; set; }
private readonly double hittableRange;
@ -37,6 +35,9 @@ namespace osu.Game.Rulesets.Osu.UI
public virtual ClickAction CheckHittable(DrawableHitObject hitObject, double time, HitResult result)
{
if (HitObjectContainer == null)
throw new InvalidOperationException($"{nameof(HitObjectContainer)} should be set before {nameof(CheckHittable)} is called.");
var aliveObjects = HitObjectContainer.AliveObjects.ToList();
int index = aliveObjects.IndexOf(hitObject);

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
#nullable disable
using System;
using System.Collections.Generic;
using osu.Game.Rulesets.Objects;
@ -23,11 +21,14 @@ namespace osu.Game.Rulesets.Osu.UI
/// </summary>
public class StartTimeOrderedHitPolicy : IHitPolicy
{
public IHitObjectContainer HitObjectContainer { get; set; }
public IHitObjectContainer? HitObjectContainer { get; set; }
public ClickAction CheckHittable(DrawableHitObject hitObject, double time, HitResult _)
{
DrawableHitObject blockingObject = null;
if (HitObjectContainer == null)
throw new InvalidOperationException($"{nameof(HitObjectContainer)} should be set before {nameof(CheckHittable)} is called.");
DrawableHitObject? blockingObject = null;
foreach (var obj in enumerateHitObjectsUpTo(hitObject.HitObject.StartTime))
{
@ -48,6 +49,9 @@ namespace osu.Game.Rulesets.Osu.UI
public void HandleHit(DrawableHitObject hitObject)
{
if (HitObjectContainer == null)
throw new InvalidOperationException($"{nameof(HitObjectContainer)} should be set before {nameof(HandleHit)} is called.");
// Hitobjects which themselves don't block future hitobjects don't cause misses (e.g. slider ticks, spinners).
if (!hitObjectCanBlockFutureHits(hitObject))
return;
@ -75,7 +79,7 @@ namespace osu.Game.Rulesets.Osu.UI
private IEnumerable<DrawableHitObject> enumerateHitObjectsUpTo(double targetTime)
{
foreach (var obj in HitObjectContainer.AliveObjects)
foreach (var obj in HitObjectContainer!.AliveObjects)
{
if (obj.HitObject.StartTime >= targetTime)
yield break;