diff --git a/src/SimulationApp.cs b/src/SimulationApp.cs index 5bf66f6..ad3d3bf 100644 --- a/src/SimulationApp.cs +++ b/src/SimulationApp.cs @@ -26,8 +26,7 @@ public abstract class SimulationApp : ITick /// Constant for the amount of time difference that should occur from last tick and current tick in milliseconds before /// the simulation logic will be ticked. /// - // ReSharper disable once InconsistentNaming - private const double TICK_INTERVAL = 1000.0d; + private readonly double _tickIntervalInMillis; /// /// Time and date of latest system tick, used to measure total elapsed time and tick simulation after each second. @@ -47,10 +46,19 @@ public abstract class SimulationApp : ITick private SpinningPixel _spinningPixel; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class with default tick interval (1000ms). /// - protected SimulationApp() + protected SimulationApp() : this(1000.0d) { + } + + /// + /// Initializes a new instance of the class with given tick interval. + /// + protected SimulationApp(double tickIntervalInMillis) + { + _tickIntervalInMillis = tickIntervalInMillis; + // We are not closing... IsClosing = false; @@ -162,7 +170,7 @@ public virtual void OnTick(bool systemTick, bool skipDay = false) var elapsedSpan = new TimeSpan(elapsedTicks); // Check if more than an entire second has gone by. - if (!(elapsedSpan.TotalMilliseconds > TICK_INTERVAL)) + if (!(elapsedSpan.TotalMilliseconds > _tickIntervalInMillis)) return; // Reset last tick time to current time for measuring towards next second tick.