diff --git a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs index 924a52a858..1bebe9dae0 100644 --- a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs +++ b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapProcessor.cs @@ -16,29 +16,13 @@ namespace osu.Game.Rulesets.Catch.Beatmaps { public override void PostProcess(Beatmap beatmap) { - if (beatmap.ComboColours.Count == 0) - return; - - int index = 0; - int colourIndex = 0; - - CatchHitObject lastObj = null; - initialiseHyperDash(beatmap.HitObjects); + base.PostProcess(beatmap); + + int index = 0; foreach (var obj in beatmap.HitObjects) - { - if (obj.NewCombo) - { - if (lastObj != null) lastObj.LastInCombo = true; - colourIndex = (colourIndex + 1) % beatmap.ComboColours.Count; - } - obj.IndexInBeatmap = index++; - obj.AccentColour = beatmap.ComboColours[colourIndex]; - - lastObj = obj; - } } private void initialiseHyperDash(List objects) diff --git a/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapProcessor.cs b/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapProcessor.cs index bfcdec9321..42b22a71ec 100644 --- a/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapProcessor.cs +++ b/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapProcessor.cs @@ -13,24 +13,7 @@ namespace osu.Game.Rulesets.Osu.Beatmaps public override void PostProcess(Beatmap beatmap) { applyStacking(beatmap); - - if (beatmap.ComboColours.Count == 0) - return; - - int comboIndex = 0; - int colourIndex = 0; - - foreach (var obj in beatmap.HitObjects) - { - if (obj.NewCombo) - { - comboIndex = 0; - colourIndex = (colourIndex + 1) % beatmap.ComboColours.Count; - } - - obj.IndexInCurrentCombo = comboIndex++; - obj.ComboColour = beatmap.ComboColours[colourIndex]; - } + base.PostProcess(beatmap); } private void applyStacking(Beatmap beatmap) diff --git a/osu.Game/Beatmaps/BeatmapProcessor.cs b/osu.Game/Beatmaps/BeatmapProcessor.cs index 9b528699ef..83b2867df7 100644 --- a/osu.Game/Beatmaps/BeatmapProcessor.cs +++ b/osu.Game/Beatmaps/BeatmapProcessor.cs @@ -1,7 +1,9 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // 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 { @@ -19,6 +21,29 @@ namespace osu.Game.Beatmaps /// /// /// The Beatmap to process. - public virtual void PostProcess(Beatmap beatmap) { } + public virtual void PostProcess(Beatmap beatmap) + { + IHasComboIndex lastObj = null; + + foreach (var obj in beatmap.HitObjects.OfType()) + { + if (obj.NewCombo) + { + obj.IndexInCurrentCombo = 0; + if (lastObj != null) + { + lastObj.LastInCombo = true; + obj.ComboIndex = lastObj.ComboIndex + 1; + } + } + else if (lastObj != null) + { + obj.IndexInCurrentCombo = lastObj.IndexInCurrentCombo + 1; + obj.ComboIndex = lastObj.ComboIndex; + } + + lastObj = obj; + } + } } } diff --git a/osu.Game/Rulesets/Objects/Types/IHasComboIndex.cs b/osu.Game/Rulesets/Objects/Types/IHasComboIndex.cs new file mode 100644 index 0000000000..68474a6e2c --- /dev/null +++ b/osu.Game/Rulesets/Objects/Types/IHasComboIndex.cs @@ -0,0 +1,26 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +namespace osu.Game.Rulesets.Objects.Types +{ + /// + /// A HitObject that is part of a combo and has extended information about its position relative to other combo objects. + /// + public interface IHasComboIndex : IHasCombo + { + /// + /// The offset of this hitobject in the current combo. + /// + int IndexInCurrentCombo { get; set; } + + /// + /// The offset of this hitobject in the current combo. + /// + int ComboIndex { get; set; } + + /// + /// Whether this is the last object in the current combo. + /// + bool LastInCombo { get; set; } + } +} diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 091ec3f7ac..5ece1a18ac 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -374,6 +374,7 @@ +