using System;
using System.Collections.Generic;
using System.Linq;
using StardewModdingAPI.Framework;
using StardewValley;
namespace StardewModdingAPI.Events
{
/// Events raised when the player data changes.
public static class PlayerEvents
{
/*********
** Events
*********/
/// Raised after the player's inventory changes in any way (added or removed item, sorted, etc).
public static event EventHandler InventoryChanged;
/// Raised after the player levels up a skill. This happens as soon as they level up, not when the game notifies the player after their character goes to bed.
public static event EventHandler LeveledUp;
/*********
** Internal methods
*********/
/// Raise an event.
/// Encapsulates monitoring and logging.
/// The player's inventory.
/// The inventory changes.
internal static void InvokeInventoryChanged(IMonitor monitor, List- inventory, IEnumerable changedItems)
{
monitor.SafelyRaiseGenericEvent($"{nameof(PlayerEvents)}.{nameof(PlayerEvents.InventoryChanged)}", PlayerEvents.InventoryChanged?.GetInvocationList(), null, new EventArgsInventoryChanged(inventory, changedItems.ToList()));
}
/// Rase a event.
/// Encapsulates monitoring and logging.
/// The player skill that leveled up.
/// The new skill level.
internal static void InvokeLeveledUp(IMonitor monitor, EventArgsLevelUp.LevelType type, int newLevel)
{
monitor.SafelyRaiseGenericEvent($"{nameof(PlayerEvents)}.{nameof(PlayerEvents.LeveledUp)}", PlayerEvents.LeveledUp?.GetInvocationList(), null, new EventArgsLevelUp(type, newLevel));
}
}
}