Cleaning up and sorting out how to use the new events best.

This commit is contained in:
Zed A. Shaw 2024-10-29 23:39:03 -04:00
parent 04350cb51e
commit 2fdbd63f4c
4 changed files with 38 additions and 32 deletions

View file

@ -16,7 +16,7 @@ void SoundManager::load(const std::string name, const std::string sound_path) {
dbc::check(fs::exists(full_path), format("sound file {} does not exist", sound_path));
// create the buffer and keep in the buffer map
SoundPair *pair = new SoundPair();
std::shared_ptr<SoundPair> pair = std::make_shared<SoundPair>();
$sounds[name] = pair;
bool good = pair->buffer.loadFromFile(full_path.string());
@ -31,13 +31,13 @@ void SoundManager::load(const std::string name, const std::string sound_path) {
void SoundManager::play(const std::string name) {
dbc::check($sounds.contains(name), format("sound {} is not loaded in map", name));
// get the sound from the sound map
SoundPair *pair = $sounds.at(name);
auto pair = $sounds.at(name);
// play it
pair->sound.play();
}
void SoundManager::playAt(const std::string name, float x, float y, float z) {
SoundPair *pair = $sounds.at(name);
auto pair = $sounds.at(name);
pair->sound.setPosition(x, y, z);
pair->sound.play();
}