feat: add basic tower mecanic

This commit is contained in:
2021-09-28 19:19:54 +02:00
parent 26d1dd9d36
commit 1e35146c4b
8 changed files with 104 additions and 26 deletions

View File

@@ -4,7 +4,7 @@
namespace td {
namespace utils {
void Timer::update() {
void AutoTimer::update() {
m_InternalTime += getTime() - m_LastTime;
if (m_InternalTime >= m_Interval) {
if (m_Function != nullptr)
@@ -14,7 +14,7 @@ void Timer::update() {
m_LastTime = getTime();
}
void Timer::update(std::uint64_t delta) {
void AutoTimer::update(std::uint64_t delta) {
m_InternalTime += delta;
if (m_InternalTime >= m_Interval) {
if (m_Function != nullptr)
@@ -24,11 +24,24 @@ void Timer::update(std::uint64_t delta) {
m_LastTime = getTime();
}
void Timer::reset() {
void AutoTimer::reset() {
m_InternalTime = 0;
m_LastTime = getTime();
}
bool Timer::update(std::uint64_t delta){
m_InternalTime += delta;
if (m_InternalTime >= m_Interval) {
m_InternalTime %= m_Interval;
return true;
}
return false;
}
void Timer::reset(){
m_InternalTime = 0;
}
std::uint64_t getTime() {
return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock().now().time_since_epoch()).count();
}