1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 10:42:54 +08:00
osu-lazer/osu.Game/Beatmaps/BeatmapProcessor.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

62 lines
1.7 KiB
C#
Raw Normal View History

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