summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI/Framework')
-rw-r--r--src/SMAPI/Framework/Content/AssetEditOperation.cs39
-rw-r--r--src/SMAPI/Framework/Content/AssetLoadOperation.cs39
-rw-r--r--src/SMAPI/Framework/Content/AssetOperationGroup.cs33
-rw-r--r--src/SMAPI/Framework/ContentCoordinator.cs28
4 files changed, 28 insertions, 111 deletions
diff --git a/src/SMAPI/Framework/Content/AssetEditOperation.cs b/src/SMAPI/Framework/Content/AssetEditOperation.cs
index 464948b0..11b8811b 100644
--- a/src/SMAPI/Framework/Content/AssetEditOperation.cs
+++ b/src/SMAPI/Framework/Content/AssetEditOperation.cs
@@ -4,38 +4,9 @@ using StardewModdingAPI.Events;
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>If there are multiple edits that apply to the same asset, the priority with which this one should be applied.</summary>
- public AssetEditPriority Priority { get; }
-
- /// <summary>The content pack on whose behalf the edit is being applied, if any.</summary>
- public IModMetadata? OnBehalfOf { 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="priority">If there are multiple edits that apply to the same asset, the priority with which this one should be applied.</param>
- /// <param name="onBehalfOf">The content pack on whose behalf the edit is being applied, if any.</param>
- /// <param name="applyEdit">Apply the edit to an asset.</param>
- public AssetEditOperation(IModMetadata mod, AssetEditPriority priority, IModMetadata? onBehalfOf, Action<IAssetData> applyEdit)
- {
- this.Mod = mod;
- this.Priority = priority;
- this.OnBehalfOf = onBehalfOf;
- this.ApplyEdit = applyEdit;
- }
- }
+ /// <param name="Mod">The mod applying the edit.</param>
+ /// <param name="Priority">If there are multiple edits that apply to the same asset, the priority with which this one should be applied.</param>
+ /// <param name="OnBehalfOf">The content pack on whose behalf the edit is being applied, if any.</param>
+ /// <param name="ApplyEdit">Apply the edit to an asset.</param>
+ internal record AssetEditOperation(IModMetadata Mod, AssetEditPriority Priority, IModMetadata? OnBehalfOf, Action<IAssetData> ApplyEdit);
}
diff --git a/src/SMAPI/Framework/Content/AssetLoadOperation.cs b/src/SMAPI/Framework/Content/AssetLoadOperation.cs
index b6cdec27..7af07dfd 100644
--- a/src/SMAPI/Framework/Content/AssetLoadOperation.cs
+++ b/src/SMAPI/Framework/Content/AssetLoadOperation.cs
@@ -4,38 +4,9 @@ using StardewModdingAPI.Events;
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 loading the asset.</summary>
- public IModMetadata Mod { get; }
-
- /// <summary>The content pack on whose behalf the asset is being loaded, if any.</summary>
- public IModMetadata? OnBehalfOf { get; }
-
- /// <summary>If there are multiple loads that apply to the same asset, the priority with which this one should be applied.</summary>
- public AssetLoadPriority Priority { 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="priority">If there are multiple loads that apply to the same asset, the priority with which this one should be applied.</param>
- /// <param name="onBehalfOf">The content pack on whose behalf the asset is being loaded, if any.</param>
- /// <param name="getData">Load the initial value for an asset.</param>
- public AssetLoadOperation(IModMetadata mod, AssetLoadPriority priority, IModMetadata? onBehalfOf, Func<IAssetInfo, object> getData)
- {
- this.Mod = mod;
- this.Priority = priority;
- this.OnBehalfOf = onBehalfOf;
- this.GetData = getData;
- }
- }
+ /// <param name="Mod">The mod applying the edit.</param>
+ /// <param name="Priority">If there are multiple loads that apply to the same asset, the priority with which this one should be applied.</param>
+ /// <param name="OnBehalfOf">The content pack on whose behalf the asset is being loaded, if any.</param>
+ /// <param name="GetData">Load the initial value for an asset.</param>
+ internal record AssetLoadOperation(IModMetadata Mod, IModMetadata? OnBehalfOf, AssetLoadPriority Priority, Func<IAssetInfo, object> GetData);
}
diff --git a/src/SMAPI/Framework/Content/AssetOperationGroup.cs b/src/SMAPI/Framework/Content/AssetOperationGroup.cs
index a2fcb722..1566a8f0 100644
--- a/src/SMAPI/Framework/Content/AssetOperationGroup.cs
+++ b/src/SMAPI/Framework/Content/AssetOperationGroup.cs
@@ -1,33 +1,8 @@
namespace StardewModdingAPI.Framework.Content
{
/// <summary>A set of operations to apply to an asset for a given <see cref="IAssetEditor"/> or <see cref="IAssetLoader"/> implementation.</summary>
- internal class AssetOperationGroup
- {
- /*********
- ** Accessors
- *********/
- /// <summary>The mod applying the changes.</summary>
- public IModMetadata Mod { get; }
-
- /// <summary>The load operations to apply.</summary>
- public AssetLoadOperation[] LoadOperations { get; }
-
- /// <summary>The edit operations to apply.</summary>
- public AssetEditOperation[] EditOperations { get; }
-
-
- /*********
- ** Public methods
- *********/
- /// <summary>Construct an instance.</summary>
- /// <param name="mod">The mod applying the changes.</param>
- /// <param name="loadOperations">The load operations to apply.</param>
- /// <param name="editOperations">The edit operations to apply.</param>
- public AssetOperationGroup(IModMetadata mod, AssetLoadOperation[] loadOperations, AssetEditOperation[] editOperations)
- {
- this.Mod = mod;
- this.LoadOperations = loadOperations;
- this.EditOperations = editOperations;
- }
- }
+ /// <param name="Mod">The mod applying the changes.</param>
+ /// <param name="LoadOperations">The load operations to apply.</param>
+ /// <param name="EditOperations">The edit operations to apply.</param>
+ internal record AssetOperationGroup(IModMetadata Mod, AssetLoadOperation[] LoadOperations, AssetEditOperation[] EditOperations);
}
diff --git a/src/SMAPI/Framework/ContentCoordinator.cs b/src/SMAPI/Framework/ContentCoordinator.cs
index f7cab23d..6702f5e6 100644
--- a/src/SMAPI/Framework/ContentCoordinator.cs
+++ b/src/SMAPI/Framework/ContentCoordinator.cs
@@ -615,19 +615,19 @@ namespace StardewModdingAPI.Framework
editor: loader.Data,
dataType: info.DataType,
createGroup: () => new AssetOperationGroup(
- mod: loader.Mod,
- loadOperations: new[]
+ Mod: loader.Mod,
+ LoadOperations: new[]
{
new AssetLoadOperation(
- mod: loader.Mod,
- priority: AssetLoadPriority.Exclusive,
- onBehalfOf: null,
- getData: assetInfo => loader.Data.Load<T>(
+ Mod: loader.Mod,
+ OnBehalfOf: null,
+ Priority: AssetLoadPriority.Exclusive,
+ GetData: assetInfo => loader.Data.Load<T>(
this.GetLegacyAssetInfo(assetInfo)
)
)
},
- editOperations: Array.Empty<AssetEditOperation>()
+ EditOperations: Array.Empty<AssetEditOperation>()
)
);
}
@@ -674,15 +674,15 @@ namespace StardewModdingAPI.Framework
editor: editor.Data,
dataType: info.DataType,
createGroup: () => new AssetOperationGroup(
- mod: editor.Mod,
- loadOperations: Array.Empty<AssetLoadOperation>(),
- editOperations: new[]
+ Mod: editor.Mod,
+ LoadOperations: Array.Empty<AssetLoadOperation>(),
+ EditOperations: new[]
{
new AssetEditOperation(
- mod: editor.Mod,
- priority: priority,
- onBehalfOf: null,
- applyEdit: assetData => editor.Data.Edit<T>(
+ Mod: editor.Mod,
+ OnBehalfOf: null,
+ Priority: priority,
+ ApplyEdit: assetData => editor.Data.Edit<T>(
this.GetLegacyAssetData(assetData)
)
)