mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-18 15:49:18 +02:00
WIP
This commit is contained in:
26
entitysystem/systems/SoundSystem.cpp
Normal file
26
entitysystem/systems/SoundSystem.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "stdafx.h"
|
||||
#include "SoundSystem.h"
|
||||
|
||||
#include "entitysystem/ECWorld.h"
|
||||
#include "entitysystem/components/BasicComponents.h"
|
||||
|
||||
void SoundSystem::Update(ECWorld& world, float dt)
|
||||
{
|
||||
world.Each<ECSComponent::SoundComponent, ECSComponent::Transform>(
|
||||
entt::exclude<ECSComponent::Disabled>,
|
||||
[](entt::entity,
|
||||
ECSComponent::SoundComponent& sc,
|
||||
ECSComponent::Transform& transform)
|
||||
{
|
||||
sc.sound.offset( glm::vec3( transform.Position ) );
|
||||
sc.sound.gain( sc.volume );
|
||||
sc.sound.pitch( sc.pitch );
|
||||
|
||||
if (sc.isPlaying && !sc.sound.is_playing()) {
|
||||
int flags = sc.loop ? sound_flags::looping : 0;
|
||||
sc.sound.play( flags );
|
||||
} else if (!sc.isPlaying && sc.sound.is_playing()) {
|
||||
sc.sound.stop();
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user