diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-10-09 17:39:11 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-10-09 17:39:11 -0400 |
commit | 037d7e357b169936fa858f6c8b9c1388ca75840b (patch) | |
tree | c197acab05a908d2ce36d35e981866715020644c /src/SMAPI/Framework/InternalExtensions.cs | |
parent | 9a15da5a173e5e218c16e2e4ef0af0c98968e1cb (diff) | |
download | SMAPI-037d7e357b169936fa858f6c8b9c1388ca75840b.tar.gz SMAPI-037d7e357b169936fa858f6c8b9c1388ca75840b.tar.bz2 SMAPI-037d7e357b169936fa858f6c8b9c1388ca75840b.zip |
set texture name earlier to support mods like SpriteMaster
Diffstat (limited to 'src/SMAPI/Framework/InternalExtensions.cs')
-rw-r--r-- | src/SMAPI/Framework/InternalExtensions.cs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/SMAPI/Framework/InternalExtensions.cs b/src/SMAPI/Framework/InternalExtensions.cs index ba9bbcec..7ad30d35 100644 --- a/src/SMAPI/Framework/InternalExtensions.cs +++ b/src/SMAPI/Framework/InternalExtensions.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Threading; using Microsoft.Xna.Framework.Graphics; @@ -163,5 +164,34 @@ namespace StardewModdingAPI.Framework { return reflection.GetField<bool>(spriteBatch, "_beginCalled").GetValue(); } + + /**** + ** Texture2D + ****/ + /// <summary>Set the texture name field.</summary> + /// <param name="texture">The texture whose name to set.</param> + /// <param name="assetName">The asset name to set.</param> + /// <returns>Returns the texture for chaining.</returns> + [return: NotNullIfNotNull("texture")] + public static Texture2D? SetName(this Texture2D? texture, IAssetName assetName) + { + if (texture != null) + texture.Name = assetName.Name; + + return texture; + } + + /// <summary>Set the texture name field.</summary> + /// <param name="texture">The texture whose name to set.</param> + /// <param name="assetName">The asset name to set.</param> + /// <returns>Returns the texture for chaining.</returns> + [return: NotNullIfNotNull("texture")] + public static Texture2D? SetName(this Texture2D? texture, string assetName) + { + if (texture != null) + texture.Name = assetName; + + return texture; + } } } |