diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2020-04-24 17:53:58 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2020-04-24 17:53:58 -0400 |
commit | beccea7efdd61d6417217eb3f40ca452373ac3d6 (patch) | |
tree | 9f097512f1d318be263c3843332b5c419c13d662 /src/SMAPI/Framework/ModHelpers/ContentHelper.cs | |
parent | 4fae0158edd2f809b145ccacf20f082c06cd4a3e (diff) | |
download | SMAPI-beccea7efdd61d6417217eb3f40ca452373ac3d6.tar.gz SMAPI-beccea7efdd61d6417217eb3f40ca452373ac3d6.tar.bz2 SMAPI-beccea7efdd61d6417217eb3f40ca452373ac3d6.zip |
add support for getting a patch helper for arbitrary data
Diffstat (limited to 'src/SMAPI/Framework/ModHelpers/ContentHelper.cs')
-rw-r--r-- | src/SMAPI/Framework/ModHelpers/ContentHelper.cs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/SMAPI/Framework/ModHelpers/ContentHelper.cs b/src/SMAPI/Framework/ModHelpers/ContentHelper.cs index e9b70845..23e45fd1 100644 --- a/src/SMAPI/Framework/ModHelpers/ContentHelper.cs +++ b/src/SMAPI/Framework/ModHelpers/ContentHelper.cs @@ -7,6 +7,7 @@ using System.IO; using System.Linq; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; +using StardewModdingAPI.Framework.Content; using StardewModdingAPI.Framework.ContentManagers; using StardewModdingAPI.Framework.Exceptions; using StardewValley; @@ -164,6 +165,19 @@ namespace StardewModdingAPI.Framework.ModHelpers return this.ContentCore.InvalidateCache(predicate).Any(); } + /// <summary>Get a patch helper for arbitrary data.</summary> + /// <typeparam name="T">The data type.</typeparam> + /// <param name="data">The asset data.</param> + /// <param name="assetName">The asset name. This is only used for tracking purposes and has no effect on the patch helper.</param> + public IAssetData GetPatchHelper<T>(T data, string assetName = null) + { + if (data == null) + throw new ArgumentNullException(nameof(data), "Can't get a patch helper for a null value."); + + assetName ??= $"temp/{Guid.NewGuid():N}"; + return new AssetDataForObject(this.CurrentLocale, assetName, data, this.NormalizeAssetName); + } + /********* ** Private methods |