Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch PhysicsTimer #4110

Merged
merged 2 commits into from
Mar 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions Source/ACE.Server/Physics/Common/PhysicsTimer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Diagnostics;
using System;

using ACE.Server.Entity;

namespace ACE.Server.Physics.Common
{
Expand All @@ -8,17 +10,19 @@ namespace ACE.Server.Physics.Common
/// </summary>
public class PhysicsTimer
{
private static readonly Stopwatch _timer;
// 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;

/// <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 static double CurrentTime => _timer.Elapsed.TotalSeconds;

static PhysicsTimer()
{
_timer = Stopwatch.StartNew();
}
_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;
}
}