1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-19 10:43:21 +08:00

Implement partial judgements + make Result non-nullable.

This commit is contained in:
smoogipooo 2017-03-29 17:57:36 +09:00
parent e8efdcfe0f
commit 3050039972
11 changed files with 63 additions and 11 deletions

View File

@ -38,7 +38,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
Colour = AccentColour,
Hit = () =>
{
if (Judgement.Result.HasValue) return false;
if (Judgement.Result != HitResult.None) return false;
Judgement.PositionOffset = Vector2.Zero; //todo: set to correct value
UpdateJudgement(true);

View File

@ -47,7 +47,7 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
protected override bool HandleKeyPress(Key key)
{
return !Judgement.Result.HasValue && UpdateJudgement(true);
return Judgement.Result == HitResult.None && UpdateJudgement(true);
}
}
}

View File

@ -68,7 +68,7 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
protected override bool HandleKeyPress(Key key)
{
if (Judgement.Result.HasValue)
if (Judgement.Result != HitResult.None)
return false;
validKeyPressed = HitKeys.Contains(key);

View File

@ -5,6 +5,7 @@ using OpenTK.Input;
using System;
using System.Linq;
using osu.Framework.Input;
using osu.Game.Modes.Objects.Drawables;
namespace osu.Game.Modes.Taiko.Objects.Drawable
{
@ -27,7 +28,7 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
protected override void CheckJudgement(bool userTriggered)
{
if (!Judgement.Result.HasValue)
if (Judgement.Result == HitResult.None)
{
base.CheckJudgement(userTriggered);
return;
@ -45,7 +46,7 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
protected override bool HandleKeyPress(Key key)
{
// Check if we've handled the first key
if (!Judgement.Result.HasValue)
if (Judgement.Result == HitResult.None)
{
// First key hasn't been handled yet, attempt to handle it
bool handled = base.HandleKeyPress(key);

View File

@ -64,7 +64,7 @@ namespace osu.Game.Modes.Taiko.Objects.Drawable
protected override bool HandleKeyPress(Key key)
{
if (Judgement.Result.HasValue)
if (Judgement.Result != HitResult.None)
return false;
UpdateJudgement(true);

View File

@ -0,0 +1,26 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Modes.Objects.Drawables;
using osu.Game.Modes.Scoring;
namespace osu.Game.Modes.Judgements
{
/// <summary>
/// Inidicates that the judgement this is attached to is a partial judgement and the scoring value may change.
/// <para>
/// This judgement will be continually processed by <see cref="DrawableHitObject{TObject, TJudgement}.CheckJudgement(bool)"/>
/// unless the result is a miss and will trigger a full re-process of the <see cref="ScoreProcessor"/> when changed.
/// </para>
/// </summary>
public interface IPartialJudgement
{
/// <summary>
/// Indicates that this partial judgement has changed and requires a full re-process of the <see cref="ScoreProcessor"/>.
/// <para>
/// This is set to false once the judgement has been re-processed.
/// </para>
/// </summary>
bool Changed { get; set; }
}
}

View File

@ -10,7 +10,7 @@ namespace osu.Game.Modes.Judgements
/// <summary>
/// Whether this judgement is the result of a hit or a miss.
/// </summary>
public HitResult? Result;
public HitResult Result;
/// <summary>
/// The offset at which this judgement occurred.

View File

@ -93,16 +93,26 @@ namespace osu.Game.Modes.Objects.Drawables
/// <returns>Whether a hit was processed.</returns>
protected bool UpdateJudgement(bool userTriggered)
{
if (Judgement.Result != null)
IPartialJudgement partial = Judgement as IPartialJudgement;
// Never re-process non-partial hits, or partial judgements that were previously judged as misses
if (Judgement.Result != HitResult.None && (partial == null || Judgement.Result == HitResult.Miss))
return false;
// Update the judgement state
double endTime = (HitObject as IHasEndTime)?.EndTime ?? HitObject.StartTime;
Judgement.TimeOffset = Time.Current - endTime;
// Update the judgement state
bool hadResult = Judgement.Result != HitResult.None;
CheckJudgement(userTriggered);
if (Judgement.Result == null)
// Don't process judgements with no result
if (Judgement.Result == HitResult.None)
return false;
// Don't process judgements that previously had results but the results were unchanged
if (hadResult && partial?.Changed != true)
return false;
switch (Judgement.Result)
@ -117,6 +127,9 @@ namespace osu.Game.Modes.Objects.Drawables
OnJudgement?.Invoke(this);
if (partial != null)
partial.Changed = false;
return true;
}

View File

@ -7,8 +7,19 @@ namespace osu.Game.Modes.Objects.Drawables
{
public enum HitResult
{
/// <summary>
/// Indicates that the object has not been judged yet.
/// </summary>
[Description("")]
None,
/// <summary>
/// Indicates that the object has been judged as a miss.
/// </summary>
[Description(@"Miss")]
Miss,
/// <summary>
/// Indicates that the object has been judged as a hit.
/// </summary>
[Description(@"Hit")]
Hit,
}

View File

@ -149,7 +149,7 @@ namespace osu.Game.Modes.UI
public event Action<TJudgement> OnJudgement;
protected override Container<Drawable> Content => content;
protected override bool AllObjectsJudged => Playfield.HitObjects.Children.All(h => h.Judgement.Result.HasValue);
protected override bool AllObjectsJudged => Playfield.HitObjects.Children.All(h => h.Judgement.Result != HitResult.None);
/// <summary>
/// The playfield.

View File

@ -97,6 +97,7 @@
<Compile Include="IO\Legacy\SerializationWriter.cs" />
<Compile Include="IPC\ScoreIPCChannel.cs" />
<Compile Include="Modes\Judgements\DrawableJudgement.cs" />
<Compile Include="Modes\Judgements\IPartialJudgement.cs" />
<Compile Include="Modes\LegacyReplay.cs" />
<Compile Include="Modes\Mods\IApplicableMod.cs" />
<Compile Include="Modes\Mods\ModType.cs" />