1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 15:57:24 +08:00
osu-lazer/osu.Game.Rulesets.Osu/UI/LegacyHitPolicy.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

64 lines
2.4 KiB
C#
Raw Normal View History

2021-02-05 13:31:22 +08:00
// 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.
2022-06-17 15:37:17 +08:00
#nullable disable
using System;
using System.Linq;
2021-02-05 13:31:22 +08:00
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Rulesets.UI;
2021-02-05 13:31:22 +08:00
namespace osu.Game.Rulesets.Osu.UI
{
/// <summary>
/// Ensures that <see cref="HitObject"/>s are hit in order of appearance. The classic note lock.
/// <remarks>
/// Hits will be blocked until the previous <see cref="HitObject"/>s have been judged.
/// </remarks>
/// </summary>
public class LegacyHitPolicy : IHitPolicy
2021-02-05 13:31:22 +08:00
{
public IHitObjectContainer HitObjectContainer { get; set; }
2021-02-05 13:31:22 +08:00
public void HandleHit(DrawableHitObject hitObject)
{
}
public ClickAction CheckHittable(DrawableHitObject hitObject, double time)
2021-02-05 13:31:22 +08:00
{
var aliveObjects = HitObjectContainer.AliveObjects.ToList();
int index = aliveObjects.IndexOf(hitObject);
if (index > 0)
2021-02-05 13:31:22 +08:00
{
var previousHitObject = (DrawableOsuHitObject)aliveObjects[index - 1];
if (previousHitObject.HitObject.StackHeight > 0 && !previousHitObject.AllJudged)
return ClickAction.Ignore;
}
2021-02-05 13:31:22 +08:00
foreach (DrawableHitObject testObject in aliveObjects)
{
if (testObject.AllJudged)
continue;
2021-02-05 13:31:22 +08:00
// if we found the object being checked, we can move on to the final timing test.
if (testObject == hitObject)
break;
2021-02-05 13:31:22 +08:00
// for all other objects, we check for validity and block the hit if any are still valid.
// 3ms of extra leniency to account for slightly unsnapped objects.
if (testObject.HitObject.GetEndTime() + 3 < hitObject.HitObject.StartTime)
return ClickAction.Shake;
}
2021-02-05 13:31:22 +08:00
// stable has `const HitObjectManager.HITTABLE_RANGE = 400;`, which is only used for notelock code.
// probably not a coincidence that this is equivalent to lazer's OsuHitWindows.MISS_WINDOW.
2021-02-05 13:31:22 +08:00
// TODO stable compares to 200 when autopilot is enabled, instead of 400.
return Math.Abs(hitObject.HitObject.StartTime - time) < 400 ? ClickAction.Hit : ClickAction.Shake;
2021-02-05 13:31:22 +08:00
}
}
}