add StateMachine
This commit is contained in:
@@ -20,7 +20,6 @@ ClientSimulation::ClientSimulation(game::World& a_World, GameHistory&& a_History
|
||||
m_StepTime(a_StepTime),
|
||||
m_World(a_World),
|
||||
m_CurrentTime(0),
|
||||
m_LastTime(GetTime()),
|
||||
m_CurrentStep(0),
|
||||
m_LastSnapshot(std::make_shared<WorldSnapshot>()),
|
||||
m_LastValidStep(0) {
|
||||
@@ -36,20 +35,19 @@ ClientSimulation::ClientSimulation(game::World& a_World, std::uint64_t a_StepTim
|
||||
m_World(a_World),
|
||||
m_History(std::numeric_limits<StepTime>::max()),
|
||||
m_CurrentTime(0),
|
||||
m_LastTime(GetTime()),
|
||||
m_CurrentStep(0),
|
||||
m_LastSnapshot(std::make_shared<WorldSnapshot>()),
|
||||
m_LastValidStep(0) {}
|
||||
|
||||
float ClientSimulation::Update() {
|
||||
float ClientSimulation::Update(float a_Delta) {
|
||||
// TODO: handle freezes (m_CurrentTime > 2 * m_StepTime)
|
||||
m_CurrentTime += GetTime() - m_LastTime;
|
||||
m_LastTime = GetTime();
|
||||
if (m_CurrentTime > m_StepTime) {
|
||||
static const float stepTimeSecond = static_cast<float>(STEP_TIME) / 1000.0f;
|
||||
m_CurrentTime += a_Delta;
|
||||
if (m_CurrentTime > stepTimeSecond) {
|
||||
m_CurrentTime = std::fmod(m_CurrentTime, stepTimeSecond);
|
||||
Step();
|
||||
m_CurrentTime %= m_StepTime;
|
||||
}
|
||||
return (float)m_CurrentTime / (float)m_StepTime;
|
||||
return (float)m_CurrentTime / stepTimeSecond;
|
||||
}
|
||||
|
||||
bool ClientSimulation::Step() {
|
||||
|
||||
Reference in New Issue
Block a user