aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/system/AudioSystem.h
diff options
context:
space:
mode:
authorJAROWMR <jarorutjes07@gmail.com>2024-12-12 15:05:33 +0100
committerJAROWMR <jarorutjes07@gmail.com>2024-12-12 15:05:33 +0100
commit641e202607b0f694df6662532f0165022c0f8621 (patch)
tree0701bbfe705a95b670c8dfcb5eaabf6007556831 /src/crepe/system/AudioSystem.h
parentdd7d5cf6b01b8a6a4238b66c27861ee76522067e (diff)
parent05a33d4793520fa84a93bc79882ef29d39cd08e5 (diff)
merge master
Diffstat (limited to 'src/crepe/system/AudioSystem.h')
-rw-r--r--src/crepe/system/AudioSystem.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/crepe/system/AudioSystem.h b/src/crepe/system/AudioSystem.h
new file mode 100644
index 0000000..2ddc443
--- /dev/null
+++ b/src/crepe/system/AudioSystem.h
@@ -0,0 +1,51 @@
+#pragma once
+
+#include "../api/AudioSource.h"
+#include "../facade/Sound.h"
+#include "../facade/SoundContext.h"
+
+#include "System.h"
+
+namespace crepe {
+
+class AudioSystem : public System {
+public:
+ using System::System;
+ void update() override;
+
+private:
+ /**
+ * \brief Update `last_*` members of \c component
+ *
+ * Copies all component properties stored for comparison between AudioSystem::update() calls
+ *
+ * \param component AudioSource component to update
+ */
+ void update_last(AudioSource & component);
+
+ /**
+ * \brief Compare update component
+ *
+ * Compares properties of \c component and \c data, and calls SoundContext functions where
+ * applicable.
+ *
+ * \param component AudioSource component to update
+ * \param resource Sound instance for AudioSource's Asset
+ */
+ void diff_update(AudioSource & component, Sound & resource);
+
+protected:
+ /**
+ * \brief Get SoundContext
+ *
+ * SoundContext is retrieved through this function instead of being a direct member of
+ * AudioSystem to aid with testability.
+ */
+ virtual SoundContext & get_context();
+
+private:
+ //! SoundContext
+ std::unique_ptr<SoundContext> context = nullptr;
+};
+
+} // namespace crepe