summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/Events/ModEvents.cs
blob: 7a318e8b4cbd69c97c6249aaa9b2593a71abf613 (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
43
44
45
46
using StardewModdingAPI.Events;

namespace StardewModdingAPI.Framework.Events
{
    /// <summary>Manages access to events raised by SMAPI.</summary>
    internal class ModEvents : IModEvents
    {
        /*********
        ** Accessors
        *********/
        /// <summary>Events related to UI and drawing to the screen.</summary>
        public IDisplayEvents Display { get; }

        /// <summary>Events linked to the game's update loop. The update loop runs roughly ≈60 times/second to run game logic like state changes, action handling, etc. These can be useful, but you should consider more semantic events like <see cref="IModEvents.Input"/> if possible.</summary>
        public IGameLoopEvents GameLoop { get; }

        /// <summary>Events raised when the player provides input using a controller, keyboard, or mouse.</summary>
        public IInputEvents Input { get; }

        /// <summary>Events raised when the player data changes.</summary>
        public IPlayerEvents Player { get; }

        /// <summary>Events raised when something changes in the world.</summary>
        public IWorldEvents World { get; }

        /// <summary>Events serving specialised edge cases that shouldn't be used by most mods.</summary>
        public ISpecialisedEvents Specialised { get; }


        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="mod">The mod which uses this instance.</param>
        /// <param name="eventManager">The underlying event manager.</param>
        public ModEvents(IModMetadata mod, EventManager eventManager)
        {
            this.Display = new ModDisplayEvents(mod, eventManager);
            this.GameLoop = new ModGameLoopEvents(mod, eventManager);
            this.Input = new ModInputEvents(mod, eventManager);
            this.Player = new ModPlayerEvents(mod, eventManager);
            this.World = new ModWorldEvents(mod, eventManager);
            this.Specialised = new ModSpecialisedEvents(mod, eventManager);
        }
    }
}