/ GUNRPG.Core / Time / SimulationTime.cs
SimulationTime.cs
 1  namespace GUNRPG.Core.Time;
 2  
 3  /// <summary>
 4  /// Represents the global simulation clock.
 5  /// All time in the simulation is measured in milliseconds.
 6  /// </summary>
 7  public class SimulationTime
 8  {
 9      /// <summary>
10      /// Current time in milliseconds.
11      /// </summary>
12      public long CurrentTimeMs { get; private set; }
13  
14      /// <summary>
15      /// Advances the simulation time by the specified amount.
16      /// </summary>
17      /// <param name="deltaMs">Amount of time to advance in milliseconds.</param>
18      public void Advance(long deltaMs)
19      {
20          if (deltaMs < 0)
21              throw new ArgumentException("Cannot advance time backwards", nameof(deltaMs));
22          
23          CurrentTimeMs += deltaMs;
24      }
25  
26      /// <summary>
27      /// Resets the simulation time to zero.
28      /// </summary>
29      public void Reset()
30      {
31          CurrentTimeMs = 0;
32      }
33  }