From cd70e5e30b24301b071f481d51e3d9510fe5fe44 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 2 Aug 2018 16:44:01 +0900 Subject: [PATCH] Migrate Rulesets.Mania to the new judgement system --- .../Objects/Drawables/DrawableHoldNote.cs | 16 ++++++------- .../Objects/Drawables/DrawableHoldNoteTick.cs | 23 ++++--------------- .../Objects/Drawables/DrawableNote.cs | 5 ++-- osu.Game.Rulesets.Mania/Objects/HoldNote.cs | 9 +++++++- .../Objects/HoldNoteTick.cs | 7 ++++++ osu.Game.Rulesets.Mania/Objects/Note.cs | 7 ++++++ osu.Game.Rulesets.Mania/Objects/TailNote.cs | 12 ++++++++++ 7 files changed, 49 insertions(+), 30 deletions(-) create mode 100644 osu.Game.Rulesets.Mania/Objects/TailNote.cs diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index 597450f223..2e64c1796a 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -100,7 +100,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables protected override void CheckForJudgements(bool userTriggered, double timeOffset) { if (tail.AllJudged) - AddJudgement(new HoldNoteJudgement { Result = HitResult.Perfect }); + ApplyJudgement(HitObject.Judgement, j => j.Result = HitResult.Perfect); } protected override void Update() @@ -166,7 +166,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables return false; // If the key has been released too early, the user should not receive full score for the release - if (Judgements.Any(j => j.Result == HitResult.Miss)) + if (HitObject.Judgement.Result == HitResult.Miss) 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 @@ -206,10 +206,10 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables { if (!HitObject.HitWindows.CanBeHit(timeOffset)) { - AddJudgement(new HoldNoteTailJudgement + ApplyJudgement(holdNote.HitObject.Tail.Judgement, j => { - Result = HitResult.Miss, - HasBroken = holdNote.hasBroken + j.Result = HitResult.Miss; + ((HoldNoteTailJudgement)j).HasBroken = holdNote.hasBroken; }); } @@ -220,10 +220,10 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables if (result == HitResult.None) return; - AddJudgement(new HoldNoteTailJudgement + ApplyJudgement(holdNote.HitObject.Tail.Judgement, j => { - Result = result, - HasBroken = holdNote.hasBroken + j.Result = result; + ((HoldNoteTailJudgement)j).HasBroken = holdNote.hasBroken; }); } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs index 5df6079efa..c281045591 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs @@ -7,7 +7,6 @@ using OpenTK.Graphics; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Game.Rulesets.Mania.Judgements; using osu.Framework.Graphics.Shapes; using osu.Game.Rulesets.Scoring; @@ -74,27 +73,15 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables protected override void CheckForJudgements(bool userTriggered, double timeOffset) { - if (!userTriggered) - return; - if (Time.Current < HitObject.StartTime) return; - if (HoldStartTime?.Invoke() > HitObject.StartTime) - return; + var startTime = HoldStartTime?.Invoke(); - AddJudgement(new HoldNoteTickJudgement { Result = HitResult.Perfect }); - } - - protected override void Update() - { - if (AllJudged) - return; - - if (HoldStartTime?.Invoke() == null) - return; - - UpdateJudgement(true); + if (startTime == null || startTime > HitObject.StartTime) + ApplyJudgement(HitObject.Judgement, j => j.Result = HitResult.Miss); + else + ApplyJudgement(HitObject.Judgement, j => j.Result = HitResult.Perfect); } } } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs index 18084c4c08..bc1033bead 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs @@ -6,7 +6,6 @@ using OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Input.Bindings; -using osu.Game.Rulesets.Mania.Judgements; using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI.Scrolling; @@ -61,7 +60,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables if (!userTriggered) { if (!HitObject.HitWindows.CanBeHit(timeOffset)) - AddJudgement(new ManiaJudgement { Result = HitResult.Miss }); + ApplyJudgement(HitObject.Judgement, j => j.Result = HitResult.Miss); return; } @@ -69,7 +68,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables if (result == HitResult.None) return; - AddJudgement(new ManiaJudgement { Result = result }); + ApplyJudgement(HitObject.Judgement, j => j.Result = result); } public virtual bool OnPressed(ManiaAction action) diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs index 22fa93a308..033434a989 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs @@ -1,8 +1,11 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // 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.ControlPoints; +using osu.Game.Rulesets.Judgements; +using osu.Game.Rulesets.Mania.Judgements; using osu.Game.Rulesets.Objects.Types; namespace osu.Game.Rulesets.Mania.Objects @@ -55,7 +58,7 @@ namespace osu.Game.Rulesets.Mania.Objects /// /// The tail note of the hold. /// - public readonly Note Tail = new Note(); + public readonly TailNote Tail = new TailNote(); /// /// The time between ticks of this hold. @@ -94,5 +97,9 @@ namespace osu.Game.Rulesets.Mania.Objects }); } } + + public HoldNoteJudgement Judgement { get; private set; } + + protected override IEnumerable CreateJudgements() => new[] { Judgement = new HoldNoteJudgement() }; } } diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNoteTick.cs b/osu.Game.Rulesets.Mania/Objects/HoldNoteTick.cs index d078c15c92..73ad3d94ec 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNoteTick.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNoteTick.cs @@ -1,6 +1,10 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // 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.Mania.Judgements; + namespace osu.Game.Rulesets.Mania.Objects { /// @@ -8,5 +12,8 @@ namespace osu.Game.Rulesets.Mania.Objects /// public class HoldNoteTick : ManiaHitObject { + public HoldNoteTickJudgement Judgement { get; private set; } + + protected override IEnumerable CreateJudgements() => new[] { Judgement = new HoldNoteTickJudgement() }; } } diff --git a/osu.Game.Rulesets.Mania/Objects/Note.cs b/osu.Game.Rulesets.Mania/Objects/Note.cs index 975188e550..ebda40de85 100644 --- a/osu.Game.Rulesets.Mania/Objects/Note.cs +++ b/osu.Game.Rulesets.Mania/Objects/Note.cs @@ -1,6 +1,10 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // 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.Mania.Judgements; + namespace osu.Game.Rulesets.Mania.Objects { /// @@ -8,5 +12,8 @@ namespace osu.Game.Rulesets.Mania.Objects /// public class Note : ManiaHitObject { + public virtual ManiaJudgement Judgement { get; } = new ManiaJudgement(); + + protected override IEnumerable CreateJudgements() => new[] { Judgement }; } } diff --git a/osu.Game.Rulesets.Mania/Objects/TailNote.cs b/osu.Game.Rulesets.Mania/Objects/TailNote.cs new file mode 100644 index 0000000000..530f3c6ff1 --- /dev/null +++ b/osu.Game.Rulesets.Mania/Objects/TailNote.cs @@ -0,0 +1,12 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Rulesets.Mania.Judgements; + +namespace osu.Game.Rulesets.Mania.Objects +{ + public class TailNote : Note + { + public override ManiaJudgement Judgement { get; } = new HoldNoteTailJudgement(); + } +}