From 4b0bc220e4da1173f742a4973939b139bef562db Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Fri, 21 Jul 2023 00:58:49 +1000 Subject: Support for changing the game's timescale Context-specific (like per-world) timescales can also be added later --- source/game/StarToolUser.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'source/game/StarToolUser.cpp') diff --git a/source/game/StarToolUser.cpp b/source/game/StarToolUser.cpp index 6c0cdf2..e0e32a8 100644 --- a/source/game/StarToolUser.cpp +++ b/source/game/StarToolUser.cpp @@ -38,10 +38,11 @@ ToolUser::ToolUser() addNetElement(&m_primaryItemActiveNetState); addNetElement(&m_altItemActiveNetState); - m_primaryFireTimerNetState.setFixedPointBase(WorldTimestep); - m_altFireTimerNetState.setFixedPointBase(WorldTimestep); - m_primaryTimeFiringNetState.setFixedPointBase(WorldTimestep); - m_altTimeFiringNetState.setFixedPointBase(WorldTimestep); + float fixedPointBase = 1.f / 60.f; + m_primaryFireTimerNetState.setFixedPointBase(fixedPointBase); + m_altFireTimerNetState.setFixedPointBase(fixedPointBase); + m_primaryTimeFiringNetState.setFixedPointBase(fixedPointBase); + m_altTimeFiringNetState.setFixedPointBase(fixedPointBase); auto interpolateTimer = [](double offset, double min, double max) -> double { if (max > min) @@ -369,7 +370,7 @@ bool ToolUser::queryShieldHit(DamageSource const& source) const { return false; } -void ToolUser::tick(bool shifting, HashSet const& moves) { +void ToolUser::tick(float dt, bool shifting, HashSet const& moves) { if (auto toolUserItem = as(m_primaryHandItem.get())) { FireMode fireMode = FireMode::None; if (!m_suppress.get()) { @@ -378,7 +379,7 @@ void ToolUser::tick(bool shifting, HashSet const& moves) { else if (m_fireAlt && m_primaryHandItem.get()->twoHanded()) fireMode = FireMode::Alt; } - toolUserItem->update(fireMode, shifting, moves); + toolUserItem->update(dt, fireMode, shifting, moves); } if (!m_primaryHandItem.get() || !m_primaryHandItem.get()->twoHanded()) { @@ -386,7 +387,7 @@ void ToolUser::tick(bool shifting, HashSet const& moves) { FireMode fireMode = FireMode::None; if (!m_suppress.get() && m_fireAlt) fireMode = FireMode::Primary; - toolUserItem->update(fireMode, shifting, moves); + toolUserItem->update(dt, fireMode, shifting, moves); } } -- cgit v1.2.3