diff --git a/src/SMAPI/Events/AssetRequestedEventArgs.cs b/src/SMAPI/Events/AssetRequestedEventArgs.cs index 6b00b1d9..d0aef1db 100644 --- a/src/SMAPI/Events/AssetRequestedEventArgs.cs +++ b/src/SMAPI/Events/AssetRequestedEventArgs.cs @@ -72,10 +72,10 @@ namespace StardewModdingAPI.Events { this.LoadOperations.Add( new AssetLoadOperation( - mod: this.Mod, - priority: priority, - onBehalfOf: this.GetOnBehalfOf(this.Mod, onBehalfOf, "load assets"), - getData: _ => load() + Mod: this.Mod, + OnBehalfOf: this.GetOnBehalfOf(this.Mod, onBehalfOf, "load assets"), + Priority: priority, + GetData: _ => load() ) ); } @@ -96,10 +96,10 @@ namespace StardewModdingAPI.Events { this.LoadOperations.Add( new AssetLoadOperation( - mod: this.Mod, - priority: priority, - onBehalfOf: null, - _ => this.Mod.Mod!.Helper.ModContent.Load(relativePath) + Mod: this.Mod, + OnBehalfOf: null, + Priority: priority, + GetData: _ => this.Mod.Mod!.Helper.ModContent.Load(relativePath) ) ); } @@ -119,10 +119,10 @@ namespace StardewModdingAPI.Events { this.EditOperations.Add( new AssetEditOperation( - mod: this.Mod, - priority: priority, - onBehalfOf: this.GetOnBehalfOf(this.Mod, onBehalfOf, "edit assets"), - apply + Mod: this.Mod, + Priority: priority, + OnBehalfOf: this.GetOnBehalfOf(this.Mod, onBehalfOf, "edit assets"), + ApplyEdit: apply ) ); } 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 { /// 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; } - - /// If there are multiple edits that apply to the same asset, the priority with which this one should be applied. - public AssetEditPriority Priority { get; } - - /// The content pack on whose behalf the edit is being applied, if any. - public IModMetadata? OnBehalfOf { get; } - - /// Apply the edit to an asset. - public Action ApplyEdit { get; } - - - /********* - ** Public methods - *********/ - /// Construct an instance. - /// The mod applying the edit. - /// If there are multiple edits that apply to the same asset, the priority with which this one should be applied. - /// The content pack on whose behalf the edit is being applied, if any. - /// Apply the edit to an asset. - public AssetEditOperation(IModMetadata mod, AssetEditPriority priority, IModMetadata? onBehalfOf, Action applyEdit) - { - this.Mod = mod; - this.Priority = priority; - this.OnBehalfOf = onBehalfOf; - this.ApplyEdit = applyEdit; - } - } + /// The mod applying the edit. + /// If there are multiple edits that apply to the same asset, the priority with which this one should be applied. + /// The content pack on whose behalf the edit is being applied, if any. + /// Apply the edit to an asset. + internal record AssetEditOperation(IModMetadata Mod, AssetEditPriority Priority, IModMetadata? OnBehalfOf, Action 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 { /// An operation which provides the initial instance of an asset when it's requested from the content pipeline. - internal class AssetLoadOperation - { - /********* - ** Accessors - *********/ - /// The mod loading the asset. - public IModMetadata Mod { get; } - - /// The content pack on whose behalf the asset is being loaded, if any. - public IModMetadata? OnBehalfOf { get; } - - /// If there are multiple loads that apply to the same asset, the priority with which this one should be applied. - public AssetLoadPriority Priority { get; } - - /// Load the initial value for an asset. - public Func GetData { get; } - - - /********* - ** Public methods - *********/ - /// Construct an instance. - /// The mod applying the edit. - /// If there are multiple loads that apply to the same asset, the priority with which this one should be applied. - /// The content pack on whose behalf the asset is being loaded, if any. - /// Load the initial value for an asset. - public AssetLoadOperation(IModMetadata mod, AssetLoadPriority priority, IModMetadata? onBehalfOf, Func getData) - { - this.Mod = mod; - this.Priority = priority; - this.OnBehalfOf = onBehalfOf; - this.GetData = getData; - } - } + /// The mod applying the edit. + /// If there are multiple loads that apply to the same asset, the priority with which this one should be applied. + /// The content pack on whose behalf the asset is being loaded, if any. + /// Load the initial value for an asset. + internal record AssetLoadOperation(IModMetadata Mod, IModMetadata? OnBehalfOf, AssetLoadPriority Priority, Func 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 { /// A set of operations to apply to an asset for a given or implementation. - internal class AssetOperationGroup - { - /********* - ** Accessors - *********/ - /// The mod applying the changes. - public IModMetadata Mod { get; } - - /// The load operations to apply. - public AssetLoadOperation[] LoadOperations { get; } - - /// The edit operations to apply. - public AssetEditOperation[] EditOperations { get; } - - - /********* - ** Public methods - *********/ - /// Construct an instance. - /// The mod applying the changes. - /// The load operations to apply. - /// The edit operations to apply. - public AssetOperationGroup(IModMetadata mod, AssetLoadOperation[] loadOperations, AssetEditOperation[] editOperations) - { - this.Mod = mod; - this.LoadOperations = loadOperations; - this.EditOperations = editOperations; - } - } + /// The mod applying the changes. + /// The load operations to apply. + /// The edit operations to apply. + 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( + Mod: loader.Mod, + OnBehalfOf: null, + Priority: AssetLoadPriority.Exclusive, + GetData: assetInfo => loader.Data.Load( this.GetLegacyAssetInfo(assetInfo) ) ) }, - editOperations: Array.Empty() + EditOperations: Array.Empty() ) ); } @@ -674,15 +674,15 @@ namespace StardewModdingAPI.Framework editor: editor.Data, dataType: info.DataType, createGroup: () => new AssetOperationGroup( - mod: editor.Mod, - loadOperations: Array.Empty(), - editOperations: new[] + Mod: editor.Mod, + LoadOperations: Array.Empty(), + EditOperations: new[] { new AssetEditOperation( - mod: editor.Mod, - priority: priority, - onBehalfOf: null, - applyEdit: assetData => editor.Data.Edit( + Mod: editor.Mod, + OnBehalfOf: null, + Priority: priority, + ApplyEdit: assetData => editor.Data.Edit( this.GetLegacyAssetData(assetData) ) )