AudioSystemComponent.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <AzCore/Component/Component.h>
  10. #include <LmbrCentral/Audio/AudioSystemComponentBus.h>
  11. #include <AzFramework/API/ApplicationAPI.h>
  12. namespace LmbrCentral
  13. {
  14. /*!
  15. * AudioSystemComponent
  16. * Handles requests of a global context for the audio system.
  17. * The requests are not tied to an AZ::Entity.
  18. */
  19. class AudioSystemComponent
  20. : public AZ::Component
  21. , protected AudioSystemComponentRequestBus::Handler
  22. , protected AzFramework::LevelSystemLifecycleNotificationBus::Handler
  23. {
  24. public:
  25. AZ_COMPONENT(AudioSystemComponent, "{666E28D2-FC99-4D41-861D-3758C5070653}");
  26. static void Reflect(AZ::ReflectContext* context);
  27. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  28. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  29. AudioSystemComponent() = default;
  30. ~AudioSystemComponent() override = default;
  31. protected:
  32. ////////////////////////////////////////////////////////////////////////
  33. // AZ::Component interface implementation
  34. void Init() override;
  35. void Activate() override;
  36. void Deactivate() override;
  37. ////////////////////////////////////////////////////////////////////////
  38. ////////////////////////////////////////////////////////////////////////
  39. // AudioSystemComponentRequestBus::Handler interface implementation
  40. bool IsAudioSystemInitialized() override;
  41. void GlobalStopAllSounds() override;
  42. void GlobalMuteAudio() override;
  43. void GlobalUnmuteAudio() override;
  44. void GlobalRefreshAudio(AZStd::string_view levelName) override;
  45. void GlobalExecuteAudioTrigger(const char* triggerName, AZ::EntityId callbackOwnerEntityId) override;
  46. void GlobalKillAudioTrigger(const char* triggerName, AZ::EntityId callbackOwnerEntityId) override;
  47. void GlobalSetAudioRtpc(const char* rtpcName, float value) override;
  48. void GlobalResetAudioRtpcs() override;
  49. void GlobalSetAudioSwitchState(const char* switchName, const char* stateName) override;
  50. void LevelLoadAudio(AZStd::string_view levelName) override;
  51. void LevelUnloadAudio() override;
  52. ////////////////////////////////////////////////////////////////////////
  53. // AzFramework::LevelSystemLifecycleNotificationBus::Handler implementation
  54. void OnLoadingStart(const char* levelName) override;
  55. void OnUnloadComplete(const char* levelName) override;
  56. };
  57. } // namespace LmbrCentral