From 2b0ce2bb4d6690b7d00da0a243855db9bffffbf0 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 24 Mar 2022 22:55:55 -0400 Subject: add AssetInvalidated content event (#766) --- src/SMAPI/Events/AssetsInvalidatedEventArgs.cs | 27 ++++++++++++++++++++++++++ src/SMAPI/Events/IContentEvents.cs | 3 +++ 2 files changed, 30 insertions(+) create mode 100644 src/SMAPI/Events/AssetsInvalidatedEventArgs.cs (limited to 'src/SMAPI/Events') diff --git a/src/SMAPI/Events/AssetsInvalidatedEventArgs.cs b/src/SMAPI/Events/AssetsInvalidatedEventArgs.cs new file mode 100644 index 00000000..0127f83a --- /dev/null +++ b/src/SMAPI/Events/AssetsInvalidatedEventArgs.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace StardewModdingAPI.Events +{ + /// Event arguments for an event. + public class AssetsInvalidatedEventArgs : EventArgs + { + /********* + ** Accessors + *********/ + /// The asset names that were invalidated. + public IEnumerable Names { get; } + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The asset names that were invalidated. + internal AssetsInvalidatedEventArgs(IEnumerable names) + { + this.Names = names.ToArray(); + } + } +} diff --git a/src/SMAPI/Events/IContentEvents.cs b/src/SMAPI/Events/IContentEvents.cs index feaf9c0a..ede9ea23 100644 --- a/src/SMAPI/Events/IContentEvents.cs +++ b/src/SMAPI/Events/IContentEvents.cs @@ -13,5 +13,8 @@ namespace StardewModdingAPI.Events /// If the asset is requested multiple times in the same tick (e.g. once to check if it exists and once to load it), SMAPI might only raise the event once and reuse the cached result. /// event EventHandler AssetRequested; + + /// Raised after one or more assets were invalidated from the content cache by a mod, so they'll be reloaded next time they're requested. If the assets will be reloaded or propagated automatically, this event is raised before that happens. + event EventHandler AssetsInvalidated; } } -- cgit