| | 1 | | using DCL; |
| | 2 | | using MainScripts.DCL.Helpers.Utils; |
| | 3 | | using System.Collections.Generic; |
| | 4 | |
|
| | 5 | | namespace MainScripts.DCL.Controllers.AssetManager |
| | 6 | | { |
| | 7 | | public abstract class AssetResolverBase |
| | 8 | | { |
| 1 | 9 | | protected static readonly AssetSource[] SOURCES = EnumUtils.Values<AssetSource>(); |
| | 10 | |
|
| 175 | 11 | | protected DataStore_FeatureFlag featureFlags { get; } |
| | 12 | |
|
| 2223 | 13 | | protected AssetResolverBase(DataStore_FeatureFlag featureFlags) |
| | 14 | | { |
| 2223 | 15 | | this.featureFlags = featureFlags; |
| 2223 | 16 | | } |
| | 17 | |
|
| | 18 | | protected static bool HasFlag(AssetSource permittedSources, AssetSource source) => |
| 900 | 19 | | EnumUtils.HasFlag(permittedSources, source); |
| | 20 | |
|
| | 21 | | protected static PoolUtils.ListPoolRent<T> GetPermittedProviders<T>(IReadOnlyDictionary<AssetSource, T> provider |
| | 22 | | { |
| 180 | 23 | | var listPoolRent = PoolUtils.RentList<T>(); |
| 180 | 24 | | var permittedProviders = listPoolRent.GetList(); |
| | 25 | |
|
| 2160 | 26 | | foreach (AssetSource assetSource in SOURCES) |
| | 27 | | { |
| 900 | 28 | | if (!HasFlag(permittedSources, assetSource)) |
| | 29 | | continue; |
| | 30 | |
|
| 484 | 31 | | if (!providers.TryGetValue(assetSource, out var provider)) |
| | 32 | | continue; |
| | 33 | |
|
| 191 | 34 | | permittedProviders.Add(provider); |
| | 35 | | } |
| | 36 | |
|
| 180 | 37 | | return listPoolRent; |
| | 38 | | } |
| | 39 | | } |
| | 40 | | } |