#nullable disable
using Microsoft.Xna.Framework;
using StardewValley;
using StardewValley.Menus;
namespace StardewModdingAPI.Framework.StateTracking.Snapshots
{
/// A frozen snapshot of the game state watchers.
internal class WatcherSnapshot
{
/*********
** Accessors
*********/
/// Tracks changes to the window size.
public SnapshotDiff WindowSize { get; } = new();
/// Tracks changes to the current player.
public PlayerSnapshot CurrentPlayer { get; private set; }
/// Tracks changes to the time of day (in 24-hour military format).
public SnapshotDiff Time { get; } = new();
/// Tracks changes to the save ID.
public SnapshotDiff SaveID { get; } = new();
/// Tracks changes to the game's locations.
public WorldLocationsSnapshot Locations { get; } = new();
/// Tracks changes to .
public SnapshotDiff ActiveMenu { get; } = new();
/// Tracks changes to the cursor position.
public SnapshotDiff Cursor { get; } = new();
/// Tracks changes to the mouse wheel scroll.
public SnapshotDiff MouseWheelScroll { get; } = new();
/// Tracks changes to the content locale.
public SnapshotDiff Locale { get; } = new();
/*********
** Public methods
*********/
/// Update the tracked values.
/// The watchers to snapshot.
public void Update(WatcherCore watchers)
{
// update player instance
if (watchers.CurrentPlayerTracker == null)
this.CurrentPlayer = null;
else if (watchers.CurrentPlayerTracker.Player != this.CurrentPlayer?.Player)
this.CurrentPlayer = new PlayerSnapshot(watchers.CurrentPlayerTracker.Player);
// update snapshots
this.WindowSize.Update(watchers.WindowSizeWatcher);
this.Locale.Update(watchers.LocaleWatcher);
this.CurrentPlayer?.Update(watchers.CurrentPlayerTracker);
this.Time.Update(watchers.TimeWatcher);
this.SaveID.Update(watchers.SaveIdWatcher);
this.Locations.Update(watchers.LocationsWatcher);
this.ActiveMenu.Update(watchers.ActiveMenuWatcher);
this.Cursor.Update(watchers.CursorWatcher);
this.MouseWheelScroll.Update(watchers.MouseWheelScrollWatcher);
}
}
}