1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 00:02:54 +08:00

Add notelock implementation

This commit is contained in:
smoogipoo 2020-03-10 15:30:24 +09:00
parent a6cf6207aa
commit 742698acab
3 changed files with 34 additions and 3 deletions

View File

@ -118,7 +118,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
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));
return;

View File

@ -1,6 +1,7 @@
// 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;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Framework.Graphics;
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.
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)
: base(hitObject)
{

View File

@ -1,6 +1,7 @@
// 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 osu.Framework.Extensions.IEnumerableExtensions;
using osuTK;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -64,7 +65,10 @@ namespace osu.Game.Rulesets.Osu.UI
base.Add(h);
followPoints.AddFollowPoints((DrawableOsuHitObject)h);
DrawableOsuHitObject osuHitObject = (DrawableOsuHitObject)h;
osuHitObject.CheckHittable = checkHittable;
followPoints.AddFollowPoints(osuHitObject);
}
public override bool Remove(DrawableHitObject h)
@ -72,11 +76,31 @@ namespace osu.Game.Rulesets.Osu.UI
bool result = base.Remove(h);
if (result)
followPoints.RemoveFollowPoints((DrawableOsuHitObject)h);
{
DrawableOsuHitObject osuHitObject = (DrawableOsuHitObject)h;
osuHitObject.CheckHittable = null;
followPoints.RemoveFollowPoints(osuHitObject);
}
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)
{
if (!judgedObject.DisplayResult || !DisplayJudgements.Value)