// 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.Types; namespace osu.Game.Beatmaps { public interface IBeatmapProcessor { IBeatmap Beatmap { get; } /// /// Post-processes to add mode-specific components that aren't added during conversion. /// /// An example of such a usage is for combo colours. /// /// void PostProcess(); } /// /// Processes a post-converted Beatmap. /// /// The type of HitObject contained in the Beatmap. public class BeatmapProcessor : IBeatmapProcessor { public IBeatmap Beatmap { get; } public BeatmapProcessor(IBeatmap beatmap) { Beatmap = beatmap; } /// /// Post-processes a Beatmap to add mode-specific components that aren't added during conversion. /// /// An example of such a usage is for combo colours. /// /// public virtual void PostProcess() { IHasComboInformation 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; } } } }