summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/Content
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-03-20 12:53:27 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-03-20 12:53:27 -0400
commita42926868ae5878ed59d6406ca085b587299ba07 (patch)
treeff351e5c4cec39a1294795fb52a518656479e451 /src/SMAPI/Framework/Content
parentd96cec88e461806c4676c9280455da19f5c7af24 (diff)
downloadSMAPI-a42926868ae5878ed59d6406ca085b587299ba07.tar.gz
SMAPI-a42926868ae5878ed59d6406ca085b587299ba07.tar.bz2
SMAPI-a42926868ae5878ed59d6406ca085b587299ba07.zip
encapsulate editor/loader operations (#766)
These will be used by the new content API, and allow handling the old one the same way.
Diffstat (limited to 'src/SMAPI/Framework/Content')
-rw-r--r--src/SMAPI/Framework/Content/AssetEditOperation.cs30
-rw-r--r--src/SMAPI/Framework/Content/AssetLoadOperation.cs30
2 files changed, 60 insertions, 0 deletions
diff --git a/src/SMAPI/Framework/Content/AssetEditOperation.cs b/src/SMAPI/Framework/Content/AssetEditOperation.cs
new file mode 100644
index 00000000..fa189d44
--- /dev/null
+++ b/src/SMAPI/Framework/Content/AssetEditOperation.cs
@@ -0,0 +1,30 @@
+using System;
+
+namespace StardewModdingAPI.Framework.Content
+{
+ /// <summary>An edit to apply to an asset when it's requested from the content pipeline.</summary>
+ internal class AssetEditOperation
+ {
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>The mod applying the edit.</summary>
+ public IModMetadata Mod { get; }
+
+ /// <summary>Apply the edit to an asset.</summary>
+ public Action<IAssetData> ApplyEdit { get; }
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ /// <param name="mod">The mod applying the edit.</param>
+ /// <param name="applyEdit">Apply the edit to an asset.</param>
+ public AssetEditOperation(IModMetadata mod, Action<IAssetData> applyEdit)
+ {
+ this.Mod = mod;
+ this.ApplyEdit = applyEdit;
+ }
+ }
+}
diff --git a/src/SMAPI/Framework/Content/AssetLoadOperation.cs b/src/SMAPI/Framework/Content/AssetLoadOperation.cs
new file mode 100644
index 00000000..d773cadd
--- /dev/null
+++ b/src/SMAPI/Framework/Content/AssetLoadOperation.cs
@@ -0,0 +1,30 @@
+using System;
+
+namespace StardewModdingAPI.Framework.Content
+{
+ /// <summary>An operation which provides the initial instance of an asset when it's requested from the content pipeline.</summary>
+ internal class AssetLoadOperation
+ {
+ /*********
+ ** Accessors
+ *********/
+ /// <summary>The mod applying the edit.</summary>
+ public IModMetadata Mod { get; }
+
+ /// <summary>Load the initial value for an asset.</summary>
+ public Func<IAssetInfo, object> GetData { get; }
+
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ /// <param name="mod">The mod applying the edit.</param>
+ /// <param name="getData">Load the initial value for an asset.</param>
+ public AssetLoadOperation(IModMetadata mod, Func<IAssetInfo, object> getData)
+ {
+ this.Mod = mod;
+ this.GetData = getData;
+ }
+ }
+}