diff --git a/osu.Game.Modes.Catch/Judgements/CatchJudgementInfo.cs b/osu.Game.Modes.Catch/Judgements/CatchJudgementInfo.cs index e560091d2d..eea85b1cb9 100644 --- a/osu.Game.Modes.Catch/Judgements/CatchJudgementInfo.cs +++ b/osu.Game.Modes.Catch/Judgements/CatchJudgementInfo.cs @@ -1,9 +1,4 @@ using osu.Game.Modes.Judgements; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace osu.Game.Modes.Catch.Judgements { diff --git a/osu.Game.Modes.Mania/Judgements/ManiaJudgementInfo.cs b/osu.Game.Modes.Mania/Judgements/ManiaJudgementInfo.cs index 1b587e4ae1..f724979e75 100644 --- a/osu.Game.Modes.Mania/Judgements/ManiaJudgementInfo.cs +++ b/osu.Game.Modes.Mania/Judgements/ManiaJudgementInfo.cs @@ -1,9 +1,4 @@ using osu.Game.Modes.Judgements; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace osu.Game.Modes.Mania.Judgements { diff --git a/osu.Game.Modes.Osu/Objects/Drawables/DrawableHitCircle.cs b/osu.Game.Modes.Osu/Objects/Drawables/DrawableHitCircle.cs index e10fa91e6f..c2717f2d3d 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/DrawableHitCircle.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/DrawableHitCircle.cs @@ -44,7 +44,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables { if (Judgement.Result.HasValue) return false; - ((PositionalJudgementInfo)Judgement).PositionOffset = Vector2.Zero; //todo: set to correct value + Judgement.PositionOffset = Vector2.Zero; //todo: set to correct value UpdateJudgement(true); return true; }, @@ -80,12 +80,10 @@ namespace osu.Game.Modes.Osu.Objects.Drawables double hitOffset = Math.Abs(Judgement.TimeOffset); - OsuJudgementInfo osuJudgement = (OsuJudgementInfo)Judgement; - if (hitOffset < HitObject.HitWindowFor(OsuScoreResult.Hit50)) { Judgement.Result = HitResult.Hit; - osuJudgement.Score = HitObject.ScoreResultForOffset(hitOffset); + Judgement.Score = HitObject.ScoreResultForOffset(hitOffset); } else Judgement.Result = HitResult.Miss; diff --git a/osu.Game.Modes.Osu/Objects/Drawables/DrawableOsuHitObject.cs b/osu.Game.Modes.Osu/Objects/Drawables/DrawableOsuHitObject.cs index 60f2c130c9..b9003a3207 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/DrawableOsuHitObject.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/DrawableOsuHitObject.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.ComponentModel; -using osu.Game.Modes.Judgements; using osu.Game.Modes.Objects.Drawables; namespace osu.Game.Modes.Osu.Objects.Drawables diff --git a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs index 94c150bd3e..49aaa893e2 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs @@ -125,27 +125,24 @@ namespace osu.Game.Modes.Osu.Objects.Drawables protected override void CheckJudgement(bool userTriggered) { - var j = (OsuJudgementInfo)Judgement; - var sc = (OsuJudgementInfo)initialCircle.Judgement; - if (!userTriggered && Time.Current >= HitObject.EndTime) { var ticksCount = ticks.Children.Count() + 1; var ticksHit = ticks.Children.Count(t => t.Judgement.Result == HitResult.Hit); - if (sc.Result == HitResult.Hit) + if (initialCircle.Judgement.Result == HitResult.Hit) ticksHit++; var hitFraction = (double)ticksHit / ticksCount; - if (hitFraction == 1 && sc.Score == OsuScoreResult.Hit300) - j.Score = OsuScoreResult.Hit300; - else if (hitFraction >= 0.5 && sc.Score >= OsuScoreResult.Hit100) - j.Score = OsuScoreResult.Hit100; + if (hitFraction == 1 && initialCircle.Judgement.Score == OsuScoreResult.Hit300) + Judgement.Score = OsuScoreResult.Hit300; + else if (hitFraction >= 0.5 && initialCircle.Judgement.Score >= OsuScoreResult.Hit100) + Judgement.Score = OsuScoreResult.Hit100; else if (hitFraction > 0) - j.Score = OsuScoreResult.Hit50; + Judgement.Score = OsuScoreResult.Hit50; else - j.Score = OsuScoreResult.Miss; + Judgement.Score = OsuScoreResult.Miss; - j.Result = j.Score != OsuScoreResult.Miss ? HitResult.Hit : HitResult.Miss; + Judgement.Result = Judgement.Score != OsuScoreResult.Miss ? HitResult.Hit : HitResult.Miss; } } diff --git a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs index 7d74463107..87d0babef2 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSliderTick.cs @@ -9,7 +9,6 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Transforms; using osu.Game.Beatmaps.Samples; -using osu.Game.Modes.Judgements; using osu.Game.Modes.Objects.Drawables; using OpenTK; using OpenTK.Graphics; @@ -72,12 +71,10 @@ namespace osu.Game.Modes.Osu.Objects.Drawables protected override void CheckJudgement(bool userTriggered) { - var j = (OsuJudgementInfo)Judgement; - if (Judgement.TimeOffset >= 0) { - j.Result = Tracking ? HitResult.Hit : HitResult.Miss; - j.Score = Tracking ? OsuScoreResult.SliderTick : OsuScoreResult.Miss; + Judgement.Result = Tracking ? HitResult.Hit : HitResult.Miss; + Judgement.Score = Tracking ? OsuScoreResult.SliderTick : OsuScoreResult.Miss; } } diff --git a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSpinner.cs b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSpinner.cs index cfebd11809..530062da93 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSpinner.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSpinner.cs @@ -75,8 +75,6 @@ namespace osu.Game.Modes.Osu.Objects.Drawables { if (Time.Current < HitObject.StartTime) return; - var j = (OsuJudgementInfo)Judgement; - disc.ScaleTo(Interpolation.ValueAt(Math.Sqrt(Progress), scaleToCircle, Vector2.One, 0, 1), 100); if (Progress >= 1) @@ -86,24 +84,24 @@ namespace osu.Game.Modes.Osu.Objects.Drawables { if (Progress >= 1) { - j.Score = OsuScoreResult.Hit300; - j.Result = HitResult.Hit; + Judgement.Score = OsuScoreResult.Hit300; + Judgement.Result = HitResult.Hit; } else if (Progress > .9) { - j.Score = OsuScoreResult.Hit100; - j.Result = HitResult.Hit; + Judgement.Score = OsuScoreResult.Hit100; + Judgement.Result = HitResult.Hit; } else if (Progress > .75) { - j.Score = OsuScoreResult.Hit50; - j.Result = HitResult.Hit; + Judgement.Score = OsuScoreResult.Hit50; + Judgement.Result = HitResult.Hit; } else { - j.Score = OsuScoreResult.Miss; + Judgement.Score = OsuScoreResult.Miss; if (Time.Current >= HitObject.EndTime) - j.Result = HitResult.Miss; + Judgement.Result = HitResult.Miss; } } } diff --git a/osu.Game.Modes.Osu/UI/OsuPlayfield.cs b/osu.Game.Modes.Osu/UI/OsuPlayfield.cs index 4b890b61b3..dd023b1cc1 100644 --- a/osu.Game.Modes.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Modes.Osu/UI/OsuPlayfield.cs @@ -11,9 +11,7 @@ using osu.Game.Modes.Osu.Objects.Drawables.Connections; using osu.Game.Modes.UI; using System.Linq; using osu.Game.Graphics.Cursor; -using osu.Game.Modes.Judgements; using OpenTK.Graphics; -using System; namespace osu.Game.Modes.Osu.UI { diff --git a/osu.Game.Modes.Taiko/Judgements/TaikoJudgementInfo.cs b/osu.Game.Modes.Taiko/Judgements/TaikoJudgementInfo.cs index 509b85ad91..499e0a62b8 100644 --- a/osu.Game.Modes.Taiko/Judgements/TaikoJudgementInfo.cs +++ b/osu.Game.Modes.Taiko/Judgements/TaikoJudgementInfo.cs @@ -1,9 +1,4 @@ using osu.Game.Modes.Judgements; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace osu.Game.Modes.Taiko.Judgements { diff --git a/osu.Game/Modes/ScoreProcesssor.cs b/osu.Game/Modes/ScoreProcesssor.cs index 0fb9ddba0c..c7a882cfab 100644 --- a/osu.Game/Modes/ScoreProcesssor.cs +++ b/osu.Game/Modes/ScoreProcesssor.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Configuration; -using osu.Game.Modes.Objects.Drawables; using System; using System.Collections.Generic; using osu.Game.Modes.Judgements; diff --git a/osu.Game/Modes/UI/HitRenderer.cs b/osu.Game/Modes/UI/HitRenderer.cs index 6d576b63f3..e962ec53bd 100644 --- a/osu.Game/Modes/UI/HitRenderer.cs +++ b/osu.Game/Modes/UI/HitRenderer.cs @@ -16,15 +16,36 @@ using osu.Game.Modes.Judgements; namespace osu.Game.Modes.UI { + /// + /// Base HitRenderer. Doesn't hold objects, should not be derived. + /// public abstract class HitRenderer : Container { + /// + /// The event that's fired when a hit object is judged. + /// public event Action OnJudgement; + + /// + /// The event that's fired when all hit objects have been judged. + /// public event Action OnAllJudged; + /// + /// The input manager for this HitRenderer. + /// internal readonly PlayerInputManager InputManager = new PlayerInputManager(); + /// + /// The key conversion input manager for this HitRenderer. + /// protected readonly KeyConversionInputManager KeyConversionInputManager; + /// + /// Whether all the HitObjects have been judged. + /// + protected abstract bool AllObjectsJudged { get; } + protected HitRenderer() { KeyConversionInputManager = CreateKeyConversionInputManager(); @@ -32,10 +53,9 @@ namespace osu.Game.Modes.UI } /// - /// Whether all the HitObjects have been judged. + /// Triggers a judgement for further processing. /// - protected abstract bool AllObjectsJudged { get; } - + /// The judgement to trigger. protected void TriggerOnJudgement(JudgementInfo j) { OnJudgement?.Invoke(j); @@ -44,12 +64,24 @@ namespace osu.Game.Modes.UI OnAllJudged?.Invoke(); } + /// + /// Creates a key conversion input manager. + /// + /// The input manager. protected virtual KeyConversionInputManager CreateKeyConversionInputManager() => new KeyConversionInputManager(); } + /// + /// HitRenderer that applies conversion to Beatmaps. Does not contain a Playfield + /// and does not load drawable hit objects. + /// + /// The type of HitObject contained by this HitRenderer. public abstract class HitRenderer : HitRenderer where TObject : HitObject { + /// + /// The Beatmap + /// public Beatmap Beatmap; protected HitRenderer(WorkingBeatmap beatmap) @@ -61,6 +93,10 @@ namespace osu.Game.Modes.UI RelativeSizeAxes = Axes.Both; } + /// + /// Applies the active mods to this HitRenderer. + /// + /// private void applyMods(IEnumerable mods) { if (mods == null) @@ -70,9 +106,18 @@ namespace osu.Game.Modes.UI mod.Apply(this); } + /// + /// Creates a converter to convert Beatmap to a specific mode. + /// + /// The Beatmap converter. protected abstract IBeatmapConverter CreateBeatmapConverter(); } + /// + /// A derivable HitRenderer that manages the Playfield and HitObjects. + /// + /// The type of HitObject contained by this HitRenderer. + /// The type of Judgement of DrawableHitObjects contained by this HitRenderer. public abstract class HitRenderer : HitRenderer where TObject : HitObject where TJudgement : JudgementInfo @@ -80,6 +125,9 @@ namespace osu.Game.Modes.UI protected override Container Content => content; protected override bool AllObjectsJudged => Playfield.HitObjects.Children.All(h => h.Judgement.Result.HasValue); + /// + /// The playfield. + /// protected Playfield Playfield; private Container content; @@ -124,13 +172,27 @@ namespace osu.Game.Modes.UI Playfield.PostProcess(); } - private void onJudgement(DrawableHitObject j) + /// + /// Triggered when an object's Judgement is updated. + /// + /// The object that Judgement has been updated for. + private void onJudgement(DrawableHitObject judgedObject) { - TriggerOnJudgement(j.Judgement); - Playfield.OnJudgement(j); + TriggerOnJudgement(judgedObject.Judgement); + Playfield.OnJudgement(judgedObject); } + /// + /// Creates a DrawableHitObject from a HitObject. + /// + /// The HitObject to make drawable. + /// The DrawableHitObject. protected abstract DrawableHitObject GetVisualRepresentation(TObject h); + + /// + /// Creates a Playfield. + /// + /// The Playfield. protected abstract Playfield CreatePlayfield(); } } diff --git a/osu.Game/Modes/UI/Playfield.cs b/osu.Game/Modes/UI/Playfield.cs index ba12fa4abf..288b4bf352 100644 --- a/osu.Game/Modes/UI/Playfield.cs +++ b/osu.Game/Modes/UI/Playfield.cs @@ -14,16 +14,15 @@ namespace osu.Game.Modes.UI where TObject : HitObject where TJudgement : JudgementInfo { + /// + /// The HitObjects contained in this Playfield. + /// public HitObjectContainer> HitObjects; - - public virtual void Add(DrawableHitObject h) => HitObjects.Add(h); + public override bool Contains(Vector2 screenSpacePos) => true; internal Container ScaledContent; - public override bool Contains(Vector2 screenSpacePos) => true; - protected override Container Content => content; - private Container content; /// @@ -51,9 +50,22 @@ namespace osu.Game.Modes.UI }); } - public virtual void PostProcess() - { - } + /// + /// Performs post-processing tasks (if any) after all DrawableHitObjects are loaded into this Playfield. + /// + public virtual void PostProcess() { } + + /// + /// Adds a DrawableHitObject to this Playfield. + /// + /// The DrawableHitObject to add. + public virtual void Add(DrawableHitObject h) => HitObjects.Add(h); + + /// + /// Triggered when an object's Judgement is updated. + /// + /// The object that Judgement has been updated for. + public virtual void OnJudgement(DrawableHitObject judgedObject) { } private class ScaledContainer : Container { @@ -72,7 +84,5 @@ namespace osu.Game.Modes.UI { public override bool Contains(Vector2 screenSpacePos) => true; } - - public virtual void OnJudgement(DrawableHitObject judgedObject) { } } }