summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/Events/ModWorldEvents.cs
blob: db03e447485cb04ba5f848fb402691fbe78617b4 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using System;
using StardewModdingAPI.Events;

namespace StardewModdingAPI.Framework.Events
{
    /// <summary>Events raised when something changes in the world.</summary>
    public class ModWorldEvents : IWorldEvents
    {
        /*********
        ** Properties
        *********/
        /// <summary>The underlying event manager.</summary>
        private readonly EventManager EventManager;

        /// <summary>The mod which uses this instance.</summary>
        private readonly IModMetadata Mod;


        /*********
        ** Accessors
        *********/
        /// <summary>Raised after a game location is added or removed.</summary>
        public event EventHandler<WorldLocationListChangedEventArgs> LocationListChanged
        {
            add => this.EventManager.World_LocationListChanged.Add(value, this.Mod);
            remove => this.EventManager.World_LocationListChanged.Remove(value);
        }

        /// <summary>Raised after buildings are added or removed in a location.</summary>
        public event EventHandler<WorldBuildingListChangedEventArgs> BuildingListChanged
        {
            add => this.EventManager.World_BuildingListChanged.Add(value, this.Mod);
            remove => this.EventManager.World_BuildingListChanged.Remove(value);
        }

        /// <summary>Raised after large terrain features (like bushes) are added or removed in a location.</summary>
        public event EventHandler<WorldLargeTerrainFeatureListChangedEventArgs> LargeTerrainFeatureListChanged
        {
            add => this.EventManager.World_LargeTerrainFeatureListChanged.Add(value, this.Mod);
            remove => this.EventManager.World_LargeTerrainFeatureListChanged.Remove(value);
        }

        /// <summary>Raised after NPCs are added or removed in a location.</summary>
        public event EventHandler<WorldNpcListChangedEventArgs> NpcListChanged
        {
            add => this.EventManager.World_NpcListChanged.Add(value);
            remove => this.EventManager.World_NpcListChanged.Remove(value);
        }

        /// <summary>Raised after objects are added or removed in a location.</summary>
        public event EventHandler<WorldObjectListChangedEventArgs> ObjectListChanged
        {
            add => this.EventManager.World_ObjectListChanged.Add(value);
            remove => this.EventManager.World_ObjectListChanged.Remove(value);
        }

        /// <summary>Raised after terrain features (like floors and trees) are added or removed in a location.</summary>
        public event EventHandler<WorldTerrainFeatureListChangedEventArgs> TerrainFeatureListChanged
        {
            add => this.EventManager.World_TerrainFeatureListChanged.Add(value);
            remove => this.EventManager.World_TerrainFeatureListChanged.Remove(value);
        }


        /*********
        ** 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>
        internal ModWorldEvents(IModMetadata mod, EventManager eventManager)
        {
            this.Mod = mod;
            this.EventManager = eventManager;
        }
    }
}