// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. #nullable disable using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Game.Beatmaps; using osu.Game.Rulesets; using osu.Game.Rulesets.Mods; namespace osu.Game.Screens { public class OsuScreenDependencies : DependencyContainer { public Bindable Beatmap { get; } public Bindable Ruleset { get; } public Bindable> Mods { get; } public OsuScreenDependencies(bool requireLease, IReadOnlyDependencyContainer parent) : base(parent) { if (requireLease) { Beatmap = parent.Get>()?.GetBoundCopy(); if (Beatmap == null) { Cache(Beatmap = parent.Get>().BeginLease(false)); CacheAs(Beatmap); } Ruleset = parent.Get>()?.GetBoundCopy(); if (Ruleset == null) { Cache(Ruleset = parent.Get>().BeginLease(true)); CacheAs(Ruleset); } Mods = parent.Get>>()?.GetBoundCopy(); if (Mods == null) { Cache(Mods = parent.Get>>().BeginLease(true)); CacheAs(Mods); } } else { Beatmap = (parent.Get>() ?? parent.Get>()).GetBoundCopy(); Ruleset = (parent.Get>() ?? parent.Get>()).GetBoundCopy(); Mods = (parent.Get>>() ?? parent.Get>>()).GetBoundCopy(); } } } }