World.ObjectListChanged event should track furniture but doesn't
DiscipleOfEris opened this issue ยท 2 comments
Describe the bug
The Events documentation states the World.ObjectListChanged
event is: "Raised after objects are added/removed in any location (including machines, furniture, fences, etc)." (emphasis mine). However, furniture changes are not actually tracked by this event or any other event.
To Reproduce
- Install a mod with nothing but:
public override void Entry(IModHelper helper)
{
this.Helper.Events.World.ObjectListChanged += delegate (object sender, ObjectListChangedEventArgs e)
{
Monitor.Log("ObjectListChanged", LogLevel.Debug);
};
}
- Load a new or any save.
- Pick up or set down any furniture.
- Nothing appears in log.
Log file
https://smapi.io/log/dcaaad354e4f42d48d7d69dcf9b64ecf
So this is probably a pretty quick fix. ObjectListChanged
is tracking changes to GameLocation::netObjects
but furniture are stored in GameLocation::furniture
which is a NetCollection.
I think the proper fix would be to add a new event: World.FurnitureListChanged
that tracks changes to the GameLocation::furniture
field. So in https://github.com/Pathoschild/SMAPI/blob/develop/src/SMAPI/Framework/StateTracking/LocationTracker.cs we would just add a ICollectionWatcher<Furniture>
created with WatcherFactory.ForNetCollection(location.furniture)
.
Then raise the new event in
SMAPI/src/SMAPI/Framework/SCore.cs
Line 882 in 112b505
Thanks! Added via #779 for the upcoming SMAPI 3.11.