summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/ContentCoordinator.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-03-05 15:38:05 -0500
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-03-05 15:38:05 -0500
commitb68b301b712a0047a7d6f24aa2fb776e19f8086d (patch)
treea127aa3cf95d682cd83dbc7ca8fb109181a0744e /src/SMAPI/Framework/ContentCoordinator.cs
parentb0d8b23c2c53ea3aafd60b0597a7562ac1708a42 (diff)
downloadSMAPI-b68b301b712a0047a7d6f24aa2fb776e19f8086d.tar.gz
SMAPI-b68b301b712a0047a7d6f24aa2fb776e19f8086d.tar.bz2
SMAPI-b68b301b712a0047a7d6f24aa2fb776e19f8086d.zip
add DoesAssetExist to support the upcoming Stardew Valley 1.6 (#766)
Diffstat (limited to 'src/SMAPI/Framework/ContentCoordinator.cs')
-rw-r--r--src/SMAPI/Framework/ContentCoordinator.cs16
1 files changed, 16 insertions, 0 deletions
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());
}
+ /// <summary>Get whether an asset from a mod folder exists.</summary>
+ /// <param name="contentManagerID">The unique name for the content manager which should load this asset.</param>
+ /// <param name="assetName">The asset name within the mod folder.</param>
+ 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);
+ }
+
/// <summary>Get a copy of an asset from a mod folder.</summary>
/// <typeparam name="T">The asset type.</typeparam>
/// <param name="contentManagerID">The unique name for the content manager which should load this asset.</param>