2019-01-24 08:43:03 +00:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Beatmaps
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2018-06-29 04:07:00 +00:00
|
|
|
|
/// Provides functionality to alter a <see cref="IBeatmap"/> after it has been converted.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
/// </summary>
|
2018-04-19 13:04:12 +00:00
|
|
|
|
public class BeatmapProcessor : IBeatmapProcessor
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2018-04-19 13:04:12 +00:00
|
|
|
|
public IBeatmap Beatmap { get; }
|
|
|
|
|
|
|
|
|
|
public BeatmapProcessor(IBeatmap beatmap)
|
|
|
|
|
{
|
|
|
|
|
Beatmap = beatmap;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-29 03:45:48 +00:00
|
|
|
|
public virtual void PreProcess()
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
IHasComboInformation lastObj = null;
|
|
|
|
|
|
2018-04-19 13:04:12 +00:00
|
|
|
|
foreach (var obj in Beatmap.HitObjects.OfType<IHasComboInformation>())
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
if (obj.NewCombo)
|
|
|
|
|
{
|
|
|
|
|
obj.IndexInCurrentCombo = 0;
|
2018-08-15 02:48:50 +00:00
|
|
|
|
obj.ComboIndex = (lastObj?.ComboIndex ?? 0) + obj.ComboOffset + 1;
|
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
if (lastObj != null)
|
|
|
|
|
lastObj.LastInCombo = true;
|
|
|
|
|
}
|
|
|
|
|
else if (lastObj != null)
|
|
|
|
|
{
|
|
|
|
|
obj.IndexInCurrentCombo = lastObj.IndexInCurrentCombo + 1;
|
|
|
|
|
obj.ComboIndex = lastObj.ComboIndex;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lastObj = obj;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-06-29 03:45:48 +00:00
|
|
|
|
|
|
|
|
|
public virtual void PostProcess()
|
|
|
|
|
{
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|