123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- /*
- * Copyright (c) Contributors to the Open 3D Engine Project.
- * For complete copyright and license terms please see the LICENSE at the root of this distribution.
- *
- * SPDX-License-Identifier: Apache-2.0 OR MIT
- *
- */
- #pragma once
- #include <AzCore/Component/Component.h>
- #include <AzFramework/API/ApplicationAPI.h>
- #include <IAudioSystem.h>
- #if defined(AUDIO_SYSTEM_EDITOR)
- #include <AzCore/std/smart_ptr/unique_ptr.h>
- #include <Include/IPlugin.h>
- #include <AzToolsFramework/API/ToolsApplicationAPI.h>
- #include <Atom/RPI.Public/ViewportContextBus.h>
- #endif // AUDIO_SYSTEM_EDITOR
- namespace AudioSystemGem
- {
- class AudioSystemGemSystemComponent
- : public AZ::Component
- , protected AzFramework::LevelSystemLifecycleNotificationBus::Handler
- , protected AzFramework::ApplicationLifecycleEvents::Bus::Handler
- , protected Audio::Gem::SystemRequestBus::Handler
- #if defined(AUDIO_SYSTEM_EDITOR)
- , private AzToolsFramework::EditorEvents::Bus::Handler
- , public AZ::RPI::ViewportContextNotificationBus::Handler
- #endif // AUDIO_SYSTEM_EDITOR
- {
- public:
- AZ_COMPONENT(AudioSystemGemSystemComponent, "{55095EE9-38E6-485F-8314-DF35CDFECC6B}", AZ::Component);
- static void Reflect(AZ::ReflectContext* context);
- static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
- static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
- static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
- static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
- AudioSystemGemSystemComponent();
- ~AudioSystemGemSystemComponent() override;
- protected:
- ////////////////////////////////////////////////////////////////////////
- // AZ::Component interface implementation
- void Init() override;
- void Activate() override;
- void Deactivate() override;
- ////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////
- // Audio::Gem::SystemRequestBus interface implementation
- bool Initialize() override;
- void Release() override;
- ////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////
- // AzFramework::LevelSystemLifecycleNotifications interface implementation
- void OnLoadingStart(const char* levelName) override;
- void OnUnloadComplete(const char* levelName) override;
- ////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////
- // AzFramework::ApplicationLifecycleEvents interface implementation
- void OnApplicationConstrained(Event /*lastEvent*/) override;
- void OnApplicationUnconstrained(Event /*lastEvent*/) override;
- ////////////////////////////////////////////////////////////////////////
- #if defined(AUDIO_SYSTEM_EDITOR)
- ////////////////////////////////////////////////////////////////////////
- // AzToolsFramework::EditorEvents::Bus interface implementation
- void NotifyRegisterViews() override;
- void NotifyIEditorAvailable(IEditor*) override;
- ////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////
- // AZ::RPI::ViewportContextNotificationBus::Handler interface implementation
- void OnViewportDefaultViewChanged(AZ::RPI::ViewPtr view) override;
- ////////////////////////////////////////////////////////////////////////
- #endif // AUDIO_SYSTEM_EDITOR
- private:
- ////////////////////////////////////////////////////////////////////////
- void CreateAudioSystem();
- void PrepareAudioSystem();
- /// This is here to express ownership
- AZStd::unique_ptr<Audio::IAudioSystem> m_audioSystem;
- #if defined(AUDIO_SYSTEM_EDITOR)
- AZStd::unique_ptr<IPlugin> m_editorPlugin;
- AZ::RPI::MatrixChangedEvent::Handler m_cameraTransformHandler;
- #endif // AUDIO_SYSTEM_EDITOR
- };
- } // namespace AudioSystemGem
|