summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/Content
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI/Framework/Content')
-rw-r--r--src/SMAPI/Framework/Content/AssetEditOperation.cs39
-rw-r--r--src/SMAPI/Framework/Content/AssetInfo.cs6
-rw-r--r--src/SMAPI/Framework/Content/AssetLoadOperation.cs39
-rw-r--r--src/SMAPI/Framework/Content/AssetOperationGroup.cs33
4 files changed, 18 insertions, 99 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/AssetInfo.cs b/src/SMAPI/Framework/Content/AssetInfo.cs
index 363fffb3..a4f0a408 100644
--- a/src/SMAPI/Framework/Content/AssetInfo.cs
+++ b/src/SMAPI/Framework/Content/AssetInfo.cs
@@ -13,6 +13,9 @@ namespace StardewModdingAPI.Framework.Content
/// <summary>Normalizes an asset key to match the cache key.</summary>
protected readonly Func<string, string> GetNormalizedPath;
+ /// <summary>The backing field for <see cref="NameWithoutLocale"/>.</summary>
+ private IAssetName? NameWithoutLocaleImpl;
+
/*********
** Accessors
@@ -24,7 +27,7 @@ namespace StardewModdingAPI.Framework.Content
public IAssetName Name { get; }
/// <inheritdoc />
- public IAssetName NameWithoutLocale { get; }
+ public IAssetName NameWithoutLocale => this.NameWithoutLocaleImpl ??= this.Name.GetBaseAssetName();
/// <inheritdoc />
[Obsolete($"Use {nameof(AssetInfo.Name)} or {nameof(AssetInfo.NameWithoutLocale)} instead. This property will be removed in SMAPI 4.0.0.")]
@@ -64,7 +67,6 @@ namespace StardewModdingAPI.Framework.Content
{
this.Locale = locale;
this.Name = assetName;
- this.NameWithoutLocale = assetName.GetBaseAssetName();
this.DataType = type;
this.GetNormalizedPath = getNormalizedPath;
}
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);
}