summaryrefslogtreecommitdiff
path: root/StardewModdingAPI/Events/Player.cs
blob: 22f572b715b87e545c942730fac344b49f2533c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System;
using System.Collections.Generic;
using StardewModdingAPI.Inheritance;
using StardewValley;

namespace StardewModdingAPI.Events
{
    public static class PlayerEvents
    {
        public static event EventHandler<EventArgsFarmerChanged> FarmerChanged = delegate { };
        public static event EventHandler<EventArgsInventoryChanged> InventoryChanged = delegate { };
        public static event EventHandler<EventArgsLevelUp> LeveledUp = delegate { };
        public static event EventHandler<EventArgsLoadedGameChanged> LoadedGame = delegate { };

        internal static void InvokeFarmerChanged(Farmer priorFarmer, Farmer newFarmer)
        {
            FarmerChanged.Invoke(null, new EventArgsFarmerChanged(priorFarmer, newFarmer));
        }

        internal static void InvokeInventoryChanged(List<Item> inventory, List<ItemStackChange> changedItems)
        {
            InventoryChanged.Invoke(null, new EventArgsInventoryChanged(inventory, changedItems));
        }

        internal static void InvokeLeveledUp(EventArgsLevelUp.LevelType type, int newLevel)
        {
            LeveledUp.Invoke(null, new EventArgsLevelUp(type, newLevel));
        }

        internal static void InvokeLoadedGame(EventArgsLoadedGameChanged loaded)
        {
            LoadedGame.Invoke(null, loaded);
        }
    }
}