1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 04:13:00 +08:00

Make NestedPlayfields non-null

This commit is contained in:
smoogipoo 2018-07-17 15:48:51 +09:00
parent 0b66f63f7d
commit 48190e3b5a

View File

@ -1,10 +1,13 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Framework.Allocation;
using osu.Framework.Extensions.IEnumerableExtensions;
namespace osu.Game.Rulesets.UI
{
@ -15,11 +18,8 @@ namespace osu.Game.Rulesets.UI
/// </summary>
public HitObjectContainer HitObjects { get; private set; }
/// <summary>
/// All the <see cref="Playfield"/>s nested inside this playfield.
/// </summary>
public IReadOnlyList<Playfield> NestedPlayfields => nestedPlayfields;
private List<Playfield> nestedPlayfields;
private readonly Lazy<List<Playfield>> nestedPlayfields = new Lazy<List<Playfield>>();
public IEnumerable<Playfield> NestedPlayfields => nestedPlayfields.IsValueCreated ? nestedPlayfields.Value : Enumerable.Empty<Playfield>();
/// <summary>
/// A container for keeping track of DrawableHitObjects.
@ -48,7 +48,7 @@ namespace osu.Game.Rulesets.UI
/// <summary>
/// Performs post-processing tasks (if any) after all DrawableHitObjects are loaded into this Playfield.
/// </summary>
public virtual void PostProcess() => nestedPlayfields?.ForEach(p => p.PostProcess());
public virtual void PostProcess() => NestedPlayfields.ForEach(p => p.PostProcess());
/// <summary>
/// Adds a DrawableHitObject to this Playfield.
@ -67,13 +67,7 @@ namespace osu.Game.Rulesets.UI
/// This does not add the <see cref="Playfield"/> to the draw hierarchy.
/// </summary>
/// <param name="otherPlayfield">The <see cref="Playfield"/> to add.</param>
protected void AddNested(Playfield otherPlayfield)
{
if (nestedPlayfields == null)
nestedPlayfields = new List<Playfield>();
nestedPlayfields.Add(otherPlayfield);
}
protected void AddNested(Playfield otherPlayfield) => nestedPlayfields.Value.Add(otherPlayfield);
/// <summary>
/// Creates the container that will be used to contain the <see cref="DrawableHitObject"/>s.