// 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; } /// /// Processes the converted prior to being invoked. /// /// Nested s generated during will not be present by this point, /// and no mods will have been applied to the s. /// /// /// /// This can only be used to add alterations to s generated directly through the conversion process. /// void PreProcess(); /// /// Processes the converted after has been invoked. /// /// Nested s generated during will be present by this point, /// and mods will have been applied to all s. /// /// /// /// This should be used to add alterations to s while they are in their most playable state. /// 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; } public virtual void PreProcess() { 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; } } public virtual void PostProcess() { } } }