diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs b/osu.Game.Modes.Osu/Objects/Drawables/Connections/ConnectionRenderer.cs similarity index 52% rename from osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs rename to osu.Game.Modes.Osu/Objects/Drawables/Connections/ConnectionRenderer.cs index e2131504cf..d35a731feb 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Connections/HitObjectConnection.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Connections/ConnectionRenderer.cs @@ -2,17 +2,18 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Graphics.Containers; -using osu.Game.Modes.Objects.Drawables; +using osu.Game.Modes.Objects; using System.Collections.Generic; namespace osu.Game.Modes.Osu.Objects.Drawables.Connections { - public abstract class HitObjectConnection : Container + public abstract class ConnectionRenderer : Container + where T : HitObject { /// - /// Create drawables inside this container, connecting hitobjects visually, for example with follow points. + /// Create drawables inside this container, connecting hit objects visually, for example with follow points. /// - /// The drawables hit objects to create connections for - public abstract void AddConnections(IEnumerable drawableHitObjects); + /// Hit objects to create connections for + public abstract void AddConnections(IEnumerable hitObjects); } } diff --git a/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointRenderer.cs similarity index 75% rename from osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs rename to osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointRenderer.cs index 3af77e41f8..469ce390d0 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointConnection.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/Connections/FollowPointRenderer.cs @@ -2,15 +2,13 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using OpenTK; -using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.Osu.Objects.Drawables.Connections; using System; using System.Collections.Generic; -using System.Linq; namespace osu.Game.Modes.Osu.Objects.Drawables { - public class FollowPointConnection : HitObjectConnection + public class FollowPointRenderer : ConnectionRenderer { /// /// Determines how much space there is between points. @@ -22,18 +20,12 @@ namespace osu.Game.Modes.Osu.Objects.Drawables /// public int PreEmpt = 800; - public override void AddConnections(IEnumerable drawableHitObjects) + public override void AddConnections(IEnumerable hitObjects) { - var hitObjects = new List(drawableHitObjects - .Select(d => (OsuHitObject)d.HitObject) - .OrderBy(h => h.StartTime)); - - for (int i = 1; i <= hitObjects.Count - 1; i++) + OsuHitObject prevHitObject = null; + foreach (var currHitObject in hitObjects) { - var prevHitObject = hitObjects[i - 1]; - var currHitObject = hitObjects[i]; - - if (!currHitObject.NewCombo && !(prevHitObject is Spinner) && !(currHitObject is Spinner)) + if (prevHitObject != null && !currHitObject.NewCombo && !(prevHitObject is Spinner) && !(currHitObject is Spinner)) { Vector2 startPosition = prevHitObject.EndPosition; Vector2 endPosition = currHitObject.Position; @@ -63,6 +55,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables }); } } + prevHitObject = currHitObject; } } } diff --git a/osu.Game.Modes.Osu/UI/OsuPlayfield.cs b/osu.Game.Modes.Osu/UI/OsuPlayfield.cs index ef7b36b0bd..f2fafc8883 100644 --- a/osu.Game.Modes.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Modes.Osu/UI/OsuPlayfield.cs @@ -9,6 +9,7 @@ using osu.Game.Modes.Osu.Objects; using osu.Game.Modes.Osu.Objects.Drawables; using osu.Game.Modes.Osu.Objects.Drawables.Connections; using osu.Game.Modes.UI; +using System.Linq; namespace osu.Game.Modes.Osu.UI { @@ -16,7 +17,7 @@ namespace osu.Game.Modes.Osu.UI { private Container approachCircles; private Container judgementLayer; - private HitObjectConnection hitObjectConnection; + private ConnectionRenderer connectionLayer; public override Vector2 Size { @@ -38,15 +39,15 @@ namespace osu.Game.Modes.Osu.UI Add(new Drawable[] { - hitObjectConnection = new FollowPointConnection + connectionLayer = new FollowPointRenderer { RelativeSizeAxes = Axes.Both, - Depth = 1, + Depth = 2, }, judgementLayer = new Container { RelativeSizeAxes = Axes.Both, - Depth = 0, + Depth = 1, }, approachCircles = new Container { @@ -72,7 +73,9 @@ namespace osu.Game.Modes.Osu.UI public override void PostProcess() { - hitObjectConnection.AddConnections(HitObjects.Children); + connectionLayer.AddConnections(HitObjects.Children + .Select(d => (OsuHitObject)d.HitObject) + .OrderBy(h => h.StartTime)); } private void judgement(DrawableHitObject h, JudgementInfo j) diff --git a/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj index 567eec593c..d8c381a648 100644 --- a/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj +++ b/osu.Game.Modes.Osu/osu.Game.Modes.Osu.csproj @@ -44,8 +44,8 @@ - - + +