1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 17:27:24 +08:00

Cache mods as array in DrawableRuleset

This commit is contained in:
smoogipoo 2019-04-10 17:11:17 +09:00
parent 85d3ff4846
commit 7845d542e3
2 changed files with 7 additions and 8 deletions

View File

@ -81,9 +81,8 @@ namespace osu.Game.Rulesets.UI
/// <summary>
/// The mods which are to be applied.
/// </summary>
[Cached]
[Cached(typeof(IBindable<IEnumerable<Mod>>))]
private readonly Bindable<IEnumerable<Mod>> mods = new Bindable<IEnumerable<Mod>>();
[Cached(typeof(IReadOnlyList<Mod>))]
private readonly IReadOnlyList<Mod> mods;
private FrameStabilityContainer frameStabilityContainer;
@ -100,7 +99,7 @@ namespace osu.Game.Rulesets.UI
if (workingBeatmap == null)
throw new ArgumentException("Beatmap cannot be null.", nameof(workingBeatmap));
this.mods.Value = mods;
this.mods = mods.ToArray();
RelativeSizeAxes = Axes.Both;
@ -160,7 +159,7 @@ namespace osu.Game.Rulesets.UI
.WithChild(ResumeOverlay)));
}
applyRulesetMods(mods.Value, config);
applyRulesetMods(mods, config);
loadObjects();
}
@ -175,7 +174,7 @@ namespace osu.Game.Rulesets.UI
Playfield.PostProcess();
foreach (var mod in mods.Value.OfType<IApplicableToDrawableHitObjects>())
foreach (var mod in mods.OfType<IApplicableToDrawableHitObjects>())
mod.ApplyToDrawableHitObjects(Playfield.HitObjectContainer.Objects);
}

View File

@ -61,7 +61,7 @@ namespace osu.Game.Rulesets.UI
private IBindable<WorkingBeatmap> beatmap { get; set; }
[Resolved]
private IBindable<IEnumerable<Mod>> mods { get; set; }
private IReadOnlyList<Mod> mods { get; set; }
[BackgroundDependencyLoader]
private void load()
@ -125,7 +125,7 @@ namespace osu.Game.Rulesets.UI
base.Update();
if (beatmap != null)
foreach (var mod in mods.Value)
foreach (var mod in mods)
if (mod is IUpdatableByPlayfield updatable)
updatable.Update(this);
}