From b68b301b712a0047a7d6f24aa2fb776e19f8086d Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 5 Mar 2022 15:38:05 -0500 Subject: add DoesAssetExist to support the upcoming Stardew Valley 1.6 (#766) --- src/SMAPI/Framework/ContentCoordinator.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/SMAPI/Framework/ContentCoordinator.cs') diff --git a/src/SMAPI/Framework/ContentCoordinator.cs b/src/SMAPI/Framework/ContentCoordinator.cs index b255dae1..fbbbe2d2 100644 --- a/src/SMAPI/Framework/ContentCoordinator.cs +++ b/src/SMAPI/Framework/ContentCoordinator.cs @@ -296,6 +296,22 @@ namespace StardewModdingAPI.Framework return Path.Combine(this.ManagedPrefix, modID.ToLower()); } + /// Get whether an asset from a mod folder exists. + /// The unique name for the content manager which should load this asset. + /// The asset name within the mod folder. + public bool DoesManagedAssetExist(string contentManagerID, IAssetName assetName) + { + // get content manager + IContentManager contentManager = this.ContentManagerLock.InReadLock(() => + this.ContentManagers.FirstOrDefault(p => p.IsNamespaced && p.Name == contentManagerID) + ); + if (contentManager == null) + throw new InvalidOperationException($"The '{contentManagerID}' prefix isn't handled by any mod."); + + // get whether the asset exists + return contentManager.DoesAssetExist(assetName); + } + /// Get a copy of an asset from a mod folder. /// The asset type. /// The unique name for the content manager which should load this asset. -- cgit