mirror of
https://github.com/ppy/osu.git
synced 2025-01-27 14:12:56 +08:00
Move combo information updating to an interface level helper method
This commit is contained in:
parent
e43f2c2c43
commit
8d925c8a8a
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
|
|
||||||
@ -22,34 +20,17 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
public virtual void PreProcess()
|
public virtual void PreProcess()
|
||||||
{
|
{
|
||||||
IHasComboInformation lastObj = null;
|
IHasComboInformation? lastObj = null;
|
||||||
|
|
||||||
bool isFirst = true;
|
|
||||||
|
|
||||||
foreach (var obj in Beatmap.HitObjects.OfType<IHasComboInformation>())
|
foreach (var obj in Beatmap.HitObjects.OfType<IHasComboInformation>())
|
||||||
{
|
{
|
||||||
if (isFirst)
|
if (lastObj == null)
|
||||||
{
|
{
|
||||||
obj.NewCombo = true;
|
|
||||||
|
|
||||||
// first hitobject should always be marked as a new combo for sanity.
|
// first hitobject should always be marked as a new combo for sanity.
|
||||||
isFirst = false;
|
obj.NewCombo = true;
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
obj.UpdateComboInformation(lastObj);
|
||||||
lastObj = obj;
|
lastObj = obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
@ -65,5 +63,26 @@ namespace osu.Game.Rulesets.Objects.Types
|
|||||||
{
|
{
|
||||||
return skin.GetConfig<SkinComboColourLookup, Color4>(new SkinComboColourLookup(comboIndex, combo))?.Value ?? Color4.White;
|
return skin.GetConfig<SkinComboColourLookup, Color4>(new SkinComboColourLookup(comboIndex, combo))?.Value ?? Color4.White;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Given the previous object in the beatmap, update relevant combo information.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="lastObj">The previous hitobject, or null if this is the first object in the beatmap.</param>
|
||||||
|
void UpdateComboInformation(IHasComboInformation? lastObj)
|
||||||
|
{
|
||||||
|
ComboIndex = lastObj?.ComboIndex ?? 0;
|
||||||
|
ComboIndexWithOffsets = lastObj?.ComboIndexWithOffsets ?? 0;
|
||||||
|
IndexInCurrentCombo = (lastObj?.IndexInCurrentCombo + 1) ?? 0;
|
||||||
|
|
||||||
|
if (NewCombo || lastObj == null)
|
||||||
|
{
|
||||||
|
IndexInCurrentCombo = 0;
|
||||||
|
ComboIndex++;
|
||||||
|
ComboIndexWithOffsets += ComboOffset + 1;
|
||||||
|
|
||||||
|
if (lastObj != null)
|
||||||
|
lastObj.LastInCombo = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user