1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 00:53:21 +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> /// <summary>
/// The mods which are to be applied. /// The mods which are to be applied.
/// </summary> /// </summary>
[Cached] [Cached(typeof(IReadOnlyList<Mod>))]
[Cached(typeof(IBindable<IEnumerable<Mod>>))] private readonly IReadOnlyList<Mod> mods;
private readonly Bindable<IEnumerable<Mod>> mods = new Bindable<IEnumerable<Mod>>();
private FrameStabilityContainer frameStabilityContainer; private FrameStabilityContainer frameStabilityContainer;
@ -100,7 +99,7 @@ namespace osu.Game.Rulesets.UI
if (workingBeatmap == null) if (workingBeatmap == null)
throw new ArgumentException("Beatmap cannot be null.", nameof(workingBeatmap)); throw new ArgumentException("Beatmap cannot be null.", nameof(workingBeatmap));
this.mods.Value = mods; this.mods = mods.ToArray();
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
@ -160,7 +159,7 @@ namespace osu.Game.Rulesets.UI
.WithChild(ResumeOverlay))); .WithChild(ResumeOverlay)));
} }
applyRulesetMods(mods.Value, config); applyRulesetMods(mods, config);
loadObjects(); loadObjects();
} }
@ -175,7 +174,7 @@ namespace osu.Game.Rulesets.UI
Playfield.PostProcess(); Playfield.PostProcess();
foreach (var mod in mods.Value.OfType<IApplicableToDrawableHitObjects>()) foreach (var mod in mods.OfType<IApplicableToDrawableHitObjects>())
mod.ApplyToDrawableHitObjects(Playfield.HitObjectContainer.Objects); mod.ApplyToDrawableHitObjects(Playfield.HitObjectContainer.Objects);
} }

View File

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