LADXHD/Base/TickCount.cs
2023-12-14 17:21:22 -05:00

29 lines
622 B
C#

using System.Linq;
namespace ProjectZ.Base
{
public class TickCounter
{
public int AverageTime;
private readonly int[] _timeCounts;
private int _currentIndex;
public TickCounter(int average)
{
_timeCounts = new int[average];
}
public void AddTick(long tick)
{
_timeCounts[_currentIndex] = (int)tick;
_currentIndex++;
if (_currentIndex >= _timeCounts.Length)
_currentIndex = 0;
AverageTime = (int)_timeCounts.Average();
}
}
}