ace/Source/ACE.Server/Entity/Timers.cs
Ty Conner e4cd32591a
Add and switch to EMU time for Game World (#3619)
* Add and switch to EMU time for world

* Update Timers.cs

* Update Timers.cs
2021-07-18 13:47:10 -04:00

49 lines
1.7 KiB
C#

using System;
using ACE.Common;
namespace ACE.Server.Entity
{
public static class Timers
{
/// <summary>
/// DateTime.UtcNow at the time the server started.
/// </summary>
public static DateTime WorldStartTime { get; } = DateTime.UtcNow;
/// <summary>
/// DateTime.UtcNow
/// </summary>
public static DateTime CurrentTime => DateTime.UtcNow;
/// <summary>
/// (CurrentTime - WorldStartTime).TotalSeconds<para />
/// This value has 1ms precision.
/// </summary>
public static double RunningTime => (CurrentTime - WorldStartTime).TotalSeconds;
/// <summary>
/// DerethDateTime.UtcNowToEMUTime at the time the server started.
/// </summary>
public static DerethDateTime WorldStartLoreTime { get; } = DerethDateTime.UtcNowToEMUTime;
/// <summary>
/// Returns DerethDateTime.UtcNowToLoreTime
/// </summary>
public static DerethDateTime CurrentLoreTime => DerethDateTime.UtcNowToLoreTime;
/// <summary>
/// Returns current in game time, as seen on Map Panel, calculated from PortalYearTicks
/// </summary>
public static DerethDateTime CurrentInGameTime => new DerethDateTime(PortalYearTicks);
/// <summary>
/// This is the current Portal Year time, in seconds.<para />
/// It is updated once per WorldManager.UpdateWorld() loop.<para />
/// This can also be used as the "frame time" value. This value will be unchanged for any calculations done inside of a single Tick of WorldManager.UpdateWorld().
/// </summary>
public static double PortalYearTicks { get; internal set; } = Timers.WorldStartLoreTime.Ticks;
}
}