2018-01-05 11:21:19 +00:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-03-14 08:07:38 +00:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2018-03-20 06:45:40 +00:00
|
|
|
|
using System.Linq;
|
2017-04-18 07:05:58 +00:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2018-03-20 06:45:40 +00:00
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
2017-03-14 08:01:21 +00:00
|
|
|
|
|
2017-09-18 13:32:49 +00:00
|
|
|
|
namespace osu.Game.Beatmaps
|
2017-03-14 08:01:21 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Processes a post-converted Beatmap.
|
|
|
|
|
/// </summary>
|
2017-03-16 07:55:08 +00:00
|
|
|
|
/// <typeparam name="TObject">The type of HitObject contained in the Beatmap.</typeparam>
|
2017-04-18 00:43:43 +00:00
|
|
|
|
public class BeatmapProcessor<TObject>
|
2017-03-16 07:55:08 +00:00
|
|
|
|
where TObject : HitObject
|
2017-03-14 08:01:21 +00:00
|
|
|
|
{
|
|
|
|
|
/// <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>
|
2018-03-20 06:45:40 +00:00
|
|
|
|
public virtual void PostProcess(Beatmap<TObject> beatmap)
|
|
|
|
|
{
|
2018-03-22 03:35:17 +00:00
|
|
|
|
IHasComboInformation lastObj = null;
|
2018-03-20 06:45:40 +00:00
|
|
|
|
|
2018-03-22 03:35:17 +00:00
|
|
|
|
foreach (var obj in beatmap.HitObjects.OfType<IHasComboInformation>())
|
2018-03-20 06:45:40 +00:00
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-03-14 08:01:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|