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

Make hitobjects only have one judgement + result

This commit is contained in:
smoogipoo 2018-08-03 15:38:48 +09:00
parent 0da6c8c1a7
commit 2a4994e5ce
29 changed files with 66 additions and 110 deletions

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Game.Rulesets.Catch.Judgements; using osu.Game.Rulesets.Catch.Judgements;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
@ -11,6 +10,6 @@ namespace osu.Game.Rulesets.Catch.Objects
{ {
public override FruitVisualRepresentation VisualRepresentation => FruitVisualRepresentation.Banana; public override FruitVisualRepresentation VisualRepresentation => FruitVisualRepresentation.Banana;
protected override IEnumerable<Judgement> CreateJudgements() => new[] { new CatchBananaJudgement() }; protected override Judgement CreateJudgement() => new CatchBananaJudgement();
} }
} }

View File

@ -2,7 +2,6 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System; using System;
using System.Linq;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -57,8 +56,8 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
{ {
if (CheckPosition == null) return; if (CheckPosition == null) return;
if (timeOffset >= 0 && Results.Count > 0) if (timeOffset >= 0 && Result != null)
ApplyResult(Results.Single(), r => r.Type = CheckPosition.Invoke(HitObject) ? HitResult.Perfect : HitResult.Miss); ApplyResult(r => r.Type = CheckPosition.Invoke(HitObject) ? HitResult.Perfect : HitResult.Miss);
} }
protected override void SkinChanged(ISkinSource skin, bool allowFallback) protected override void SkinChanged(ISkinSource skin, bool allowFallback)

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Game.Rulesets.Catch.Judgements; using osu.Game.Rulesets.Catch.Judgements;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
@ -9,6 +8,6 @@ namespace osu.Game.Rulesets.Catch.Objects
{ {
public class Droplet : CatchHitObject public class Droplet : CatchHitObject
{ {
protected override IEnumerable<Judgement> CreateJudgements() => new[] { new CatchDropletJudgement() }; protected override Judgement CreateJudgement() => new CatchDropletJudgement();
} }
} }

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Game.Rulesets.Catch.Judgements; using osu.Game.Rulesets.Catch.Judgements;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
@ -9,6 +8,6 @@ namespace osu.Game.Rulesets.Catch.Objects
{ {
public class Fruit : CatchHitObject public class Fruit : CatchHitObject
{ {
protected override IEnumerable<Judgement> CreateJudgements() => new[] { new CatchJudgement() }; protected override Judgement CreateJudgement() => new CatchJudgement();
} }
} }

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Game.Rulesets.Catch.Judgements; using osu.Game.Rulesets.Catch.Judgements;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
@ -9,6 +8,6 @@ namespace osu.Game.Rulesets.Catch.Objects
{ {
public class TinyDroplet : Droplet public class TinyDroplet : Droplet
{ {
protected override IEnumerable<Judgement> CreateJudgements() => new[] { new CatchTinyDropletJudgement() }; protected override Judgement CreateJudgement() => new CatchTinyDropletJudgement();
} }
} }

View File

