diff options
| author | untodesu <kirill@untode.su> | 2025-07-01 03:08:39 +0500 |
|---|---|---|
| committer | untodesu <kirill@untode.su> | 2025-07-01 03:08:39 +0500 |
| commit | 458e0005690ea9d579588a0a12368fc2c2c9a93a (patch) | |
| tree | 588a9ca6cb3c76d9193b5bd4601d64f0e50e8c8c /src/game/client/sound_emitter.cc | |
| parent | c7b0c8e0286a1b2bb7ec55e579137dfc3b22eeb9 (diff) | |
| download | voxelius-458e0005690ea9d579588a0a12368fc2c2c9a93a.tar.bz2 voxelius-458e0005690ea9d579588a0a12368fc2c2c9a93a.zip | |
I hyper-focued on refactoring again
- I put a cool-sounding "we are number one" remix on repeat and straight
up grinded the entire repository to a better state until 03:09 AM. I
guess I have something wrong in my brain that makes me do this shit
Diffstat (limited to 'src/game/client/sound_emitter.cc')
| -rw-r--r-- | src/game/client/sound_emitter.cc | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/src/game/client/sound_emitter.cc b/src/game/client/sound_emitter.cc deleted file mode 100644 index 9b84df2..0000000 --- a/src/game/client/sound_emitter.cc +++ /dev/null @@ -1,58 +0,0 @@ -#include "client/pch.hh" - -#include "client/sound_emitter.hh" - -#include "core/config.hh" -#include "core/constexpr.hh" - -#include "shared/coord.hh" -#include "shared/dimension.hh" -#include "shared/transform.hh" -#include "shared/velocity.hh" - -#include "client/camera.hh" -#include "client/globals.hh" -#include "client/sound.hh" - -SoundEmitterComponent::SoundEmitterComponent(void) -{ - alGenSources(1, &source); - sound = nullptr; -} - -SoundEmitterComponent::~SoundEmitterComponent(void) -{ - alSourceStop(source); - alDeleteSources(1, &source); -} - -void SoundEmitterComponent::update(void) -{ - if(globals::dimension) { - const auto view = globals::dimension->entities.view<SoundEmitterComponent>(); - - const auto& pivot = camera::position_chunk; - const auto gain = vx::clamp(sound::volume_effects.get_value() * 0.01f, 0.0f, 1.0f); - - for(const auto [entity, emitter] : view.each()) { - alSourcef(emitter.source, AL_GAIN, gain); - - if(const auto transform = globals::dimension->entities.try_get<TransformComponentIntr>(entity)) { - auto position = coord::to_relative(pivot, transform->chunk, transform->local); - alSource3f(emitter.source, AL_POSITION, position.x, position.y, position.z); - } - - if(const auto velocity = globals::dimension->entities.try_get<VelocityComponent>(entity)) { - alSource3f(emitter.source, AL_VELOCITY, velocity->value.x, velocity->value.y, velocity->value.z); - } - - ALint source_state; - alGetSourcei(emitter.source, AL_SOURCE_STATE, &source_state); - - if(source_state == AL_STOPPED) { - alSourceRewind(emitter.source); - emitter.sound = nullptr; - } - } - } -} |
