namespace StardewModdingAPI.Framework.Utilities { /// Counts down from a baseline value. internal class Countdown { /********* ** Accessors *********/ /// The initial value from which to count down. public int Initial { get; } /// The current value. public int Current { get; private set; } /********* ** Public methods *********/ /// Construct an instance. /// The initial value from which to count down. public Countdown(int initial) { this.Initial = initial; this.Current = initial; } /// Reduce the current value by one. /// Returns whether the value was decremented (i.e. wasn't already zero). public bool Decrement() { if (this.Current <= 0) return false; this.Current--; return true; } /// Restart the countdown. public void Reset() { this.Current = this.Initial; } } }