@ -99,7 +99,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
protected override void CheckForJudgements(bool userTriggered, double timeOffset) protected override void CheckForJudgements(bool userTriggered, double timeOffset)
{ {
if (tail.AllJudged) if (tail.AllJudged)
ApplyResult(Results.Single(), r => r.Type = HitResult.Perfect); ApplyResult(r => r.Type = HitResult.Perfect);
} }
protected override void Update() protected override void Update()
@ -165,7 +165,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
return false; return false;
// If the key has been released too early, the user should not receive full score for the release // If the key has been released too early, the user should not receive full score for the release
if (Results.Single().Type == HitResult.Miss) if (Result.Type == HitResult.Miss)
holdNote.hasBroken = true; holdNote.hasBroken = true;
// The head note also handles early hits before the body, but we want accurate early hits to count as the body being held // The head note also handles early hits before the body, but we want accurate early hits to count as the body being held
@ -204,7 +204,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
if (!userTriggered) if (!userTriggered)
{ {
if (!HitObject.HitWindows.CanBeHit(timeOffset)) if (!HitObject.HitWindows.CanBeHit(timeOffset))
ApplyResult(Results.Single(), r => r.Type = HitResult.Miss); ApplyResult(r => r.Type = HitResult.Miss);
return; return;
} }
@ -213,7 +213,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
if (result == HitResult.None) if (result == HitResult.None)
return; return;
ApplyResult(Results.Single(), r => ApplyResult(r =>
{ {
if (holdNote.hasBroken && (result == HitResult.Perfect || result == HitResult.Perfect)) if (holdNote.hasBroken && (result == HitResult.Perfect || result == HitResult.Perfect))
result = HitResult.Good; result = HitResult.Good;

View File

@ -2,7 +2,6 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System; using System;
using System.Linq;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
@ -80,9 +79,9 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
var startTime = HoldStartTime?.Invoke(); var startTime = HoldStartTime?.Invoke();
if (startTime == null || startTime > HitObject.StartTime) if (startTime == null || startTime > HitObject.StartTime)
ApplyResult(Results.Single(), r => r.Type = HitResult.Miss); ApplyResult(r => r.Type = HitResult.Miss);
else else
ApplyResult(Results.Single(), r => r.Type = HitResult.Perfect); ApplyResult(r => r.Type = HitResult.Perfect);
} }
} }
} }

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Linq;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -61,7 +60,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
if (!userTriggered) if (!userTriggered)
{ {
if (!HitObject.HitWindows.CanBeHit(timeOffset)) if (!HitObject.HitWindows.CanBeHit(timeOffset))
ApplyResult(Results.Single(), r => r.Type = HitResult.Miss); ApplyResult(r => r.Type = HitResult.Miss);
return; return;
} }
@ -69,7 +68,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
if (result == HitResult.None) if (result == HitResult.None)
return; return;
ApplyResult(Results.Single(), r => r.Type = result); ApplyResult(r => r.Type = result);
} }
public virtual bool OnPressed(ManiaAction action) public virtual bool OnPressed(ManiaAction action)

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
@ -98,6 +97,6 @@ namespace osu.Game.Rulesets.Mania.Objects
} }
} }
protected override IEnumerable<Judgement> CreateJudgements() => new[] { new HoldNoteJudgement() }; protected override Judgement CreateJudgement() => new HoldNoteJudgement();
} }
} }

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mania.Judgements; using osu.Game.Rulesets.Mania.Judgements;
@ -12,6 +11,6 @@ namespace osu.Game.Rulesets.Mania.Objects
/// </summary> /// </summary>
public class HoldNoteTick : ManiaHitObject public class HoldNoteTick : ManiaHitObject
{ {
protected override IEnumerable<Judgement> CreateJudgements() => new[] { new HoldNoteTickJudgement() }; protected override Judgement CreateJudgement() => new HoldNoteTickJudgement();
} }
} }

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mania.Judgements; using osu.Game.Rulesets.Mania.Judgements;
@ -12,6 +11,6 @@ namespace osu.Game.Rulesets.Mania.Objects
/// </summary> /// </summary>
public class Note : ManiaHitObject public class Note : ManiaHitObject
{ {
protected override IEnumerable<Judgement> CreateJudgements() => new[] { new ManiaJudgement() }; protected override Judgement CreateJudgement() => new ManiaJudgement();
} }
} }

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mania.Judgements; using osu.Game.Rulesets.Mania.Judgements;
@ -9,6 +8,6 @@ namespace osu.Game.Rulesets.Mania.Objects
{ {
public class TailNote : Note public class TailNote : Note
{ {
protected override IEnumerable<Judgement> CreateJudgements() => new[] { new ManiaJudgement() }; protected override Judgement CreateJudgement() => new ManiaJudgement();
} }
} }

View File

