using JetBrains.Annotations; using System; namespace NEG.Utils.Timing { public class AutoTimeMachine { private readonly TimeMachine machine; public AutoTimeMachine(Action action, double interval) { Action = action; Interval = interval; machine = new TimeMachine(); } [PublicAPI] public double Interval { get; set; } [PublicAPI] public Action Action { get; } /// /// Forwards the time by given amount, triggers assigned action relevant amount of times /// /// Amount of time to forward by public void Forward(double time) { machine.Accumulate(time); int rolls = machine.RetrieveAll(Interval); for (int i = 0; i < rolls; i++) Action(); } } }