handle vanilla assets in DoesAssetExist (#766)

This commit is contained in:
Jesse Plamondon-Willard 2022-03-05 18:12:00 -05:00
parent b68b301b71
commit debe177241
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
1 changed files with 5 additions and 1 deletions

View File

@ -68,11 +68,15 @@ namespace StardewModdingAPI.Framework.ContentManagers
if (base.DoesAssetExist(assetName)) if (base.DoesAssetExist(assetName))
return true; return true;
// vanilla asset
if (File.Exists(Path.Combine(this.RootDirectory, $"{assetName.Name}.xnb")))
return true;
// managed asset // managed asset
if (this.Coordinator.TryParseManagedAssetKey(assetName.Name, out string contentManagerID, out IAssetName relativePath)) if (this.Coordinator.TryParseManagedAssetKey(assetName.Name, out string contentManagerID, out IAssetName relativePath))
return this.Coordinator.DoesManagedAssetExist(contentManagerID, relativePath); return this.Coordinator.DoesManagedAssetExist(contentManagerID, relativePath);
// else check for loaders // custom asset from a loader
string locale = this.GetLocale(); string locale = this.GetLocale();
IAssetInfo info = new AssetInfo(locale, assetName, typeof(object), this.AssertAndNormalizeAssetName); IAssetInfo info = new AssetInfo(locale, assetName, typeof(object), this.AssertAndNormalizeAssetName);
ModLinked<IAssetLoader>[] loaders = this.GetLoaders<object>(info).ToArray(); ModLinked<IAssetLoader>[] loaders = this.GetLoaders<object>(info).ToArray();