diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-02 16:13:08 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-12-02 16:13:08 +0100 |
commit | 7a8657dfe019104aced61a5b63e63f61ad919f7a (patch) | |
tree | fd8e7aa148aac0a4f50fca8fe05e5016dfd16e47 /src/crepe/system/AudioSystem.cpp | |
parent | b8194e02679dc88f5c0a240da83a4700ec5200cf (diff) |
remove `Private`
Diffstat (limited to 'src/crepe/system/AudioSystem.cpp')
-rw-r--r-- | src/crepe/system/AudioSystem.cpp | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/src/crepe/system/AudioSystem.cpp b/src/crepe/system/AudioSystem.cpp index 26913c0..c1cde8b 100644 --- a/src/crepe/system/AudioSystem.cpp +++ b/src/crepe/system/AudioSystem.cpp @@ -16,56 +16,50 @@ void AudioSystem::update() { for (AudioSource & component : components) { Sound & resource = resource_manager.get<Sound>(component.source); - if (component.private_data.empty()) { - auto & data = component.private_data.set<ComponentPrivate>(); - this->update_last(component, data); - data.last_active = false; - } - auto & data = component.private_data.get<ComponentPrivate>(); - - this->diff_update(component, data, resource); + this->diff_update(component, resource); - this->update_last(component, data); + this->update_last(component); } } -void AudioSystem::diff_update(AudioSource & component, ComponentPrivate & data, - Sound & resource) { +void AudioSystem::diff_update(AudioSource & component, Sound & resource) { SoundContext & context = this->get_context(); - if (component.active != data.last_active) { + if (component.active != component.last_active) { if (component.active) { component.oneshot_play = component.play_on_awake; } else { - context.stop(data.handle); + context.stop(component.voice); return; } } if (!component.active) return; if (component.oneshot_play) { - data.handle = context.play(resource); + component.voice = context.play(resource); component.oneshot_play = false; } if (component.oneshot_stop) { - context.stop(data.handle); + context.stop(component.voice); component.oneshot_stop = false; } - if (component.volume != data.last_volume) { - context.set_volume(data.handle, component.volume); + if (component.volume != component.last_volume) { + context.set_volume(component.voice, component.volume); } - if (component.loop != data.last_loop) { - context.set_loop(data.handle, component.loop); + if (component.loop != component.last_loop) { + context.set_loop(component.voice, component.loop); } } -void AudioSystem::update_last(const AudioSource & component, ComponentPrivate & data) { - data.last_active = component.active; - data.last_loop = component.loop; - data.last_volume = component.volume; +void AudioSystem::update_last(AudioSource & component) { + component.last_active = component.active; + component.last_loop = component.loop; + component.last_volume = component.volume; } SoundContext & AudioSystem::get_context() { - if (this->context.empty()) this->context.set<SoundContext>(); - return this->context.get<SoundContext>(); + if (this->context == nullptr) + this->context = make_unique<SoundContext>(); + return *this->context.get(); } + |