Modding tip:Scripted Objects and the Seasonal Lot Marker by Consort
This is how it probably works, to my best knowledge as of now.
Problem:
The seasonal lot marker (SLM) can make your scripted object disappear, but your code is still active although your object is not there.
What's going on?
The SLM puts your object "out of world". Your instantiated code is still there and reacts to the events you subscribed to. You may want to supress this and switch your code on and off depending on whether your object is "there" or "not there" in the current season.
Dealing with it:
this.InWorld is a useful bool you can check for. False if your object is hidden by the SLM, true if it's there.
The SLM also calls your object's AddToWorld() method when it is unhiding your object, and the RemoveFromWorld() method when making it disappear.
Simply do a prefab override for those methods. RemoveFromWorld in this example:
public override void RemoveFromWorld()
{
base.RemoveFromWorld();
//your code to switch off your stuff here
//for example:
EventTracker.RemoveListener(sRoomChangeListener);
sRoomChangeListener = null;
}
Note that both of these methods also get called quite frequently in build mode each time the user enters/leaves/changes a lot with a SLM. You may or may not want to gate that.
If anyone has better knowledge of the subject, please let us know:)