diff options
Diffstat (limited to 'src/SMAPI/Events/AssetRequestedEventArgs.cs')
-rw-r--r-- | src/SMAPI/Events/AssetRequestedEventArgs.cs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/SMAPI/Events/AssetRequestedEventArgs.cs b/src/SMAPI/Events/AssetRequestedEventArgs.cs index 774ab808..9942079b 100644 --- a/src/SMAPI/Events/AssetRequestedEventArgs.cs +++ b/src/SMAPI/Events/AssetRequestedEventArgs.cs @@ -50,18 +50,20 @@ namespace StardewModdingAPI.Events /// <summary>Provide the initial instance for the asset, instead of trying to load it from the game's <c>Content</c> folder.</summary> /// <param name="load">Get the initial instance of an asset.</param> /// <param name="onBehalfOf">The content pack ID on whose behalf you're applying the change. This is only valid for content packs for your mod.</param> + /// <param name="allowSkipOnConflict">When there are multiple loads that apply to the same asset, this indicates whether this one can be skipped to resolve the conflict. If all loads allow skipping, the first one that was registered will be applied. If this is false, SMAPI will raise an error and apply none of them.</param> /// <remarks> /// Usage notes: /// <list type="bullet"> /// <item>The asset doesn't need to exist in the game's <c>Content</c> folder. If any mod loads the asset, the game will see it as an existing asset as if it was in that folder.</item> - /// <item>Each asset can logically only have one initial instance. If multiple loads apply at the same time, SMAPI will raise an error and ignore all of them. If you're making changes to the existing asset instead of replacing it, you should use <see cref="Edit"/> instead to avoid those limitations and improve mod compatibility.</item> + /// <item>Each asset can logically only have one initial instance. If multiple loads apply at the same time, SMAPI will use the <paramref name="allowSkipOnConflict"/> parameter to decide what happens. If you're making changes to the existing asset instead of replacing it, you should use <see cref="Edit"/> instead to avoid those limitations and improve mod compatibility.</item> /// </list> /// </remarks> - public void LoadFrom(Func<object> load, string onBehalfOf = null) + public void LoadFrom(Func<object> load, string onBehalfOf = null, bool allowSkipOnConflict = false) { this.LoadOperations.Add( new AssetLoadOperation( mod: this.Mod, + allowSkipOnConflict: allowSkipOnConflict, onBehalfOf: this.GetOnBehalfOf(this.Mod, onBehalfOf, "load assets"), getData: _ => load() ) @@ -71,6 +73,7 @@ namespace StardewModdingAPI.Events /// <summary>Provide the initial instance for the asset from a file in your mod folder, instead of trying to load it from the game's <c>Content</c> folder.</summary> /// <typeparam name="TAsset">The expected data type. The main supported types are <see cref="Map"/>, <see cref="Texture2D"/>, dictionaries, and lists; other types may be supported by the game's content pipeline.</typeparam> /// <param name="relativePath">The relative path to the file in your mod folder.</param> + /// <param name="allowSkipOnConflict">When there are multiple loads that apply to the same asset, this indicates whether this one can be skipped to resolve the conflict. If all loads allow skipping, the first one that was registered will be applied. If this is false, SMAPI will raise an error and apply none of them.</param> /// <remarks> /// Usage notes: /// <list type="bullet"> @@ -78,11 +81,12 @@ namespace StardewModdingAPI.Events /// <item>Each asset can logically only have one initial instance. If multiple loads apply at the same time, SMAPI will raise an error and ignore all of them. If you're making changes to the existing asset instead of replacing it, you should use <see cref="Edit"/> instead to avoid those limitations and improve mod compatibility.</item> /// </list> /// </remarks> - public void LoadFromModFile<TAsset>(string relativePath) + public void LoadFromModFile<TAsset>(string relativePath, bool allowSkipOnConflict = false) { this.LoadOperations.Add( new AssetLoadOperation( mod: this.Mod, + allowSkipOnConflict: allowSkipOnConflict, onBehalfOf: null, _ => this.Mod.Mod.Helper.Content.Load<TAsset>(relativePath)) ); |