From 5f2e83969a0994d798b869b1b53e9fc82d556093 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 8 May 2022 18:37:23 -0400 Subject: only build AssetWithoutLocale when it's used --- src/SMAPI/Events/AssetRequestedEventArgs.cs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/SMAPI/Events') 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; } -- cgit