aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/system/AudioSystem.h
blob: 7f41fdaf388803400bd938764750ecacaad51836 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#pragma once

#include "../facade/SoundContext.h"
#include "../api/AudioSource.h"

#include "System.h"

namespace crepe {

class AudioSystem : public System {
public:
	using System::System;
	void update() override;

private:
	/**
	 * \brief Private data stored by AudioSystem on AudioSource component
	 */
	struct ComponentPrivate {
		//! This sample's voice handle
		SoLoud::handle handle;

		//! Value of \c active after last system update
		bool last_active = false;
		//! Value of \c playing after last system update
		bool last_playing = false;
		//! Value of \c volume after last system update
		float last_volume = 1.0;
		//! Value of \c loop after last system update
		bool last_loop = false;
	};

	void update_private(const AudioSource & component, ComponentPrivate & data);

private:
	SoundContext context {};
};

} // namespace crepe