@ -99,7 +99,7 @@ namespace osu.Game.Rulesets.Osu.Tests
if (auto && !userTriggered && timeOffset > 0) if (auto && !userTriggered && timeOffset > 0)
{ {
// force success // force success
ApplyResult(Results.Single(), r => r.Type = HitResult.Great); ApplyResult(r => r.Type = HitResult.Great);
} }
else else
base.CheckForJudgements(userTriggered, timeOffset); base.CheckForJudgements(userTriggered, timeOffset);

View File

@ -2,7 +2,6 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System; using System;
using System.Linq;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces; using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
@ -82,7 +81,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
if (!userTriggered) if (!userTriggered)
{ {
if (!HitObject.HitWindows.CanBeHit(timeOffset)) if (!HitObject.HitWindows.CanBeHit(timeOffset))
ApplyResult(Results.Single(), r => r.Type = HitResult.Miss); ApplyResult(r => r.Type = HitResult.Miss);
return; return;
} }
@ -91,7 +90,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
if (result == HitResult.None) if (result == HitResult.None)
return; return;
ApplyResult(Results.Single(), r => r.Type = result); ApplyResult(r => r.Type = result);
} }
protected override void UpdatePreemptState() protected override void UpdatePreemptState()

View File

@ -4,7 +4,6 @@
using System; using System;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using System.Linq;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Osu.Judgements; using osu.Game.Rulesets.Osu.Judgements;
@ -35,7 +34,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
{ {
UpdatePreemptState(); UpdatePreemptState();
var judgementOffset = Math.Min(HitObject.HitWindows.HalfWindowFor(HitResult.Miss), Results.FirstOrDefault()?.TimeOffset ?? 0); var judgementOffset = Math.Min(HitObject.HitWindows.HalfWindowFor(HitResult.Miss), Result?.TimeOffset ?? 0);
using (BeginDelayedSequence(HitObject.TimePreempt + judgementOffset, true)) using (BeginDelayedSequence(HitObject.TimePreempt + judgementOffset, true))
UpdateCurrentState(state); UpdateCurrentState(state);

View File

@ -3,7 +3,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.MathUtils; using osu.Framework.MathUtils;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
@ -45,7 +44,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
protected override void CheckForJudgements(bool userTriggered, double timeOffset) protected override void CheckForJudgements(bool userTriggered, double timeOffset)
{ {
if (repeatPoint.StartTime <= Time.Current) if (repeatPoint.StartTime <= Time.Current)
ApplyResult(Results.Single(), r => r.Type = drawableSlider.Tracking ? HitResult.Great : HitResult.Miss); ApplyResult(r => r.Type = drawableSlider.Tracking ? HitResult.Great : HitResult.Miss);
} }
protected override void UpdatePreemptState() protected override void UpdatePreemptState()

View File

@ -136,16 +136,16 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
if (userTriggered || Time.Current < slider.EndTime) if (userTriggered || Time.Current < slider.EndTime)
return; return;
ApplyResult(Results.Single(), r => ApplyResult(r =>
{ {
var judgementsCount = NestedHitObjects.Count(); var judgementsCount = NestedHitObjects.Count();
var judgementsHit = NestedHitObjects.Count(h => h.IsHit); var judgementsHit = NestedHitObjects.Count(h => h.IsHit);
var hitFraction = (double)judgementsHit / judgementsCount; var hitFraction = (double)judgementsHit / judgementsCount;
if (hitFraction == 1 && HeadCircle.Results.Single().Type == HitResult.Great) if (hitFraction == 1 && HeadCircle.Result.Type == HitResult.Great)
r.Type = HitResult.Great; r.Type = HitResult.Great;
else if (hitFraction >= 0.5 && HeadCircle.Results.Single().Type >= HitResult.Good) else if (hitFraction >= 0.5 && HeadCircle.Result.Type >= HitResult.Good)
r.Type = HitResult.Good; r.Type = HitResult.Good;
else if (hitFraction > 0) else if (hitFraction > 0)
r.Type = HitResult.Meh; r.Type = HitResult.Meh;

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Linq;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
@ -32,7 +31,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
protected override void CheckForJudgements(bool userTriggered, double timeOffset) protected override void CheckForJudgements(bool userTriggered, double timeOffset)
{ {
if (!userTriggered && timeOffset >= 0) if (!userTriggered && timeOffset >= 0)
ApplyResult(Results.Single(), r => r.Type = Tracking ? HitResult.Great : HitResult.Miss); ApplyResult(r => r.Type = Tracking ? HitResult.Great : HitResult.Miss);
} }
} }
} }

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Linq;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using OpenTK; using OpenTK;
@ -51,7 +50,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
protected override void CheckForJudgements(bool userTriggered, double timeOffset) protected override void CheckForJudgements(bool userTriggered, double timeOffset)
{ {
if (timeOffset >= 0) if (timeOffset >= 0)
ApplyResult(Results.Single(), r => r.Type = Tracking ? HitResult.Great : HitResult.Miss); ApplyResult(r => r.Type = Tracking ? HitResult.Great : HitResult.Miss);
} }
protected override void UpdatePreemptState() protected override void UpdatePreemptState()

View File

@ -138,7 +138,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
if (userTriggered || Time.Current < Spinner.EndTime) if (userTriggered || Time.Current < Spinner.EndTime)
return; return;
ApplyResult(Results.Single(), r => ApplyResult(r =>
{ {
if (Progress >= 1) if (Progress >= 1)
r.Type = HitResult.Great; r.Type = HitResult.Great;

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Osu.Judgements; using osu.Game.Rulesets.Osu.Judgements;
@ -9,6 +8,6 @@ namespace osu.Game.Rulesets.Osu.Objects
{ {
public class HitCircle : OsuHitObject public class HitCircle : OsuHitObject
{ {
protected override IEnumerable<Judgement> CreateJudgements() => new[] { new OsuJudgement() }; protected override Judgement CreateJudgement() => new OsuJudgement();
} }
} }

View File

@ -2,7 +2,6 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System; using System;
using System.Collections.Generic;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
@ -28,6 +27,6 @@ namespace osu.Game.Rulesets.Osu.Objects
TimePreempt = Math.Min(SpanDuration * 2, TimePreempt); TimePreempt = Math.Min(SpanDuration * 2, TimePreempt);
} }
protected override IEnumerable<Judgement> CreateJudgements() => new[] { new OsuJudgement() }; protected override Judgement CreateJudgement() => new OsuJudgement();
} }
} }

