InputConfigurationComponent.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 <AzCore/Asset/AssetCommon.h>
  11. #include <AzFramework/Components/EditorEntityEvents.h>
  12. #include <StartingPointInput/InputEventRequestBus.h>
  13. #include <InputEventBindings.h>
  14. namespace AZ
  15. {
  16. class SerializeContext;
  17. }
  18. namespace StartingPointInput
  19. {
  20. class InputConfigurationComponent
  21. : public AZ::Component
  22. , private AZ::Data::AssetBus::Handler
  23. , private InputConfigurationComponentRequestBus::Handler
  24. , public AzFramework::EditorEntityEvents
  25. {
  26. public:
  27. AZ_COMPONENT(InputConfigurationComponent, "{3106EE2A-4816-433E-B855-D17A6484D5EC}", AzFramework::EditorEntityEvents);
  28. virtual ~InputConfigurationComponent();
  29. InputConfigurationComponent();
  30. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  31. static void Reflect(AZ::ReflectContext* reflection);
  32. //////////////////////////////////////////////////////////////////////////
  33. // AZ::Component
  34. void Init() override;
  35. void Activate() override;
  36. void Deactivate() override;
  37. //////////////////////////////////////////////////////////////////////////
  38. //////////////////////////////////////////////////////////////////////////
  39. /// AzFramework::EditorEntityEvents
  40. void EditorSetPrimaryAsset(const AZ::Data::AssetId& assetId) override;
  41. //////////////////////////////////////////////////////////////////////////
  42. private:
  43. InputConfigurationComponent(const InputConfigurationComponent&) = delete;
  44. //////////////////////////////////////////////////////////////////////////
  45. // AZ::InputConfigurationComponentRequestBus::Handler
  46. void SetLocalUserId(AzFramework::LocalUserId localUserId) override;
  47. //////////////////////////////////////////////////////////////////////////
  48. //////////////////////////////////////////////////////////////////////////
  49. /// AZ::Data::AssetBus::Handler
  50. void OnAssetReady(AZ::Data::Asset<AZ::Data::AssetData> asset) override;
  51. void OnAssetReloaded(AZ::Data::Asset<AZ::Data::AssetData> asset) override;
  52. //////////////////////////////////////////////////////////////////////////
  53. void ActivateBindingsIfAppropriate();
  54. //////////////////////////////////////////////////////////////////////////
  55. // Reflected Data
  56. InputEventBindings m_inputEventBindings;
  57. AZStd::vector<AZStd::string> m_inputContexts;
  58. AZ::Data::Asset<InputEventBindingsAsset> m_inputEventBindingsAsset;
  59. AZ::s32 m_localPlayerIndex = -1;
  60. AzFramework::LocalUserId m_localUserId = AzFramework::LocalUserIdAny;
  61. bool m_isContextActive = false;
  62. // Unlike the definition of most assets, the input asset requires additional preparation after its loaded
  63. // in order to actually be prepared to be used.
  64. bool m_isAssetPrepared = false;
  65. AZ::Uuid m_uuid;
  66. };
  67. } // namespace Input