/// <summary>Tries to load a texture given the <see cref="IContentSource"/>, the path to the texture, the list of source names for it, and the good type.</summary> private static bool TryLoadTextureProvider(IContentSource contentSource, string imagePath, List <string> source, ArtisanGood good, IMonitor monitor, out ArtisanGoodTextureProvider provider) { provider = null; if (imagePath == null) { return(false); } IManifest manifest = contentSource.GetManifest(); if (source == null || source.Count == 0 || source.Any(item => item == null)) { monitor.Log($"Couldn't load {good} from {manifest.Name} ({manifest.UniqueID}) because it has an invalid source list ({artisanGoodToSourceType[good]}).", LogLevel.Warn); monitor.Log($"{artisanGoodToSourceType[good]} must not be null, must not be empty, and cannot have null items inside it.", LogLevel.Warn); } else { try { provider = new ArtisanGoodTextureProvider(contentSource.Load <Texture2D>(imagePath), source, good); return(true); } catch (Exception) { monitor.Log($"Couldn't load {good} from {manifest.Name} ({manifest.UniqueID}) because the {good} texture file path is invalid ({imagePath}).", LogLevel.Warn); } } return(false); }
private static bool TryLoadTextureProvider(IContentSource contentSource, string?imagePath, List <string>?source, object good, IMonitor monitor, out object?provider) { provider = null; if (string.IsNullOrEmpty(imagePath)) { return(false); } var manifest = contentSource.GetManifest(); if (source is null || source.Count == 0 || source.Any(string.IsNullOrEmpty)) { monitor.Log($"Couldn't load Mead from {manifest.Name} ({manifest.UniqueID}) because it has an invalid source list (Flowers).", LogLevel.Warn); monitor.Log("Flowers must not be null, must not be empty, and cannot have null items inside it.", LogLevel.Warn); }