diff options
Diffstat (limited to 'src/SMAPI/Framework')
-rw-r--r-- | src/SMAPI/Framework/Content/AssetInterceptorChange.cs | 6 | ||||
-rw-r--r-- | src/SMAPI/Framework/SGame.cs | 20 |
2 files changed, 18 insertions, 8 deletions
diff --git a/src/SMAPI/Framework/Content/AssetInterceptorChange.cs b/src/SMAPI/Framework/Content/AssetInterceptorChange.cs index 498afe36..037d9f89 100644 --- a/src/SMAPI/Framework/Content/AssetInterceptorChange.cs +++ b/src/SMAPI/Framework/Content/AssetInterceptorChange.cs @@ -64,7 +64,8 @@ namespace StardewModdingAPI.Framework.Content { try { - return editor.CanEdit<TAsset>(asset); + if (editor.CanEdit<TAsset>(asset)) + return true; } catch (Exception ex) { @@ -77,7 +78,8 @@ namespace StardewModdingAPI.Framework.Content { try { - return loader.CanLoad<TAsset>(asset); + if (loader.CanLoad<TAsset>(asset)) + return true; } catch (Exception ex) { diff --git a/src/SMAPI/Framework/SGame.cs b/src/SMAPI/Framework/SGame.cs index e2b22ba7..d6c3b836 100644 --- a/src/SMAPI/Framework/SGame.cs +++ b/src/SMAPI/Framework/SGame.cs @@ -18,6 +18,7 @@ using StardewModdingAPI.Framework.Events; using StardewModdingAPI.Framework.Input; using StardewModdingAPI.Framework.Networking; using StardewModdingAPI.Framework.Reflection; +using StardewModdingAPI.Framework.StateTracking.Comparers; using StardewModdingAPI.Framework.StateTracking.Snapshots; using StardewModdingAPI.Framework.Utilities; using StardewModdingAPI.Toolkit.Serialization; @@ -427,17 +428,24 @@ namespace StardewModdingAPI.Framework return; } - /********* ** Reload assets when interceptors are added/removed *********/ if (this.ReloadAssetInterceptorsQueue.Any()) { - this.Monitor.Log("Invalidating cached assets for new editors & loaders...", LogLevel.Trace); + // get unique interceptors + AssetInterceptorChange[] interceptors = this.ReloadAssetInterceptorsQueue + .GroupBy(p => p.Instance, new ObjectReferenceComparer<object>()) + .Select(p => p.First()) + .ToArray(); + this.ReloadAssetInterceptorsQueue.Clear(); + + // log summary + this.Monitor.Log("Invalidating cached assets for new editors & loaders..."); this.Monitor.Log( - "changed: " + " changed: " + string.Join(", ", - this.ReloadAssetInterceptorsQueue + interceptors .GroupBy(p => p.Mod) .OrderBy(p => p.Key.DisplayName) .Select(modGroup => @@ -448,8 +456,8 @@ namespace StardewModdingAPI.Framework ) ); - this.ContentCore.InvalidateCache(asset => this.ReloadAssetInterceptorsQueue.Any(p => p.CanIntercept(asset))); - this.ReloadAssetInterceptorsQueue.Clear(); + // reload affected assets + this.ContentCore.InvalidateCache(asset => interceptors.Any(p => p.CanIntercept(asset))); } /********* |