// // Created by Tom Augier on 05/06/2021 // #include "PlayerSoundManagerSystem.hpp" #include namespace BBM { PlayerSoundManagerSystem::PlayerSoundManagerSystem(WAL::Wal &wal) : System(wal) {} void PlayerSoundManagerSystem::onFixedUpdate(WAL::ViewEntity &entity) { const auto &controllable = entity.get(); auto &sound = entity.get(); auto &health = entity.get(); sound.setVolume(sound.volume); std::map soundIndex = { {health.getHealthPoint() <= 0, SoundComponent::DEATH}, {controllable.bomb, SoundComponent::BOMB}, {controllable.move.x != 0 || controllable.move.y != 0, SoundComponent::MOVE} }; for (auto &a : soundIndex) { if (a.first) { sound.setIndex(a.second); sound.playSound(); } } } }