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