refactor(game_time): introduce Timer for time-based updates and rename existing to TickTimer

Add a new `Timer` class that operates in seconds (using `TimeType`) alongside the existing `TickTimer` which uses `TickType`. Rename the original `Timer` to `TickTimer` throughout the codebase. Update `ClientWorld` to maintain separate maps for tick-based and time-based timers, and replace the hardcoded footstep timer in `ClientPlayer` with a time-based callback timer. Also add `play_2d` to `AudioEngine` and load an ambient bird sound to demonstrate the new timer functionality.
This commit is contained in:
2026-07-07 15:32:07 +08:00
parent 7eebed40e0
commit 6b3872dc97
10 changed files with 138 additions and 51 deletions

View File

@@ -89,6 +89,29 @@ void AudioEngine::play_3d(const std::string& sound, const glm::vec3& pos,
} catch (const std::exception& e) {
if (check) {
ASSERT_MSG(false, e.what());
Logger::error("Player Sound Error {}", e.what());
}
}
}
void AudioEngine::play_2d(const std::string& sound, bool check) {
if (!m_pool) {
Logger::error("Source Pool is nullptr");
return;
}
auto* source = m_pool->acquire();
source->set_volume(m_sfx_volume);
if (!source) {
Logger::error("Source is Full");
}
try {
auto& buffer = m_sounds.get_buffer(sound);
source->play_2d(buffer);
} catch (const std::exception& e) {
if (check) {
ASSERT_MSG(false, e.what());
Logger::error("Player Sound Error {}", e.what());
}
}
}