diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-03-05 15:38:05 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-03-05 15:38:05 -0500 |
commit | b68b301b712a0047a7d6f24aa2fb776e19f8086d (patch) | |
tree | a127aa3cf95d682cd83dbc7ca8fb109181a0744e /src/SMAPI/Framework/ContentCoordinator.cs | |
parent | b0d8b23c2c53ea3aafd60b0597a7562ac1708a42 (diff) | |
download | SMAPI-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.cs | 16 |
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> |