Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Client/Systems/Events/EventsSystems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ namespace Systems {
}

const std::size_t waitTimeBullet = 500;
const std::string soundPathShoot = "assets/Audio/Sounds/laser.ogg";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The soundPathShoot constant is defined within the playerShootBullet function. If this sound path is used elsewhere in the code, consider moving it to a more global scope to avoid duplication.


void playerShootBullet(std::size_t /*unused*/, std::size_t /*unused*/)
{
Expand All @@ -73,6 +74,7 @@ namespace Systems {
Registry::components<struct health_s> arrHealth = registry.getComponents<struct health_s>();
Clock &clock_ = registry.getClock();
static std::size_t clockId = clock_.create(true);
Registry::components<Raylib::Sound> arrSounds = registry.getComponents<Raylib::Sound>();
std::vector<std::size_t> ids =
registry.getEntitiesByComponents({typeid(Types::Player), typeid(Types::Position)});

Expand All @@ -81,6 +83,12 @@ namespace Systems {
return;
}

for (auto &sound : arrSounds) {
if (sound.getPath() == soundPathShoot) {
sound.setNeedToPlay(true);
}
}

for (auto &id : ids) {
// send bullet to server
if (arrHealth.exist(id) && arrHealth[id].hp <= 0) {
Expand Down
6 changes: 0 additions & 6 deletions src/Client/Systems/Graphic/AudioSystems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,12 @@ namespace Systems {
std::lock_guard<std::mutex> lock(Registry::getInstance().mutex);
Registry &registry = Registry::getInstance();
Registry::components<Raylib::Music> arrMusics = registry.getComponents<Raylib::Music>();
Registry::components<Raylib::Sound> arrSounds = registry.getComponents<Raylib::Sound>();

for (auto &music : arrMusics) {
if (music.getPath() == musicPath && Raylib::isKeyPressed(Raylib::KeyboardKey::KB_M)) {
music.setNeedToPlay(true);
}
}
for (auto &sound : arrSounds) {
if (sound.getPath() == soundPathShoot && Raylib::isKeyPressed(Raylib::KeyboardKey::KB_SPACE)) {
sound.setNeedToPlay(true);
}
}
}

void GraphicSystems::initAudio(std::size_t managerId, std::size_t systemId)
Expand Down