using StardewModdingAPI.Framework.StateTracking;
namespace StardewModdingAPI.Framework
{
/// A snapshot of a tracked value.
/// The tracked value type.
internal class SnapshotDiff
{
/*********
** Accessors
*********/
/// Whether the value changed since the last update.
public bool IsChanged { get; private set; }
/// The previous value.
public T Old { get; private set; }
/// The current value.
public T New { get; private set; }
/*********
** Public methods
*********/
/// Update the snapshot.
/// Whether the value changed since the last update.
/// The previous value.
/// The current value.
public void Update(bool isChanged, T old, T now)
{
this.IsChanged = isChanged;
this.Old = old;
this.New = now;
}
/// Update the snapshot.
/// The value watcher to snapshot.
public void Update(IValueWatcher watcher)
{
this.Update(watcher.IsChanged, watcher.PreviousValue, watcher.CurrentValue);
}
}
}