diff --git a/src/SMAPI/Events/AssetRequestedEventArgs.cs b/src/SMAPI/Events/AssetRequestedEventArgs.cs
index 3bcf83b9..6b00b1d9 100644
--- a/src/SMAPI/Events/AssetRequestedEventArgs.cs
+++ b/src/SMAPI/Events/AssetRequestedEventArgs.cs
@@ -19,19 +19,22 @@ namespace StardewModdingAPI.Events
/// Get the mod metadata for a content pack, if it's a valid content pack for the mod.
private readonly Func GetOnBehalfOf;
+ /// The asset info being requested.
+ private readonly IAssetInfo AssetInfo;
+
/*********
** Accessors
*********/
/// The name of the asset being requested.
- public IAssetName Name { get; }
+ public IAssetName Name => this.AssetInfo.Name;
/// The with any locale codes stripped.
/// For example, if contains a locale like Data/Bundles.fr-FR, this will be the name without locale like Data/Bundles. If the name has no locale, this field is equivalent.
- public IAssetName NameWithoutLocale { get; }
+ public IAssetName NameWithoutLocale => this.AssetInfo.NameWithoutLocale;
/// The requested data type.
- public Type DataType { get; }
+ public Type DataType => this.AssetInfo.DataType;
/// The load operations requested by the event handler.
internal IList LoadOperations { get; } = new List();
@@ -45,16 +48,12 @@ namespace StardewModdingAPI.Events
*********/
/// Construct an instance.
/// The mod handling the event.
- /// The name of the asset being requested.
- /// The requested data type.
- /// The with any locale codes stripped.
+ /// The asset info being requested.
/// Get the mod metadata for a content pack, if it's a valid content pack for the mod.
- internal AssetRequestedEventArgs(IModMetadata mod, IAssetName name, IAssetName nameWithoutLocale, Type dataType, Func getOnBehalfOf)
+ internal AssetRequestedEventArgs(IModMetadata mod, IAssetInfo assetInfo, Func getOnBehalfOf)
{
this.Mod = mod;
- this.Name = name;
- this.NameWithoutLocale = nameWithoutLocale;
- this.DataType = dataType;
+ this.AssetInfo = assetInfo;
this.GetOnBehalfOf = getOnBehalfOf;
}
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
/// Normalizes an asset key to match the cache key.
protected readonly Func GetNormalizedPath;
+ /// The backing field for .
+ private IAssetName? NameWithoutLocaleImpl;
+
/*********
** Accessors
@@ -24,7 +27,7 @@ namespace StardewModdingAPI.Framework.Content
public IAssetName Name { get; }
///
- public IAssetName NameWithoutLocale { get; }
+ public IAssetName NameWithoutLocale => this.NameWithoutLocaleImpl ??= this.Name.GetBaseAssetName();
///
[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/SCore.cs b/src/SMAPI/Framework/SCore.cs
index 3c6e1b6c..f882682e 100644
--- a/src/SMAPI/Framework/SCore.cs
+++ b/src/SMAPI/Framework/SCore.cs
@@ -1160,7 +1160,7 @@ namespace StardewModdingAPI.Framework
this.EventManager.AssetRequested.Raise(
invoke: (mod, invoke) =>
{
- AssetRequestedEventArgs args = new(mod, asset.Name, asset.NameWithoutLocale, asset.DataType, this.GetOnBehalfOfContentPack);
+ AssetRequestedEventArgs args = new(mod, asset, this.GetOnBehalfOfContentPack);
invoke(args);