diff --git a/src/SMAPI/Metadata/CoreAssetPropagator.cs b/src/SMAPI/Metadata/CoreAssetPropagator.cs
index 277da525..38b205a5 100644
--- a/src/SMAPI/Metadata/CoreAssetPropagator.cs
+++ b/src/SMAPI/Metadata/CoreAssetPropagator.cs
@@ -326,19 +326,19 @@ namespace StardewModdingAPI.Metadata
}
// dynamic textures
- if (key.StartsWith(this.GetNormalisedPath("Buildings\\"), StringComparison.InvariantCultureIgnoreCase))
+ if (this.IsInFolder(key, "Buildings"))
return this.ReloadBuildings(content, key);
- if (key.StartsWith(this.GetNormalisedPath("Characters\\")) && this.CountSegments(key) == 2) // ignore Characters/Dialogue/*, etc
+ if (this.IsInFolder(key, "Characters"))
return this.ReloadNpcSprites(content, key, monster: false);
- if (key.StartsWith(this.GetNormalisedPath("Characters\\Monsters\\")))
+ if (this.IsInFolder(key, "Characters\\Monsters"))
return this.ReloadNpcSprites(content, key, monster: true);
- if (key.StartsWith(this.GetNormalisedPath("LooseSprites\\Fence")))
+ if (key.StartsWith(this.GetNormalisedPath("LooseSprites\\Fence"), StringComparison.InvariantCultureIgnoreCase))
return this.ReloadFenceTextures(content, key);
- if (key.StartsWith(this.GetNormalisedPath("Portraits\\")))
+ if (this.IsInFolder(key, "Portraits"))
return this.ReloadNpcPortraits(content, key);
return false;
@@ -348,6 +348,9 @@ namespace StardewModdingAPI.Metadata
/*********
** Private methods
*********/
+ /****
+ ** Reload methods
+ ****/
/// Reload building textures.
/// The content manager through which to reload the asset.
/// The asset key to reload.
@@ -491,6 +494,9 @@ namespace StardewModdingAPI.Metadata
return false;
}
+ /****
+ ** Helpers
+ ****/
/// Get an NPC name from the name of their file under Content/Characters.
/// The file name.
/// Derived from .
@@ -527,6 +533,17 @@ namespace StardewModdingAPI.Metadata
}
}
+ /// Get whether a normalised asset key is in the given folder.
+ /// The normalised asset key (like Animals/cat).
+ /// The key folder (like Animals); doesn't need to be normalised.
+ /// Whether to return true if the key is inside a subfolder of the .
+ private bool IsInFolder(string key, string folder, bool allowSubfolders = false)
+ {
+ return
+ key.StartsWith(this.GetNormalisedPath($"{folder}\\"), StringComparison.InvariantCultureIgnoreCase)
+ && (allowSubfolders || this.CountSegments(key) == this.CountSegments(folder) + 1);
+ }
+
/// Get the segments in a path (e.g. 'a/b' is 'a' and 'b').
/// The path to check.
private string[] GetSegments(string path)