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

50 lines
1.7 KiB
C#
Raw Normal View History

2018-01-05 19:21:19 +08:00
// 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;
2017-04-18 15:05:58 +08:00
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types;
2017-09-18 21:32:49 +08:00
namespace osu.Game.Beatmaps
{
/// <summary>
/// Processes a post-converted Beatmap.
/// </summary>
2017-03-16 15:55:08 +08:00
/// <typeparam name="TObject">The type of HitObject contained in the Beatmap.</typeparam>
public class BeatmapProcessor<TObject>
2017-03-16 15:55:08 +08:00
where TObject : HitObject
{
/// <summary>
/// Post-processes a Beatmap to add mode-specific components that aren't added during conversion.
/// <para>
/// An example of such a usage is for combo colours.
/// </para>
/// </summary>
/// <param name="beatmap">The Beatmap to process.</param>
public virtual void PostProcess(Beatmap<TObject> beatmap)
{
2018-03-22 11:35:17 +08:00
IHasComboInformation lastObj = null;
2018-03-22 11:35:17 +08:00
foreach (var obj in beatmap.HitObjects.OfType<IHasComboInformation>())
{
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;
}
}
}
}