From a3c3bfb1a8628e574611c4dcf3d81c8d8d8286ba Mon Sep 17 00:00:00 2001 From: Hanamuke Date: Wed, 12 Sep 2018 19:48:35 +0200 Subject: [PATCH 1/4] Fixes hyperdash computation (for nested objects) --- .../Beatmaps/CatchBeatmapProcessor.cs | 45 ++++++++++--------- .../Objects/CatchHitObject.cs | 4 +- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs index ab0afb08d7..34bddf425c 100644 --- a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs +++ b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs @@ -74,42 +74,43 @@ namespace osu.Game.Rulesets.Catch.Beatmaps private void initialiseHyperDash(List objects) { - // todo: add difficulty adjust. - double halfCatcherWidth = CatcherArea.CATCHER_SIZE * (objects.FirstOrDefault()?.Scale ?? 1) / CatchPlayfield.BASE_WIDTH / 2; + if (objects.Count == 0) + return; + List objectWithDroplets = new List(); + + foreach (var currentObject in objects) + { + if (currentObject is Fruit) + objectWithDroplets.Add(currentObject); + if (currentObject is JuiceStream) + foreach (var currentJuiceElement in currentObject.NestedHitObjects) + if (!(currentJuiceElement is TinyDroplet)) + objectWithDroplets.Add((CatchHitObject)currentJuiceElement); + } + + double halfCatcherWidth = CatcherArea.CATCHER_SIZE * objectWithDroplets[0].Scale / CatchPlayfield.BASE_WIDTH / 2; int lastDirection = 0; double lastExcess = halfCatcherWidth; - int objCount = objects.Count; - - for (int i = 0; i < objCount - 1; i++) + for (int i = 0; i < objectWithDroplets.Count - 1; i++) { - CatchHitObject currentObject = objects[i]; - - // not needed? - // if (currentObject is TinyDroplet) continue; - - CatchHitObject nextObject = objects[i + 1]; - - // while (nextObject is TinyDroplet) - // { - // if (++i == objCount - 1) break; - // nextObject = objects[i + 1]; - // } + CatchHitObject currentObject = objectWithDroplets[i]; + CatchHitObject nextObject = objectWithDroplets[i + 1]; int thisDirection = nextObject.X > currentObject.X ? 1 : -1; - double timeToNext = nextObject.StartTime - ((currentObject as IHasEndTime)?.EndTime ?? currentObject.StartTime) - 4; + double timeToNext = nextObject.StartTime - currentObject.StartTime; double distanceToNext = Math.Abs(nextObject.X - currentObject.X) - (lastDirection == thisDirection ? lastExcess : halfCatcherWidth); - - if (timeToNext * CatcherArea.Catcher.BASE_SPEED < distanceToNext) + float distanceToHyper = (float)(timeToNext * CatcherArea.Catcher.BASE_SPEED - distanceToNext); + if (distanceToHyper < 0) { currentObject.HyperDashTarget = nextObject; lastExcess = halfCatcherWidth; } else { - //currentObject.DistanceToHyperDash = timeToNext - distanceToNext; - lastExcess = MathHelper.Clamp(timeToNext - distanceToNext, 0, halfCatcherWidth); + currentObject.DistanceToHyperDash = distanceToHyper; + lastExcess = MathHelper.Clamp(distanceToHyper, 0, halfCatcherWidth); } lastDirection = thisDirection; diff --git a/osu.Game.Rulesets.Catch/Objects/CatchHitObject.cs b/osu.Game.Rulesets.Catch/Objects/CatchHitObject.cs index 621fc100c2..5eae4de9e6 100644 --- a/osu.Game.Rulesets.Catch/Objects/CatchHitObject.cs +++ b/osu.Game.Rulesets.Catch/Objects/CatchHitObject.cs @@ -27,7 +27,9 @@ namespace osu.Game.Rulesets.Catch.Objects public int ComboIndex { get; set; } /// - /// The distance for a fruit to to next hyper if it's not a hyper. + /// The difference between the distance of the next object + /// and the distance that would have triggered hyper dashing. + /// A value close to 0 indicates a difficult jump (for SR calculation) /// public float DistanceToHyperDash { get; set; } From 7d3380db665fb938c5c9c6992d76eec07a5fa6e7 Mon Sep 17 00:00:00 2001 From: Hanamuke Date: Thu, 13 Sep 2018 17:01:33 +0200 Subject: [PATCH 2/4] Fixed comment. Created static CatchArea.GetCatcheWidth method --- osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs | 5 +---- osu.Game.Rulesets.Catch/Objects/CatchHitObject.cs | 6 +++--- osu.Game.Rulesets.Catch/UI/CatcherArea.cs | 5 +++++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs index 34bddf425c..d4be6564ca 100644 --- a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs +++ b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs @@ -74,9 +74,6 @@ namespace osu.Game.Rulesets.Catch.Beatmaps private void initialiseHyperDash(List objects) { - if (objects.Count == 0) - return; - List objectWithDroplets = new List(); foreach (var currentObject in objects) @@ -89,7 +86,7 @@ namespace osu.Game.Rulesets.Catch.Beatmaps objectWithDroplets.Add((CatchHitObject)currentJuiceElement); } - double halfCatcherWidth = CatcherArea.CATCHER_SIZE * objectWithDroplets[0].Scale / CatchPlayfield.BASE_WIDTH / 2; + double halfCatcherWidth = CatcherArea.GetCatcherSize(Beatmap.BeatmapInfo.BaseDifficulty) / 2; int lastDirection = 0; double lastExcess = halfCatcherWidth; diff --git a/osu.Game.Rulesets.Catch/Objects/CatchHitObject.cs b/osu.Game.Rulesets.Catch/Objects/CatchHitObject.cs index 5eae4de9e6..773bf576dd 100644 --- a/osu.Game.Rulesets.Catch/Objects/CatchHitObject.cs +++ b/osu.Game.Rulesets.Catch/Objects/CatchHitObject.cs @@ -27,9 +27,9 @@ namespace osu.Game.Rulesets.Catch.Objects public int ComboIndex { get; set; } /// - /// The difference between the distance of the next object - /// and the distance that would have triggered hyper dashing. - /// A value close to 0 indicates a difficult jump (for SR calculation) + /// Difference between the distance to the next object + /// and the distance that would have triggered a hyper dash. + /// A value close to 0 indicates a difficult jump (for difficulty calculation). /// public float DistanceToHyperDash { get; set; } diff --git a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs index 9460512a8d..1662246b62 100644 --- a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs +++ b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs @@ -107,6 +107,11 @@ namespace osu.Game.Rulesets.Catch.UI public bool AttemptCatch(CatchHitObject obj) => MovableCatcher.AttemptCatch(obj); + public static float GetCatcherSize(BeatmapDifficulty difficulty) + { + return (CATCHER_SIZE / CatchPlayfield.BASE_WIDTH) * (1.0f - 0.7f * (difficulty.CircleSize - 5) / 5); + } + public class Catcher : Container, IKeyBindingHandler { /// From 7e07a07c01004655b812c3a01c1614ccf4d7303c Mon Sep 17 00:00:00 2001 From: Hanamuke Date: Thu, 13 Sep 2018 17:15:46 +0200 Subject: [PATCH 3/4] Fix HitObjects being out of order because of nested objects --- osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs index d4be6564ca..c7ea29f8c0 100644 --- a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs +++ b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs @@ -86,6 +86,8 @@ namespace osu.Game.Rulesets.Catch.Beatmaps objectWithDroplets.Add((CatchHitObject)currentJuiceElement); } + objectWithDroplets.Sort((h1, h2) => h1.StartTime.CompareTo(h2.StartTime)); + double halfCatcherWidth = CatcherArea.GetCatcherSize(Beatmap.BeatmapInfo.BaseDifficulty) / 2; int lastDirection = 0; double lastExcess = halfCatcherWidth; From 9b6f5c90976a41595814aec313d643349a7a8626 Mon Sep 17 00:00:00 2001 From: Hanamuke Date: Thu, 13 Sep 2018 17:29:10 +0200 Subject: [PATCH 4/4] Fix redundant paranthesis --- osu.Game.Rulesets.Catch/UI/CatcherArea.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs index 1662246b62..be56ccf8c1 100644 --- a/osu.Game.Rulesets.Catch/UI/CatcherArea.cs +++ b/osu.Game.Rulesets.Catch/UI/CatcherArea.cs @@ -109,7 +109,7 @@ namespace osu.Game.Rulesets.Catch.UI public static float GetCatcherSize(BeatmapDifficulty difficulty) { - return (CATCHER_SIZE / CatchPlayfield.BASE_WIDTH) * (1.0f - 0.7f * (difficulty.CircleSize - 5) / 5); + return CATCHER_SIZE / CatchPlayfield.BASE_WIDTH * (1.0f - 0.7f * (difficulty.CircleSize - 5) / 5); } public class Catcher : Container, IKeyBindingHandler