summaryrefslogtreecommitdiff
path: root/StardewModdingAPI/Events/Time.cs
blob: 39ca642aca1c8bb1760b0772c12621e896c5a5c9 (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
36
37
38
39
40
41
42
using System;

namespace StardewModdingAPI.Events
{
    public static class TimeEvents
    {
        public static event EventHandler<EventArgsIntChanged> TimeOfDayChanged = delegate { };
        public static event EventHandler<EventArgsIntChanged> DayOfMonthChanged = delegate { };
        public static event EventHandler<EventArgsIntChanged> YearOfGameChanged = delegate { };
        public static event EventHandler<EventArgsStringChanged> SeasonOfYearChanged = delegate { };

        /// <summary>
        /// Occurs when Game1.newDay changes. True directly before saving, and False directly after.
        /// </summary>
        public static event EventHandler<EventArgsNewDay> OnNewDay = delegate { };

        internal static void InvokeTimeOfDayChanged(int priorInt, int newInt)
        {
            TimeOfDayChanged.Invoke(null, new EventArgsIntChanged(priorInt, newInt));
        }

        internal static void InvokeDayOfMonthChanged(int priorInt, int newInt)
        {
            DayOfMonthChanged.Invoke(null, new EventArgsIntChanged(priorInt, newInt));
        }

        internal static void InvokeYearOfGameChanged(int priorInt, int newInt)
        {
            YearOfGameChanged.Invoke(null, new EventArgsIntChanged(priorInt, newInt));
        }

        internal static void InvokeSeasonOfYearChanged(string priorString, string newString)
        {
            SeasonOfYearChanged.Invoke(null, new EventArgsStringChanged(priorString, newString));
        }

        internal static void InvokeOnNewDay(int priorInt, int newInt, bool newDay)
        {
            OnNewDay.Invoke(null, new EventArgsNewDay(priorInt, newInt, newDay));
        }
    }
}