From a79fde897b533913e146f8f5bf83457bd3b19d06 Mon Sep 17 00:00:00 2001 From: Damnae Date: Thu, 9 Feb 2017 08:29:21 +0100 Subject: [PATCH] Add StackedPosition/StackedEndPosition and offset slider curves by StackOffset. --- .../Objects/Drawables/DrawableHitCircle.cs | 2 +- .../Objects/Drawables/DrawableSlider.cs | 10 +++++----- osu.Game.Modes.Osu/Objects/Drawables/HitExplosion.cs | 2 +- osu.Game.Modes.Osu/Objects/OsuHitObject.cs | 9 +++++++-- osu.Game.Modes.Osu/Objects/Slider.cs | 12 ++++++++++++ osu.Game.Modes.Osu/Objects/SliderCurve.cs | 10 ++++++---- 6 files changed, 32 insertions(+), 13 deletions(-) diff --git a/osu.Game.Modes.Osu/Objects/Drawables/DrawableHitCircle.cs b/osu.Game.Modes.Osu/Objects/Drawables/DrawableHitCircle.cs index d96726844a..8f59f05001 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/DrawableHitCircle.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/DrawableHitCircle.cs @@ -28,7 +28,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables osuObject = h; Origin = Anchor.Centre; - Position = osuObject.Position + h.StackOffset; + Position = osuObject.StackedPosition; Scale = new Vector2(osuObject.Scale); Children = new Drawable[] diff --git a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs index 5587f9c4a2..611daad642 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/DrawableSlider.cs @@ -31,7 +31,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables { body = new SliderBody(s) { - Position = s.Position + s.StackOffset, + Position = s.StackedPosition, PathWidth = s.Scale * 64, }, bouncer1 = new SliderBouncer(s, false) @@ -41,7 +41,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables }, bouncer2 = new SliderBouncer(s, true) { - Position = s.Position + s.StackOffset, + Position = s.StackedPosition, Scale = new Vector2(s.Scale), }, ball = new SliderBall(s) @@ -51,7 +51,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables initialCircle = new DrawableHitCircle(new HitCircle { StartTime = s.StartTime, - Position = s.Position + s.StackOffset, + Position = s.StackedPosition, Scale = s.Scale, Colour = s.Colour, Sample = s.Sample, @@ -89,11 +89,11 @@ namespace osu.Game.Modes.Osu.Objects.Drawables if (repeat % 2 == 1) progress = 1 - progress; - bouncer2.Position = slider.Curve.PositionAt(body.SnakedEnd ?? 0) + slider.StackOffset; + bouncer2.Position = slider.Curve.PositionAt(body.SnakedEnd ?? 0); //todo: we probably want to reconsider this before adding scoring, but it looks and feels nice. if (initialCircle.Judgement?.Result != HitResult.Hit) - initialCircle.Position = slider.Curve.PositionAt(progress) + slider.StackOffset; + initialCircle.Position = slider.Curve.PositionAt(progress); components.ForEach(c => c.UpdateProgress(progress, repeat)); } diff --git a/osu.Game.Modes.Osu/Objects/Drawables/HitExplosion.cs b/osu.Game.Modes.Osu/Objects/Drawables/HitExplosion.cs index 51a944cb18..96360a6291 100644 --- a/osu.Game.Modes.Osu/Objects/Drawables/HitExplosion.cs +++ b/osu.Game.Modes.Osu/Objects/Drawables/HitExplosion.cs @@ -26,7 +26,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables Direction = FlowDirection.VerticalOnly; Spacing = new Vector2(0, 2); - Position = (h?.EndPosition ?? Vector2.Zero) + judgement.PositionOffset; + Position = (h?.StackedEndPosition ?? Vector2.Zero) + judgement.PositionOffset; Children = new Drawable[] { diff --git a/osu.Game.Modes.Osu/Objects/OsuHitObject.cs b/osu.Game.Modes.Osu/Objects/OsuHitObject.cs index 465751ba97..5c3121e76c 100644 --- a/osu.Game.Modes.Osu/Objects/OsuHitObject.cs +++ b/osu.Game.Modes.Osu/Objects/OsuHitObject.cs @@ -13,13 +13,18 @@ namespace osu.Game.Modes.Osu.Objects { public Vector2 Position { get; set; } - public float Scale { get; set; } = 1; + public Vector2 StackedPosition => Position + StackOffset; public virtual Vector2 EndPosition => Position; - public int StackHeight { get; set; } + public Vector2 StackedEndPosition => EndPosition + StackOffset; + + public virtual int StackHeight { get; set; } + public Vector2 StackOffset => new Vector2(StackHeight * Scale * -6.4f); + public float Scale { get; set; } = 1; + public override void SetDefaultsFromBeatmap(Beatmap beatmap) { base.SetDefaultsFromBeatmap(beatmap); diff --git a/osu.Game.Modes.Osu/Objects/Slider.cs b/osu.Game.Modes.Osu/Objects/Slider.cs index 2269aa0ce5..85ee83a7f8 100644 --- a/osu.Game.Modes.Osu/Objects/Slider.cs +++ b/osu.Game.Modes.Osu/Objects/Slider.cs @@ -12,6 +12,18 @@ namespace osu.Game.Modes.Osu.Objects public override Vector2 EndPosition => RepeatCount % 2 == 0 ? Position : Curve.PositionAt(1); + private int stackHeight; + public override int StackHeight + { + get { return stackHeight; } + set + { + stackHeight = value; + if (Curve != null) + Curve.Offset = StackOffset; + } + } + public double Velocity; public override void SetDefaultsFromBeatmap(Beatmap beatmap) diff --git a/osu.Game.Modes.Osu/Objects/SliderCurve.cs b/osu.Game.Modes.Osu/Objects/SliderCurve.cs index 9c035ac010..4e3fe34a1d 100644 --- a/osu.Game.Modes.Osu/Objects/SliderCurve.cs +++ b/osu.Game.Modes.Osu/Objects/SliderCurve.cs @@ -17,6 +17,8 @@ namespace osu.Game.Modes.Osu.Objects public CurveTypes CurveType; + public Vector2 Offset; + private List calculatedPath = new List(); private List cumulativeLength = new List(); @@ -177,12 +179,12 @@ namespace osu.Game.Modes.Osu.Objects int i = 0; for (; i < calculatedPath.Count && cumulativeLength[i] < d0; ++i); - path.Add(interpolateVertices(i, d0)); + path.Add(interpolateVertices(i, d0) + Offset); for (; i < calculatedPath.Count && cumulativeLength[i] <= d1; ++i) - path.Add(calculatedPath[i]); + path.Add(calculatedPath[i] + Offset); - path.Add(interpolateVertices(i, d1)); + path.Add(interpolateVertices(i, d1) + Offset); } /// @@ -194,7 +196,7 @@ namespace osu.Game.Modes.Osu.Objects public Vector2 PositionAt(double progress) { double d = progressToDistance(progress); - return interpolateVertices(indexOfDistance(d), d); + return interpolateVertices(indexOfDistance(d), d) + Offset; } } } \ No newline at end of file