pupush
This commit is contained in:
31
src/td/game/World.cpp
Normal file
31
src/td/game/World.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#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
|
||||
Reference in New Issue
Block a user