using System;
using StardewModdingAPI.Framework;
namespace StardewModdingAPI.Events
{
/// Events raised before and after the player saves/loads the game.
public static class SaveEvents
{
/*********
** Events
*********/
/// Raised before the game begins writes data to the save file.
public static event EventHandler BeforeSave;
/// Raised after the game finishes writing data to the save file.
public static event EventHandler AfterSave;
/// Raised after the player loads a save slot.
public static event EventHandler AfterLoad;
/*********
** Internal methods
*********/
/// Raise a event.
/// Encapsulates monitoring and logging.
internal static void InvokeBeforeSave(IMonitor monitor)
{
monitor.SafelyRaisePlainEvent($"{nameof(SaveEvents)}.{nameof(SaveEvents.BeforeSave)}", SaveEvents.BeforeSave?.GetInvocationList(), null, EventArgs.Empty);
}
/// Raise a event.
/// Encapsulates monitoring and logging.
internal static void InvokeAfterSave(IMonitor monitor)
{
monitor.SafelyRaisePlainEvent($"{nameof(SaveEvents)}.{nameof(SaveEvents.AfterSave)}", SaveEvents.AfterSave?.GetInvocationList(), null, EventArgs.Empty);
}
/// Raise a event.
/// Encapsulates monitoring and logging.
internal static void InvokeAfterLoad(IMonitor monitor)
{
monitor.SafelyRaisePlainEvent($"{nameof(SaveEvents)}.{nameof(SaveEvents.AfterLoad)}", SaveEvents.AfterLoad?.GetInvocationList(), null, EventArgs.Empty);
}
}
}