too many things

This commit is contained in:
2025-07-18 13:11:18 +02:00
parent b788caafa6
commit 6d0e56eb46
26 changed files with 529 additions and 191 deletions

View File

@@ -0,0 +1,32 @@
#include <td/simulation/RealTimeSimulation.h>
#include <chrono>
namespace td {
namespace sim {
std::uint64_t GetTime() {
return static_cast<std::uint64_t>(
std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock().now().time_since_epoch()).count());
}
RealTimeSimulation::RealTimeSimulation(game::World& a_World, GameHistory&& a_History, std::uint64_t a_StepTime) :
m_StepTime(a_StepTime),
m_World(a_World),
m_History(std::move(a_History)),
m_CurrentTime(0),
m_LastTime(GetTime()),
m_CurrentStep(0) {}
void RealTimeSimulation::Update() {
m_CurrentTime += GetTime() - m_LastTime;
m_LastTime = GetTime();
if (m_CurrentTime > m_StepTime) {
m_World.Tick(m_History[m_CurrentStep], FpFloat(m_StepTime) / FpFloat(1000));
m_CurrentStep++;
m_CurrentTime -= m_StepTime;
}
}
} // namespace sim
} // namespace td