2
0

AudioComponent.h 859 B

12345678910111213141516171819202122232425262728293031
  1. // ----------------------------------------------------------------
  2. // From Game Programming in C++ by Sanjay Madhav
  3. // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
  4. //
  5. // Released under the BSD License
  6. // See LICENSE in root directory for full details.
  7. // ----------------------------------------------------------------
  8. #pragma once
  9. #include "Component.h"
  10. #include "SoundEvent.h"
  11. #include <vector>
  12. #include <string>
  13. class AudioComponent : public Component
  14. {
  15. public:
  16. AudioComponent(class Actor* owner, int updateOrder = 200);
  17. ~AudioComponent();
  18. void Update(float deltaTime) override;
  19. void OnUpdateWorldTransform() override;
  20. SoundEvent PlayEvent(const std::string& name);
  21. void StopAllEvents();
  22. TypeID GetType() const override { return TAudioComponent; }
  23. private:
  24. std::vector<SoundEvent> mEvents2D;
  25. std::vector<SoundEvent> mEvents3D;
  26. };