ace/Source/ACE.Server/Physics/Common/PhysicsTimer.cs
Mag-nus 2e9b8f38d8
Switch PhysicsTimer (#4110)
* Switch PhysicsTimer

PhysicsTimer.CurrentTime evalulated the stopwatch every single call.

This simply redirects the timer to use the master Timers.PortalYearTicks timer

* Update PhysicsTimer.cs
2024-03-24 14:29:36 +00:00

28 lines
1.1 KiB
C#

using System;
using ACE.Server.Entity;
namespace ACE.Server.Physics.Common
{
/// <summary>
/// This should only be used by the ACE.Server.Physics namespace and physics related properties<para />
/// For a equally precise timer outside of this namespace, you can use WorldManager.PortalYearTicks
/// </summary>
public class PhysicsTimer
{
// When using PhysicsTimer outside of a running ACE instance, you must uncomment these lines and use this version of the timer. Otherwise, your CurrentTime will not increment.
// You can use this method when running in an ACE instance, it's just less efficient.
/*private static readonly System.Diagnostics.Stopwatch _timer;
public static double CurrentTime => _timer.Elapsed.TotalSeconds;
static PhysicsTimer()
{
_timer = System.Diagnostics.Stopwatch.StartNew();
}*/
// When using PhysicsTimer in a running ACE instance, you should use this timer instead. It is more efficient. Timers.PortalYearTicks is incremented by the WorldManager.
public static double CurrentTime => Timers.PortalYearTicks;
}
}