mirror of
https://github.com/osukey/osukey.git
synced 2025-05-30 09:57:21 +09:00
Add object-ordered hit policy
This commit is contained in:
parent
6c78d308a4
commit
a4551dc1ee
55
osu.Game.Rulesets.Osu/UI/ObjectOrderedHitPolicy.cs
Normal file
55
osu.Game.Rulesets.Osu/UI/ObjectOrderedHitPolicy.cs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||||
|
|
||||||
|
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 ObjectOrderedHitPolicy : IHitPolicy
|
||||||
|
{
|
||||||
|
private IEnumerable<DrawableHitObject> hitObjects;
|
||||||
|
|
||||||
|
public void SetHitObjects(IEnumerable<DrawableHitObject> hitObjects) => this.hitObjects = hitObjects;
|
||||||
|
|
||||||
|
public bool IsHittable(DrawableHitObject hitObject, double time) => enumerateHitObjectsUpTo(hitObject.HitObject.StartTime).All(obj => obj.AllJudged);
|
||||||
|
|
||||||
|
public void HandleHit(DrawableHitObject hitObject)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerable<DrawableHitObject> enumerateHitObjectsUpTo(double targetTime)
|
||||||
|
{
|
||||||
|
foreach (var obj in hitObjects)
|
||||||
|
{
|
||||||
|
if (obj.HitObject.StartTime >= targetTime)
|
||||||
|
yield break;
|
||||||
|
|
||||||
|
switch (obj)
|
||||||
|
{
|
||||||
|
case DrawableSpinner _:
|
||||||
|
continue;
|
||||||
|
|
||||||
|
case DrawableSlider slider:
|
||||||
|
yield return slider.HeadCircle;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
yield return obj;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -31,7 +31,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
private readonly ProxyContainer spinnerProxies;
|
private readonly ProxyContainer spinnerProxies;
|
||||||
private readonly JudgementContainer<DrawableOsuJudgement> judgementLayer;
|
private readonly JudgementContainer<DrawableOsuJudgement> judgementLayer;
|
||||||
private readonly FollowPointRenderer followPoints;
|
private readonly FollowPointRenderer followPoints;
|
||||||
private readonly StartTimeOrderedHitPolicy hitPolicy;
|
private readonly IHitPolicy hitPolicy;
|
||||||
|
|
||||||
public static readonly Vector2 BASE_SIZE = new Vector2(512, 384);
|
public static readonly Vector2 BASE_SIZE = new Vector2(512, 384);
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
approachCircles = new ProxyContainer { RelativeSizeAxes = Axes.Both },
|
approachCircles = new ProxyContainer { RelativeSizeAxes = Axes.Both },
|
||||||
};
|
};
|
||||||
|
|
||||||
hitPolicy = new StartTimeOrderedHitPolicy();
|
hitPolicy = new ObjectOrderedHitPolicy();
|
||||||
hitPolicy.SetHitObjects(HitObjectContainer.AliveObjects);
|
hitPolicy.SetHitObjects(HitObjectContainer.AliveObjects);
|
||||||
|
|
||||||
var hitWindows = new OsuHitWindows();
|
var hitWindows = new OsuHitWindows();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user