LADXHD/Base/TickCount.cs

29 lines
622 B
C#
Raw Permalink Normal View History

2023-12-14 22:21:22 +00:00
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();
}
}
}