diff --git a/src/SMAPI/Framework/Content/ContentCache.cs b/src/SMAPI/Framework/Content/ContentCache.cs index d8862eb3..cbb6c1e9 100644 --- a/src/SMAPI/Framework/Content/ContentCache.cs +++ b/src/SMAPI/Framework/Content/ContentCache.cs @@ -3,9 +3,7 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Diagnostics.Contracts; using System.Linq; -using StardewModdingAPI.Framework.Reflection; using StardewModdingAPI.Toolkit.Utilities; -using StardewValley; namespace StardewModdingAPI.Framework.Content { @@ -41,12 +39,10 @@ namespace StardewModdingAPI.Framework.Content ** Constructor ****/ /// Construct an instance. - /// The underlying content manager whose cache to manage. - /// Simplifies access to private game code. - public ContentCache(LocalizedContentManager contentManager, Reflector reflection) + /// The asset cache for the underlying content manager. + public ContentCache(Dictionary loadedAssets) { - this.Cache = reflection.GetField>(contentManager, "loadedAssets").GetValue() - ?? throw new InvalidOperationException("Can't initialize content cache: required field 'loadedAssets' is missing."); + this.Cache = loadedAssets; } /**** diff --git a/src/SMAPI/Framework/ContentManagers/BaseContentManager.cs b/src/SMAPI/Framework/ContentManagers/BaseContentManager.cs index 5ae5313d..613df023 100644 --- a/src/SMAPI/Framework/ContentManagers/BaseContentManager.cs +++ b/src/SMAPI/Framework/ContentManagers/BaseContentManager.cs @@ -89,7 +89,8 @@ namespace StardewModdingAPI.Framework.ContentManagers // init this.Name = name; this.Coordinator = coordinator ?? throw new ArgumentNullException(nameof(coordinator)); - this.Cache = new ContentCache(this, reflection); + // ReSharper disable once VirtualMemberCallInConstructor -- LoadedAssets isn't overridden by SMAPI or Stardew Valley + this.Cache = new ContentCache(this.LoadedAssets); this.Monitor = monitor ?? throw new ArgumentNullException(nameof(monitor)); this.Reflection = reflection; this.OnDisposing = onDisposing;