diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs index 6cf353eaf2..b6a07aa4e3 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Linq; using osu.Framework.Graphics; using osu.Game.Rulesets.Objects.Drawables; using OpenTK; @@ -15,6 +16,7 @@ public class DrawableRepeatPoint : DrawableOsuHitObject, ITrackSnaking { private readonly RepeatPoint repeatPoint; private readonly DrawableSlider drawableSlider; + private bool isEndRepeat => repeatPoint.RepeatIndex % 2 == 0; public double FadeInTime; public double FadeOutTime; @@ -25,17 +27,17 @@ public DrawableRepeatPoint(RepeatPoint repeatPoint, DrawableSlider drawableSlide this.repeatPoint = repeatPoint; this.drawableSlider = drawableSlider; - Size = new Vector2(32 * repeatPoint.Scale); + Size = new Vector2(45 * repeatPoint.Scale); Blending = BlendingMode.Additive; Origin = Anchor.Centre; - + Children = new Drawable[] { new SpriteIcon { RelativeSizeAxes = Axes.Both, - Icon = FontAwesome.fa_eercast + Icon = FontAwesome.fa_chevron_right } }; } @@ -72,6 +74,14 @@ protected override void UpdateCurrentState(ArmedState state) } } - public void UpdateSnakingPosition(Vector2 start, Vector2 end) => Position = repeatPoint.RepeatIndex % 2 == 0 ? end : start; + public void UpdateSnakingPosition(Vector2 start, Vector2 end) + { + Position = isEndRepeat ? end : start; + var curve = drawableSlider.CurrentCurve; + if (curve.Count < 3 || curve.All(p => p == Position)) + return; + var referencePoint = curve[isEndRepeat ? curve.IndexOf(Position) - 1 : curve.LastIndexOf(Position) + 1]; + Rotation = MathHelper.RadiansToDegrees((float)Math.Atan2(referencePoint.Y - Position.Y, referencePoint.X - Position.X)); + } } } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs index 6f3bb34a89..8deb31db2a 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs @@ -26,6 +26,8 @@ public class DrawableSlider : DrawableOsuHitObject, IDrawableHitObjectWithProxie private readonly Container ticks; private readonly Container repeatPoints; + public List CurrentCurve => Body.CurrentCurve; + public readonly SliderBody Body; public readonly SliderBall Ball; diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBody.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBody.cs index 6fe1fda8eb..901d1c568d 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBody.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/Pieces/SliderBody.cs @@ -89,7 +89,7 @@ public void SetRange(double p0, double p1) // We want the container to have the same size as the slider, // and to be positioned such that the slider head is at (0,0). container.Size = path.Size; - container.Position = -path.PositionInBoundingBox(slider.Curve.PositionAt(0) - currentCurve[0]); + container.Position = -path.PositionInBoundingBox(slider.Curve.PositionAt(0) - CurrentCurve[0]); container.ForceRedraw(); } @@ -148,7 +148,7 @@ private void reloadTexture() path.Texture = texture; } - private readonly List currentCurve = new List(); + public readonly List CurrentCurve = new List(); private bool updateSnaking(double p0, double p1) { if (SnakedStart == p0 && SnakedEnd == p1) return false; @@ -156,11 +156,11 @@ private bool updateSnaking(double p0, double p1) SnakedStart = p0; SnakedEnd = p1; - slider.Curve.GetPathToProgress(currentCurve, p0, p1); + slider.Curve.GetPathToProgress(CurrentCurve, p0, p1); path.ClearVertices(); - foreach (Vector2 p in currentCurve) - path.AddVertex(p - currentCurve[0]); + foreach (Vector2 p in CurrentCurve) + path.AddVertex(p - CurrentCurve[0]); return true; }