1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 16:02:58 +08:00

Only call IUpdatableByPlayfield.Update if the playfield isn't nested

This commit is contained in:
Henry Lin 2022-03-03 14:37:39 +08:00
parent a38eb426ef
commit 464be6e64c
2 changed files with 19 additions and 1 deletions

View File

@ -5,8 +5,19 @@ using osu.Game.Rulesets.UI;
namespace osu.Game.Rulesets.Mods
{
/// <summary>
/// An interface for <see cref="Mod"/>s that are updated every frame by a <see cref="Playfield"/>.
/// </summary>
public interface IUpdatableByPlayfield : IApplicableMod
{
/// <summary>
/// Update this <see cref="Mod"/>.
/// </summary>
/// <param name="playfield">The main <see cref="Playfield"/></param>
/// <remarks>
/// This method is called once per frame during gameplay by the main <see cref="Playfield"/> only.
/// To access nested <see cref="Playfield"/>s, use <see cref="Playfield.NestedPlayfields"/>.
/// </remarks>
void Update(Playfield playfield);
}
}

View File

@ -79,6 +79,11 @@ namespace osu.Game.Rulesets.UI
private readonly List<Playfield> nestedPlayfields = new List<Playfield>();
/// <summary>
/// Whether this <see cref="Playfield"/> is nested in another <see cref="Playfield"/>.
/// </summary>
public bool IsNested { get; private set; }
/// <summary>
/// Whether judgements should be displayed by this and and all nested <see cref="Playfield"/>s.
/// </summary>
@ -206,6 +211,8 @@ namespace osu.Game.Rulesets.UI
/// <param name="otherPlayfield">The <see cref="Playfield"/> to add.</param>
protected void AddNested(Playfield otherPlayfield)
{
otherPlayfield.IsNested = true;
otherPlayfield.DisplayJudgements.BindTo(DisplayJudgements);
otherPlayfield.NewResult += (d, r) => NewResult?.Invoke(d, r);
@ -229,7 +236,7 @@ namespace osu.Game.Rulesets.UI
{
base.Update();
if (mods != null)
if (!IsNested && mods != null)
{
foreach (var mod in mods)
{