2019-01-24 17:43:03 +09: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 18:19:50 +09:00
|
|
|
|
|
2022-06-17 16:37:17 +09:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2018-03-20 15:45:40 +09:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2017-09-18 22:32:49 +09:00
|
|
|
|
namespace osu.Game.Beatmaps
|
2017-03-14 17:01:21 +09:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2018-06-29 13:07:00 +09:00
|
|
|
|
/// Provides functionality to alter a <see cref="IBeatmap"/> after it has been converted.
|
2017-03-14 17:01:21 +09:00
|
|
|
|
/// </summary>
|
2018-04-19 22:04:12 +09:00
|
|
|
|
public class BeatmapProcessor : IBeatmapProcessor
|
2017-03-14 17:01:21 +09:00
|
|
|
|
{
|
2018-04-19 22:04:12 +09:00
|
|
|
|
public IBeatmap Beatmap { get; }
|
|
|
|
|
|
|
|
|
|
public BeatmapProcessor(IBeatmap beatmap)
|
|
|
|
|
{
|
|
|
|
|
Beatmap = beatmap;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-29 12:45:48 +09:00
|
|
|
|
public virtual void PreProcess()
|
2018-03-20 15:45:40 +09:00
|
|
|
|
{
|
2018-03-22 12:35:17 +09:00
|
|
|
|
IHasComboInformation lastObj = null;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2020-10-06 19:04:50 +09:00
|
|
|
|
bool isFirst = true;
|
|
|
|
|
|
2018-04-19 22:04:12 +09:00
|
|
|
|
foreach (var obj in Beatmap.HitObjects.OfType<IHasComboInformation>())
|
2018-03-20 15:45:40 +09:00
|
|
|
|
{
|
2020-10-06 19:04:50 +09:00
|
|
|
|
if (isFirst)
|
|
|
|
|
{
|
|
|
|
|
obj.NewCombo = true;
|
|
|
|
|
|
|
|
|
|
// first hitobject should always be marked as a new combo for sanity.
|
|
|
|
|
isFirst = false;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-21 17:32:56 +09:00
|
|
|
|
obj.ComboIndex = lastObj?.ComboIndex ?? 0;
|
|
|
|
|
obj.ComboIndexWithOffsets = lastObj?.ComboIndexWithOffsets ?? 0;
|
|
|
|
|
obj.IndexInCurrentCombo = (lastObj?.IndexInCurrentCombo + 1) ?? 0;
|
|
|
|
|
|
2018-03-20 15:45:40 +09:00
|
|
|
|
if (obj.NewCombo)
|
|
|
|
|
{
|
|
|
|
|
obj.IndexInCurrentCombo = 0;
|
2021-07-21 17:32:56 +09:00
|
|
|
|
obj.ComboIndex++;
|
|
|
|
|
obj.ComboIndexWithOffsets += obj.ComboOffset + 1;
|
2018-08-15 11:48:50 +09:00
|
|
|
|
|
2018-03-20 15:45:40 +09:00
|
|
|
|
if (lastObj != null)
|
|
|
|
|
lastObj.LastInCombo = true;
|
|
|
|
|
}
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2018-03-20 15:45:40 +09:00
|
|
|
|
lastObj = obj;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-06-29 12:45:48 +09:00
|
|
|
|
|
|
|
|
|
public virtual void PostProcess()
|
|
|
|
|
{
|
|
|
|
|
}
|
2017-03-14 17:01:21 +09:00
|
|
|
|
}
|
|
|
|
|
}
|