remove reflection no longer needed after migration to MonoGame

This commit is contained in:
Jesse Plamondon-Willard 2022-04-13 22:19:45 -04:00
parent 3078ae2a8e
commit ff1b4cd323
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
2 changed files with 5 additions and 8 deletions

View File

@ -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
****/
/// <summary>Construct an instance.</summary>
/// <param name="contentManager">The underlying content manager whose cache to manage.</param>
/// <param name="reflection">Simplifies access to private game code.</param>
public ContentCache(LocalizedContentManager contentManager, Reflector reflection)
/// <param name="loadedAssets">The asset cache for the underlying content manager.</param>
public ContentCache(Dictionary<string, object> loadedAssets)
{
this.Cache = reflection.GetField<Dictionary<string, object>>(contentManager, "loadedAssets").GetValue()
?? throw new InvalidOperationException("Can't initialize content cache: required field 'loadedAssets' is missing.");
this.Cache = loadedAssets;
}
/****

View File

@ -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;