Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
11 changes: 9 additions & 2 deletions src/Client/Systems/Events/EventsSystems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,16 @@ namespace Systems {
}
}

const std::size_t waitTimeBullet = 500;

void playerShootBullet(std::size_t /*unused*/, std::size_t /*unused*/)
{
static const std::size_t waitTimeBullet = 500;
static const std::string soundPathShoot = "assets/Audio/Sounds/laser.ogg";
Registry &registry = Registry::getInstance();
Registry::components<Types::Position> arrPosition = registry.getComponents<Types::Position>();
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 +82,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