32 lines
704 B
C++
32 lines
704 B
C++
#include <td/game/World.h>
|
|
|
|
#include <td/Constants.h>
|
|
|
|
#include <limits>
|
|
|
|
namespace td {
|
|
namespace game {
|
|
|
|
World::World() : m_WorldStates(std::numeric_limits<StepsType>::max()), m_OffsetTime(0) {}
|
|
|
|
void World::Tick(float a_Delta) {
|
|
m_OffsetTime += a_Delta;
|
|
|
|
if (GetCursorPos() > m_WorldStates.size()) {
|
|
if (!m_GameHistory.HasLockStep(GetCursorPos())) {
|
|
// oupsi
|
|
return;
|
|
}
|
|
WorldState& lastState = m_WorldStates.back();
|
|
WorldState nextState = lastState.GetNextState(m_GameHistory.GetLockStep(GetCursorPos()));
|
|
m_WorldStates.push_back(std::move(nextState));
|
|
}
|
|
}
|
|
|
|
std::uint16_t World::GetCursorPos() {
|
|
return (std::uint16_t) m_OffsetTime * TPS;
|
|
}
|
|
|
|
} // namespace game
|
|
} // namespace td
|