From 1c2cc3837a59d6023fa086db90ea1ccd50e9fdd6 Mon Sep 17 00:00:00 2001 From: Hanamuke Date: Thu, 13 Sep 2018 21:52:15 +0200 Subject: [PATCH 1/5] Compute combo for nested Objects. Display fruit depending on Combo for osu!catch --- osu.Game.Rulesets.Catch/Objects/CatchHitObject.cs | 2 +- osu.Game/Beatmaps/BeatmapProcessor.cs | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Catch/Objects/CatchHitObject.cs b/osu.Game.Rulesets.Catch/Objects/CatchHitObject.cs index 621fc100c2..2346a55bbe 100644 --- a/osu.Game.Rulesets.Catch/Objects/CatchHitObject.cs +++ b/osu.Game.Rulesets.Catch/Objects/CatchHitObject.cs @@ -16,7 +16,7 @@ namespace osu.Game.Rulesets.Catch.Objects public int IndexInBeatmap { get; set; } - public virtual FruitVisualRepresentation VisualRepresentation => (FruitVisualRepresentation)(IndexInBeatmap % 4); + public virtual FruitVisualRepresentation VisualRepresentation => (FruitVisualRepresentation)(ComboIndex % 4); public virtual bool NewCombo { get; set; } diff --git a/osu.Game/Beatmaps/BeatmapProcessor.cs b/osu.Game/Beatmaps/BeatmapProcessor.cs index 9d7cd673dc..84bf6ada18 100644 --- a/osu.Game/Beatmaps/BeatmapProcessor.cs +++ b/osu.Game/Beatmaps/BeatmapProcessor.cs @@ -44,6 +44,15 @@ namespace osu.Game.Beatmaps public virtual void PostProcess() { + foreach (var hitObject in Beatmap.HitObjects) + { + var objectComboInfo = (IHasComboInformation)hitObject; + foreach (var obj in hitObject.NestedHitObjects.OfType()) + { + obj.IndexInCurrentCombo = objectComboInfo.IndexInCurrentCombo; + obj.ComboIndex = objectComboInfo.ComboIndex; + } + } } } } From 347cb0a1b5bdaf64f90a4dfc699a1dd2b30d5856 Mon Sep 17 00:00:00 2001 From: Hanamuke Date: Fri, 14 Sep 2018 19:41:29 +0200 Subject: [PATCH 2/5] Check for type conversion, mais the update recursive --- osu.Game/Beatmaps/BeatmapProcessor.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapProcessor.cs b/osu.Game/Beatmaps/BeatmapProcessor.cs index 84bf6ada18..1a767942eb 100644 --- a/osu.Game/Beatmaps/BeatmapProcessor.cs +++ b/osu.Game/Beatmaps/BeatmapProcessor.cs @@ -44,13 +44,24 @@ namespace osu.Game.Beatmaps public virtual void PostProcess() { + void UpdateNestedCombo(Rulesets.Objects.HitObject obj, int comboIndex, int indexInCurrentCombo) + { + if (obj is IHasComboInformation) + { + var objectComboInfo = (IHasComboInformation)obj; + objectComboInfo.ComboIndex = comboIndex; + objectComboInfo.IndexInCurrentCombo = indexInCurrentCombo; + foreach (var nestedObjet in obj.NestedHitObjects) + UpdateNestedCombo(nestedObjet, comboIndex, indexInCurrentCombo); + } + } foreach (var hitObject in Beatmap.HitObjects) { - var objectComboInfo = (IHasComboInformation)hitObject; - foreach (var obj in hitObject.NestedHitObjects.OfType()) + if (hitObject is IHasComboInformation) { - obj.IndexInCurrentCombo = objectComboInfo.IndexInCurrentCombo; - obj.ComboIndex = objectComboInfo.ComboIndex; + var objectComboInfo = (IHasComboInformation)hitObject; + foreach (var nested in hitObject.NestedHitObjects) + UpdateNestedCombo(nested, objectComboInfo.ComboIndex, objectComboInfo.IndexInCurrentCombo); } } } From c8d3776c79767b24b6772ee87014f5bd67008c8f Mon Sep 17 00:00:00 2001 From: Hanamuke Date: Fri, 14 Sep 2018 19:46:04 +0200 Subject: [PATCH 3/5] Remove uneeded brackets --- osu.Game/Beatmaps/BeatmapProcessor.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapProcessor.cs b/osu.Game/Beatmaps/BeatmapProcessor.cs index 1a767942eb..35420efa8e 100644 --- a/osu.Game/Beatmaps/BeatmapProcessor.cs +++ b/osu.Game/Beatmaps/BeatmapProcessor.cs @@ -56,14 +56,12 @@ namespace osu.Game.Beatmaps } } foreach (var hitObject in Beatmap.HitObjects) - { if (hitObject is IHasComboInformation) { var objectComboInfo = (IHasComboInformation)hitObject; foreach (var nested in hitObject.NestedHitObjects) UpdateNestedCombo(nested, objectComboInfo.ComboIndex, objectComboInfo.IndexInCurrentCombo); } - } } } } From 3e7006ec1fe25a650b8ef33107d91b71dd3a4f7e Mon Sep 17 00:00:00 2001 From: Hanamuke Date: Fri, 14 Sep 2018 19:52:32 +0200 Subject: [PATCH 4/5] Fix fonction name --- osu.Game/Beatmaps/BeatmapProcessor.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapProcessor.cs b/osu.Game/Beatmaps/BeatmapProcessor.cs index 35420efa8e..7007c41402 100644 --- a/osu.Game/Beatmaps/BeatmapProcessor.cs +++ b/osu.Game/Beatmaps/BeatmapProcessor.cs @@ -44,7 +44,7 @@ namespace osu.Game.Beatmaps public virtual void PostProcess() { - void UpdateNestedCombo(Rulesets.Objects.HitObject obj, int comboIndex, int indexInCurrentCombo) + void updateNestedCombo(Rulesets.Objects.HitObject obj, int comboIndex, int indexInCurrentCombo) { if (obj is IHasComboInformation) { @@ -52,7 +52,7 @@ namespace osu.Game.Beatmaps objectComboInfo.ComboIndex = comboIndex; objectComboInfo.IndexInCurrentCombo = indexInCurrentCombo; foreach (var nestedObjet in obj.NestedHitObjects) - UpdateNestedCombo(nestedObjet, comboIndex, indexInCurrentCombo); + updateNestedCombo(nestedObjet, comboIndex, indexInCurrentCombo); } } foreach (var hitObject in Beatmap.HitObjects) @@ -60,7 +60,7 @@ namespace osu.Game.Beatmaps { var objectComboInfo = (IHasComboInformation)hitObject; foreach (var nested in hitObject.NestedHitObjects) - UpdateNestedCombo(nested, objectComboInfo.ComboIndex, objectComboInfo.IndexInCurrentCombo); + updateNestedCombo(nested, objectComboInfo.ComboIndex, objectComboInfo.IndexInCurrentCombo); } } } From aba1de8b1ab1c29c85a126cbc065b9d52c884c30 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 18 Sep 2018 12:54:07 +0900 Subject: [PATCH 5/5] Cleanup --- osu.Game/Beatmaps/BeatmapProcessor.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapProcessor.cs b/osu.Game/Beatmaps/BeatmapProcessor.cs index 7007c41402..9db2c5f08e 100644 --- a/osu.Game/Beatmaps/BeatmapProcessor.cs +++ b/osu.Game/Beatmaps/BeatmapProcessor.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Linq; +using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Types; namespace osu.Game.Beatmaps @@ -44,24 +45,25 @@ namespace osu.Game.Beatmaps public virtual void PostProcess() { - void updateNestedCombo(Rulesets.Objects.HitObject obj, int comboIndex, int indexInCurrentCombo) + void updateNestedCombo(HitObject obj, int comboIndex, int indexInCurrentCombo) { - if (obj is IHasComboInformation) + if (obj is IHasComboInformation objectComboInfo) { - var objectComboInfo = (IHasComboInformation)obj; objectComboInfo.ComboIndex = comboIndex; objectComboInfo.IndexInCurrentCombo = indexInCurrentCombo; - foreach (var nestedObjet in obj.NestedHitObjects) - updateNestedCombo(nestedObjet, comboIndex, indexInCurrentCombo); + foreach (var nestedObject in obj.NestedHitObjects) + updateNestedCombo(nestedObject, comboIndex, indexInCurrentCombo); } } + foreach (var hitObject in Beatmap.HitObjects) - if (hitObject is IHasComboInformation) + { + if (hitObject is IHasComboInformation objectComboInfo) { - var objectComboInfo = (IHasComboInformation)hitObject; foreach (var nested in hitObject.NestedHitObjects) updateNestedCombo(nested, objectComboInfo.ComboIndex, objectComboInfo.IndexInCurrentCombo); } + } } } }