1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 01:27:29 +08:00
osu-lazer/osu.Game/Beatmaps/BeatmapProcessor.cs

50 lines
1.4 KiB
C#

// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// 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
{
/// <summary>
/// Provides functionality to alter a <see cref="IBeatmap"/> after it has been converted.
/// </summary>
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<IHasComboInformation>())
{
if (obj.NewCombo)
{
obj.IndexInCurrentCombo = 0;
obj.ComboIndex = (lastObj?.ComboIndex ?? 0) + obj.ComboOffset + 1;
if (lastObj != null)
lastObj.LastInCombo = true;
}
else if (lastObj != null)
{
obj.IndexInCurrentCombo = lastObj.IndexInCurrentCombo + 1;
obj.ComboIndex = lastObj.ComboIndex;
}
lastObj = obj;
}
}
public virtual void PostProcess()
{
}
}
}