mirror of
https://github.com/ppy/osu.git
synced 2025-03-04 06:12:57 +08:00
Don't create nested hitobjects unless absolutely required
This commit is contained in:
parent
7765a1aa3a
commit
c67f372560
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
@ -56,10 +57,10 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public HitWindows HitWindows { get; set; }
|
public HitWindows HitWindows { get; set; }
|
||||||
|
|
||||||
private readonly SortedList<HitObject> nestedHitObjects = new SortedList<HitObject>((h1, h2) => h1.StartTime.CompareTo(h2.StartTime));
|
private readonly Lazy<SortedList<HitObject>> nestedHitObjects = new Lazy<SortedList<HitObject>>(() => new SortedList<HitObject>((h1, h2) => h1.StartTime.CompareTo(h2.StartTime)));
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public IReadOnlyList<HitObject> NestedHitObjects => nestedHitObjects;
|
public IReadOnlyList<HitObject> NestedHitObjects => nestedHitObjects.Value;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Applies default values to this HitObject.
|
/// Applies default values to this HitObject.
|
||||||
@ -70,14 +71,20 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
{
|
{
|
||||||
ApplyDefaultsToSelf(controlPointInfo, difficulty);
|
ApplyDefaultsToSelf(controlPointInfo, difficulty);
|
||||||
|
|
||||||
nestedHitObjects.Clear();
|
if (nestedHitObjects.IsValueCreated)
|
||||||
|
nestedHitObjects.Value.Clear();
|
||||||
|
|
||||||
CreateNestedHitObjects();
|
CreateNestedHitObjects();
|
||||||
nestedHitObjects.ForEach(h =>
|
|
||||||
|
if (nestedHitObjects.IsValueCreated)
|
||||||
|
{
|
||||||
|
nestedHitObjects.Value.ForEach(h =>
|
||||||
{
|
{
|
||||||
h.HitWindows = HitWindows;
|
h.HitWindows = HitWindows;
|
||||||
h.ApplyDefaults(controlPointInfo, difficulty);
|
h.ApplyDefaults(controlPointInfo, difficulty);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected virtual void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
protected virtual void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||||
{
|
{
|
||||||
@ -96,7 +103,7 @@ namespace osu.Game.Rulesets.Objects
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void AddNested(HitObject hitObject) => nestedHitObjects.Add(hitObject);
|
protected void AddNested(HitObject hitObject) => nestedHitObjects.Value.Add(hitObject);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates the <see cref="HitWindows"/> for this <see cref="HitObject"/>.
|
/// Creates the <see cref="HitWindows"/> for this <see cref="HitObject"/>.
|
||||||
|
Loading…
Reference in New Issue
Block a user