1er commit

This commit is contained in:
2021-08-21 10:14:47 +02:00
commit a99ecf7c2d
99 changed files with 66605 additions and 0 deletions

37
src/misc/Time.cpp Normal file
View File

@@ -0,0 +1,37 @@
#include "misc/Time.h"
#include <chrono>
namespace td {
namespace utils {
void Timer::update(){
m_InternalTime += getTime() - m_LastTime;
if(m_InternalTime >= m_Interval){
if(m_Function != nullptr)
m_Function();
m_InternalTime %= m_Interval;
}
m_LastTime = getTime();
}
void Timer::update(std::uint64_t delta){
m_InternalTime += delta;
if(m_InternalTime >= m_Interval){
if(m_Function != nullptr)
m_Function();
m_InternalTime %= m_Interval;
}
m_LastTime = getTime();
}
void Timer::reset(){
m_InternalTime = 0;
m_LastTime = getTime();
}
std::uint64_t getTime(){
return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock().now().time_since_epoch()).count();
}
} // namespace utils
} // namespace td