From a42926868ae5878ed59d6406ca085b587299ba07 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 20 Mar 2022 12:53:27 -0400 Subject: encapsulate editor/loader operations (#766) These will be used by the new content API, and allow handling the old one the same way. --- src/SMAPI/Framework/Content/AssetEditOperation.cs | 30 +++++++++++++++++++++++ src/SMAPI/Framework/Content/AssetLoadOperation.cs | 30 +++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 src/SMAPI/Framework/Content/AssetEditOperation.cs create mode 100644 src/SMAPI/Framework/Content/AssetLoadOperation.cs (limited to 'src/SMAPI/Framework/Content') 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 +{ + /// An edit to apply to an asset when it's requested from the content pipeline. + internal class AssetEditOperation + { + /********* + ** Accessors + *********/ + /// The mod applying the edit. + public IModMetadata Mod { get; } + + /// Apply the edit to an asset. + public Action ApplyEdit { get; } + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The mod applying the edit. + /// Apply the edit to an asset. + public AssetEditOperation(IModMetadata mod, Action 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 +{ + /// An operation which provides the initial instance of an asset when it's requested from the content pipeline. + internal class AssetLoadOperation + { + /********* + ** Accessors + *********/ + /// The mod applying the edit. + public IModMetadata Mod { get; } + + /// Load the initial value for an asset. + public Func GetData { get; } + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The mod applying the edit. + /// Load the initial value for an asset. + public AssetLoadOperation(IModMetadata mod, Func getData) + { + this.Mod = mod; + this.GetData = getData; + } + } +} -- cgit