summaryrefslogtreecommitdiff
path: root/src/SMAPI/Events/TerrainFeatureListChangedEventArgs.cs
blob: 77a7310216e3f8a0f8e3c1eb921b78ffadc4b386 (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
#nullable disable

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using StardewValley;
using StardewValley.TerrainFeatures;

namespace StardewModdingAPI.Events
{
    /// <summary>Event arguments for a <see cref="IWorldEvents.TerrainFeatureListChanged"/> event.</summary>
    public class TerrainFeatureListChangedEventArgs : EventArgs
    {
        /*********
        ** Accessors
        *********/
        /// <summary>The location which changed.</summary>
        public GameLocation Location { get; }

        /// <summary>The terrain features added to the location.</summary>
        public IEnumerable<KeyValuePair<Vector2, TerrainFeature>> Added { get; }

        /// <summary>The terrain features removed from the location.</summary>
        public IEnumerable<KeyValuePair<Vector2, TerrainFeature>> Removed { get; }

        /// <summary>Whether this is the location containing the local player.</summary>
        public bool IsCurrentLocation => object.ReferenceEquals(this.Location, Game1.player?.currentLocation);


        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="location">The location which changed.</param>
        /// <param name="added">The terrain features added to the location.</param>
        /// <param name="removed">The terrain features removed from the location.</param>
        internal TerrainFeatureListChangedEventArgs(GameLocation location, IEnumerable<KeyValuePair<Vector2, TerrainFeature>> added, IEnumerable<KeyValuePair<Vector2, TerrainFeature>> removed)
        {
            this.Location = location;
            this.Added = added.ToArray();
            this.Removed = removed.ToArray();
        }
    }
}