mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-08 17:57:02 +08:00
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:
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user