View File

@ -214,6 +214,6 @@ namespace osu.Game.Rulesets.Osu.Objects
} }
} }
protected override IEnumerable<Judgement> CreateJudgements() => new[] { new OsuJudgement() }; protected override Judgement CreateJudgement() => new OsuJudgement();
} }
} }

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Osu.Judgements; using osu.Game.Rulesets.Osu.Judgements;
@ -14,6 +13,6 @@ namespace osu.Game.Rulesets.Osu.Objects
{ {
} }
protected override IEnumerable<Judgement> CreateJudgements() => new[] { new OsuSliderTailJudgement() }; protected override Judgement CreateJudgement() => new OsuSliderTailJudgement();
} }
} }

View File

@ -1,7 +1,6 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
@ -30,6 +29,6 @@ namespace osu.Game.Rulesets.Osu.Objects
TimePreempt = (StartTime - SpanStartTime) / 2 + offset; TimePreempt = (StartTime - SpanStartTime) / 2 + offset;
} }
protected override IEnumerable<Judgement> CreateJudgements() => new[] { new OsuJudgement() }; protected override Judgement CreateJudgement() => new OsuJudgement();
} }
} }

View File

@ -2,7 +2,6 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System; using System;
using System.Collections.Generic;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
@ -33,6 +32,6 @@ namespace osu.Game.Rulesets.Osu.Objects
SpinsRequired = (int)Math.Max(1, SpinsRequired * 0.6); SpinsRequired = (int)Math.Max(1, SpinsRequired * 0.6);
} }
protected override IEnumerable<Judgement> CreateJudgements() => new[] { new OsuJudgement() }; protected override Judgement CreateJudgement() => new OsuJudgement();
} }
} }

