From fb9e5710b15729eaf172bd104aa88aeaedf3f2c2 Mon Sep 17 00:00:00 2001 From: Askou Date: Mon, 7 Jun 2021 11:46:27 +0200 Subject: [PATCH] replace music system by sound system --- .../System/Music/PlayerMusicManagerSystem.cpp | 26 ------------------- .../System/Sound/PlayerSoundManagerSystem.cpp | 26 +++++++++++++++++++ .../PlayerSoundManagerSystem.hpp} | 14 +++++----- 3 files changed, 33 insertions(+), 33 deletions(-) delete mode 100644 sources/System/Music/PlayerMusicManagerSystem.cpp create mode 100644 sources/System/Sound/PlayerSoundManagerSystem.cpp rename sources/System/{Music/PlayerMusicManagerSystem.hpp => Sound/PlayerSoundManagerSystem.hpp} (53%) diff --git a/sources/System/Music/PlayerMusicManagerSystem.cpp b/sources/System/Music/PlayerMusicManagerSystem.cpp deleted file mode 100644 index 2d46b5ff..00000000 --- a/sources/System/Music/PlayerMusicManagerSystem.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// -// Created by Tom Augier on 05/06/2021 -// - -#include "PlayerMusicManagerSystem.hpp" - -namespace BBM { - - void MusicManagerSystem::onFixedUpdate(WAL::Entity &entity) - { - if (!entity.hasComponent()) - return; - const auto &controllable = entity.getComponent(); - auto &music = entity.getComponent(); - auto &health = entity.getComponent(); - - music.setIndex(MusicComponent::BOMB); - controllable.bomb ? music.loadMusic() : music.unloadMusic(); - music.setIndex(MusicComponent::JUMP); - controllable.jump ? music.loadMusic() : music.unloadMusic(); - music.setIndex(MusicComponent::MOVE); - (controllable.move.x != 0 || controllable.move.y != 0) ? music.loadMusic() : music.unloadMusic(); - music.setIndex(MusicComponent::DEATH); - health.getHealthPoint() == 0 ? music.loadMusic() : music.unloadMusic(); - } -} \ No newline at end of file diff --git a/sources/System/Sound/PlayerSoundManagerSystem.cpp b/sources/System/Sound/PlayerSoundManagerSystem.cpp new file mode 100644 index 00000000..512a5603 --- /dev/null +++ b/sources/System/Sound/PlayerSoundManagerSystem.cpp @@ -0,0 +1,26 @@ +// +// Created by Tom Augier on 05/06/2021 +// + +#include "PlayerSoundManagerSystem.hpp" + +namespace BBM { + + void SoundManagerSystem::onFixedUpdate(WAL::Entity &entity) + { + if (!entity.hasComponent()) + return; + const auto &controllable = entity.getComponent(); + auto &sound = entity.getComponent(); + auto &health = entity.getComponent(); + + sound.setIndex(SoundComponent::BOMB); + controllable.bomb ? sound.loadSound() : sound.unloadSound(); + sound.setIndex(SoundComponent::JUMP); + controllable.jump ? sound.loadSound() : sound.unloadSound(); + sound.setIndex(SoundComponent::MOVE); + (controllable.move.x != 0 || controllable.move.y != 0) ? sound.loadSound() : sound.unloadSound(); + sound.setIndex(SoundComponent::DEATH); + health.getHealthPoint() == 0 ? sound.loadSound() : sound.unloadSound(); + } +} \ No newline at end of file diff --git a/sources/System/Music/PlayerMusicManagerSystem.hpp b/sources/System/Sound/PlayerSoundManagerSystem.hpp similarity index 53% rename from sources/System/Music/PlayerMusicManagerSystem.hpp rename to sources/System/Sound/PlayerSoundManagerSystem.hpp index 7038549a..aff694c2 100644 --- a/sources/System/Music/PlayerMusicManagerSystem.hpp +++ b/sources/System/Sound/PlayerSoundManagerSystem.hpp @@ -6,26 +6,26 @@ #include "System/System.hpp" #include "Window.hpp" -#include "Component/Music/MusicComponent.hpp" +#include "Component/Sound/SoundComponent.hpp" #include "Component/Health/HealthComponent.hpp" #include #include "Wal.hpp" namespace BBM { - class MusicManagerSystem : public WAL::System + class SoundManagerSystem : public WAL::System { public: //! @inherit void onFixedUpdate(WAL::Entity &entity) override; //! @brief ctor - MusicManagerSystem(WAL::Wal &wal, RAY::Window &window); + SoundManagerSystem(WAL::Wal &wal, RAY::Window &window); //! @brief Default copy ctor - MusicManagerSystem(const MusicManagerSystem &) = default; + SoundManagerSystem(const SoundManagerSystem &) = default; //! @brief Default dtor - ~MusicManagerSystem() override = default; - //! @brief A MusicManager screen system can't be assigned. - MusicManagerSystem &operator=(const MusicManagerSystem &) = delete; + ~SoundManagerSystem() override = default; + //! @brief A SoundManager screen system can't be assigned. + SoundManagerSystem &operator=(const SoundManagerSystem &) = delete; }; }