mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 15:12:57 +08:00
Add notelock implementation
This commit is contained in:
parent
a6cf6207aa
commit
742698acab
@ -118,7 +118,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
|
|
||||||
var result = HitObject.HitWindows.ResultFor(timeOffset);
|
var result = HitObject.HitWindows.ResultFor(timeOffset);
|
||||||
|
|
||||||
if (result == HitResult.None)
|
if (result == HitResult.None || CheckHittable?.Invoke(this) == false)
|
||||||
{
|
{
|
||||||
Shake(Math.Abs(timeOffset) - HitObject.HitWindows.WindowFor(HitResult.Miss));
|
Shake(Math.Abs(timeOffset) - HitObject.HitWindows.WindowFor(HitResult.Miss));
|
||||||
return;
|
return;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
@ -16,6 +17,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
// Must be set to update IsHovered as it's used in relax mdo to detect osu hit objects.
|
// Must be set to update IsHovered as it's used in relax mdo to detect osu hit objects.
|
||||||
public override bool HandlePositionalInput => true;
|
public override bool HandlePositionalInput => true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether this <see cref="DrawableOsuHitObject"/> can be hit.
|
||||||
|
/// If not-null, this <see cref="DrawableOsuHitObject"/> will not receive a judgement until this function returns <c>true</c>.
|
||||||
|
/// </summary>
|
||||||
|
public Func<DrawableOsuHitObject, bool> CheckHittable;
|
||||||
|
|
||||||
protected DrawableOsuHitObject(OsuHitObject hitObject)
|
protected DrawableOsuHitObject(OsuHitObject hitObject)
|
||||||
: base(hitObject)
|
: base(hitObject)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -64,7 +65,10 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
|
|
||||||
base.Add(h);
|
base.Add(h);
|
||||||
|
|
||||||
followPoints.AddFollowPoints((DrawableOsuHitObject)h);
|
DrawableOsuHitObject osuHitObject = (DrawableOsuHitObject)h;
|
||||||
|
osuHitObject.CheckHittable = checkHittable;
|
||||||
|
|
||||||
|
followPoints.AddFollowPoints(osuHitObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Remove(DrawableHitObject h)
|
public override bool Remove(DrawableHitObject h)
|
||||||
@ -72,11 +76,31 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
bool result = base.Remove(h);
|
bool result = base.Remove(h);
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
followPoints.RemoveFollowPoints((DrawableOsuHitObject)h);
|
{
|
||||||
|
DrawableOsuHitObject osuHitObject = (DrawableOsuHitObject)h;
|
||||||
|
osuHitObject.CheckHittable = null;
|
||||||
|
|
||||||
|
followPoints.RemoveFollowPoints(osuHitObject);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool checkHittable(DrawableOsuHitObject osuHitObject)
|
||||||
|
{
|
||||||
|
var lastObject = HitObjectContainer.AliveObjects.GetPrevious(osuHitObject);
|
||||||
|
|
||||||
|
// Ensure the last object is not alive anymore, in which case always allow the hit.
|
||||||
|
if (lastObject == null)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Ensure that either the last object has received a judgement or the hit time occurs after the last object's start time.
|
||||||
|
if (lastObject.Judged || Time.Current > lastObject.HitObject.StartTime)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private void onNewResult(DrawableHitObject judgedObject, JudgementResult result)
|
private void onNewResult(DrawableHitObject judgedObject, JudgementResult result)
|
||||||
{
|
{
|
||||||
if (!judgedObject.DisplayResult || !DisplayJudgements.Value)
|
if (!judgedObject.DisplayResult || !DisplayJudgements.Value)
|
||||||
|
Loading…
Reference in New Issue
Block a user