View File

@ -46,7 +46,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
/// <summary> /// <summary>
/// Whether this <see cref="DrawableHitObject"/> and all of its nested <see cref="DrawableHitObject"/>s have been hit. /// Whether this <see cref="DrawableHitObject"/> and all of its nested <see cref="DrawableHitObject"/>s have been hit.
/// </summary> /// </summary>
public bool IsHit => Results.All(j => j.IsHit) && NestedHitObjects.All(n => n.IsHit); public bool IsHit => (Result?.IsHit ?? true) && NestedHitObjects.All(n => n.IsHit);
/// <summary> /// <summary>
/// Whether this <see cref="DrawableHitObject"/> and all of its nested <see cref="DrawableHitObject"/>s have been judged. /// Whether this <see cref="DrawableHitObject"/> and all of its nested <see cref="DrawableHitObject"/>s have been judged.
@ -57,17 +57,9 @@ namespace osu.Game.Rulesets.Objects.Drawables
/// Whether this <see cref="DrawableHitObject"/> has been judged. /// Whether this <see cref="DrawableHitObject"/> has been judged.
/// Note: This does NOT include nested hitobjects. /// Note: This does NOT include nested hitobjects.
/// </summary> /// </summary>
public bool Judged => Results.All(h => h.HasResult); public bool Judged => Result?.HasResult ?? true;
private readonly List<JudgementResult> results = new List<JudgementResult>(); public readonly JudgementResult Result;
public IReadOnlyList<JudgementResult> Results => results;
/// <summary>
/// The <see cref="JudgementResult"/> that affects whether this <see cref="DrawableHitObject"/> has been hit or missed.
/// By default, this is the last <see cref="JudgementResult"/> in <see cref="Results"/>, and should be overridden if the order
/// of <see cref="Judgement"/>s in <see cref="HitObject.CreateJudgements"/> doesn't list the main <see cref="Judgement"/> as its last element.
/// </summary>
protected virtual JudgementResult MainResult => Results.LastOrDefault();
private bool judgementOccurred; private bool judgementOccurred;
@ -85,8 +77,8 @@ namespace osu.Game.Rulesets.Objects.Drawables
{ {
HitObject = hitObject; HitObject = hitObject;
foreach (var j in hitObject.Judgements) if (hitObject.Judgement != null)
results.Add(CreateJudgementResult(j)); Result = CreateJudgementResult(hitObject.Judgement);
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -144,20 +136,15 @@ namespace osu.Game.Rulesets.Objects.Drawables
{ {
base.Update(); base.Update();
if (lastUpdateTime > Time.Current) if (Result != null && lastUpdateTime > Time.Current)
{ {
var endTime = (HitObject as IHasEndTime)?.EndTime ?? HitObject.StartTime; var endTime = (HitObject as IHasEndTime)?.EndTime ?? HitObject.StartTime;
for (int i = Results.Count - 1; i >= 0; i--) if (Result.TimeOffset + endTime < Time.Current)
{ {
var judgement = Results[i]; OnJudgementRemoved?.Invoke(this, Result);
if (judgement.TimeOffset + endTime <= Time.Current) Result.Type = HitResult.None;
break;
OnJudgementRemoved?.Invoke(this, judgement);
judgement.Type = HitResult.None;
State.Value = ArmedState.Idle; State.Value = ArmedState.Idle;
} }
} }
@ -185,23 +172,17 @@ namespace osu.Game.Rulesets.Objects.Drawables
/// Notifies that a new judgement has occurred for this <see cref="DrawableHitObject"/>. /// Notifies that a new judgement has occurred for this <see cref="DrawableHitObject"/>.
/// </summary> /// </summary>
/// <param name="judgement">The <see cref="Judgement"/>.</param> /// <param name="judgement">The <see cref="Judgement"/>.</param>
protected void ApplyResult(JudgementResult result, Action<JudgementResult> application) protected void ApplyResult(Action<JudgementResult> application)
{ {
// Todo: Unsure if we want to keep this application?.Invoke(Result);
if (!Results.Contains(result))
throw new ArgumentException($"The applied judgement result must be a part of {Results}.");
application?.Invoke(result);
judgementOccurred = true; judgementOccurred = true;
// Ensure that the judgement is given a valid time offset, because this may not get set by the caller // Ensure that the judgement is given a valid time offset, because this may not get set by the caller
var endTime = (HitObject as IHasEndTime)?.EndTime ?? HitObject.StartTime; var endTime = (HitObject as IHasEndTime)?.EndTime ?? HitObject.StartTime;
result.TimeOffset = Time.Current - endTime; Result.TimeOffset = Time.Current - endTime;
if (result == MainResult) switch (Result.Type)
{
switch (result.Type)
{ {
case HitResult.None: case HitResult.None:
break; break;
@ -212,9 +193,8 @@ namespace osu.Game.Rulesets.Objects.Drawables
State.Value = ArmedState.Hit; State.Value = ArmedState.Hit;
break; break;
} }
}
OnJudgement?.Invoke(this, result); OnJudgement?.Invoke(this, Result);
} }
/// <summary> /// <summary>

View File

@ -3,7 +3,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json; using Newtonsoft.Json;
using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Lists; using osu.Framework.Lists;
@ -64,8 +63,7 @@ namespace osu.Game.Rulesets.Objects
[JsonIgnore] [JsonIgnore]
public IReadOnlyList<HitObject> NestedHitObjects => nestedHitObjects.Value; public IReadOnlyList<HitObject> NestedHitObjects => nestedHitObjects.Value;
private readonly List<Judgement> judgements = new List<Judgement>(); public Judgement Judgement { get; private set; }
public IReadOnlyList<Judgement> Judgements => judgements;
/// <summary> /// <summary>
/// Applies default values to this HitObject. /// Applies default values to this HitObject.
@ -76,8 +74,7 @@ namespace osu.Game.Rulesets.Objects
{ {
ApplyDefaultsToSelf(controlPointInfo, difficulty); ApplyDefaultsToSelf(controlPointInfo, difficulty);
judgements.Clear(); Judgement = CreateJudgement();
judgements.AddRange(CreateJudgements());
if (nestedHitObjects.IsValueCreated) if (nestedHitObjects.IsValueCreated)
nestedHitObjects.Value.Clear(); nestedHitObjects.Value.Clear();
@ -111,7 +108,7 @@ namespace osu.Game.Rulesets.Objects
{ {
} }
protected virtual IEnumerable<Judgement> CreateJudgements() => Enumerable.Empty<Judgement>(); protected virtual Judgement CreateJudgement() => null;
protected void AddNested(HitObject hitObject) => nestedHitObjects.Value.Add(hitObject); protected void AddNested(HitObject hitObject) => nestedHitObjects.Value.Add(hitObject);

View File

@ -224,15 +224,15 @@ namespace osu.Game.Rulesets.Scoring
foreach (var nested in obj.NestedHitObjects) foreach (var nested in obj.NestedHitObjects)
simulate(nested); simulate(nested);
foreach (var judgement in obj.Judgements) if (obj.Judgement == null)
{ return;
var result = CreateJudgementResult(judgement);
result.Type = judgement.MaxResult; var result = CreateJudgementResult(obj.Judgement);
result.Type = obj.Judgement.MaxResult;
AddJudgement(result); AddJudgement(result);
} }
} }
}
/// <summary> /// <summary>
/// Adds a judgement to this ScoreProcessor. /// Adds a judgement to this ScoreProcessor.