summaryrefslogtreecommitdiff
path: root/src/SMAPI/Events/EventArgsLocationObjectsChanged.cs
blob: a6138ddbb499188c6ed5f491db3ba6f8e796746d (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
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Netcode;
using StardewValley;
using SObject = StardewValley.Object;

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

        /// <summary>The objects added to the list.</summary>
        public IEnumerable<KeyValuePair<Vector2, SObject>> Added { get; }

        /// <summary>The objects removed from the list.</summary>
        public IEnumerable<KeyValuePair<Vector2, SObject>> Removed { get; }

        /// <summary>The current list of objects in the current location.</summary>
        [Obsolete("Use " + nameof(EventArgsLocationObjectsChanged.Added))]
        public IDictionary<Vector2, NetRef<SObject>> NewObjects { get; }


        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="location">The location which changed.</param>
        /// <param name="added">The objects added to the list.</param>
        /// <param name="removed">The objects removed from the list.</param>
        /// <param name="newObjects">The current list of objects in the current location.</param>
        public EventArgsLocationObjectsChanged(GameLocation location, IEnumerable<KeyValuePair<Vector2, SObject>> added, IEnumerable<KeyValuePair<Vector2, SObject>> removed, IDictionary<Vector2, NetRef<SObject>> newObjects)
        {
            this.Location = location;
            this.Added = added.ToArray();
            this.Removed = removed.ToArray();
            this.NewObjects = newObjects;
        }
    }
}