fix ReplaceWith not working for legacy IAssetEditor implementations

This commit is contained in:
Jesse Plamondon-Willard 2022-04-23 16:47:24 -04:00
parent 4fa414c2bd
commit 4a14792e4d
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
2 changed files with 8 additions and 5 deletions

View File

@ -25,8 +25,9 @@ namespace StardewModdingAPI.Framework.Content
/// <param name="data">The content data being read.</param>
/// <param name="getNormalizedPath">Normalizes an asset key to match the cache key.</param>
/// <param name="reflection">Simplifies access to private code.</param>
public AssetDataForObject(string? locale, IAssetName assetName, object data, Func<string, string> getNormalizedPath, Reflector reflection)
: base(locale, assetName, data, getNormalizedPath, onDataReplaced: null)
/// <param name="onDataReplaced">A callback to invoke when the data is replaced (if any).</param>
public AssetDataForObject(string? locale, IAssetName assetName, object data, Func<string, string> getNormalizedPath, Reflector reflection, Action<object>? onDataReplaced = null)
: base(locale, assetName, data, getNormalizedPath, onDataReplaced)
{
this.Reflection = reflection;
}
@ -36,8 +37,9 @@ namespace StardewModdingAPI.Framework.Content
/// <param name="data">The content data being read.</param>
/// <param name="getNormalizedPath">Normalizes an asset key to match the cache key.</param>
/// <param name="reflection">Simplifies access to private code.</param>
public AssetDataForObject(IAssetInfo info, object data, Func<string, string> getNormalizedPath, Reflector reflection)
: this(info.Locale, info.Name, data, getNormalizedPath, reflection) { }
/// <param name="onDataReplaced">A callback to invoke when the data is replaced (if any).</param>
public AssetDataForObject(IAssetInfo info, object data, Func<string, string> getNormalizedPath, Reflector reflection, Action<object>? onDataReplaced = null)
: this(info.Locale, info.Name, data, getNormalizedPath, reflection, onDataReplaced) { }
/// <inheritdoc />
public IAssetDataForDictionary<TKey, TValue> AsDictionary<TKey, TValue>()

View File

@ -716,7 +716,8 @@ namespace StardewModdingAPI.Framework
assetName: legacyName,
data: asset.Data,
getNormalizedPath: this.MainContentManager.AssertAndNormalizeAssetName,
reflection: this.Reflection
reflection: this.Reflection,
onDataReplaced: asset.ReplaceWith
);
}