Files
o3de/Code/Framework/AzFramework/AzFramework/AzFrameworkModule.cpp
T
bosnichd 86ccf1c86e Input context component (#4152)
* Create a new InputContextComponent.

- An InputContextComponent is used to configure (at edit time) the data necessary to create an AzFrameowrk::InputContext (at run time). The lifecycle of any InputContextComponent is controlled by the AZ::Entity it is attached to (adhering to the same rules as any other AZ::Component), and the InputContext which it owns is created/destroyed when the component is activated/deactivated.

- The underlying AzFramework::InputContext and AzFramework::InputMapping* classes already exist, along with comprehensive unit tests (see Code/Framework/AzFramework/Tests/InputTests.cpp). All changes in this PR are simply to allow input contexts / input mappings to be defined/edited from the editor using data.

- The new InputContextComponent is similar in many respects to the InputConfigurationComponent found in the StartingPointInput Gem, the main difference being that the user-defined input mapping objects the new component creates are identical (from the perspective of any input consumer) to 'raw' engine-defined input channels (the existing AzFramework::InputMapping class inherits from the existing AzFramework::InputChannel class). This means that any system which consumes input (in either C++ or lua) can seamlessly interchange between obtaining input using either the 'raw' engine-defined input channels (eg. InputDeviceGamepad::Button::A, InputDeviceKeyboard::Key::AlphanumericA, etc.) or any user-defined input mapping, which can now be defined from the editor using data. Ultimately I would like to deprecate the StartingPointInput::InputConfigurationComponent in favour of this new InputContextComponent, which isn't realistic at present because the former is used pervasively throughout many different projects, and it integrates with ScriptCanvas in a way that I have yet to replicate, but this is a step towards the goal of a unified, engine-wide input context/input mapping solution that can be used interchangeably by any system, project, or Gem.

Signed-off-by: bosnichd <bosnichd@amazon.com>

* Edited some reflected property descriptions for clarity.

Signed-off-by: bosnichd <bosnichd@amazon.com>

* Fix clang builds:
- Add a missing virtual destructor.
- Fix the scope of two reflected property attribute functions.

Signed-off-by: bosnichd <bosnichd@amazon.com>

* Fix for InputContextComponent being reflected twice in some cirsumstances.

Signed-off-by: bosnichd <bosnichd@amazon.com>

* Updates in response to PR feedback.

Signed-off-by: bosnichd <bosnichd@amazon.com>

* More updates based on review feedback.

Signed-off-by: bosnichd <bosnichd@amazon.com>
2021-09-16 12:26:57 -06:00

73 lines
3.1 KiB
C++

/*
* 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
*
*/
#include <AzFramework/AzFrameworkModule.h>
// Component includes
#include <AzFramework/Asset/AssetCatalogComponent.h>
#include <AzFramework/Asset/CustomAssetTypeComponent.h>
#include <AzFramework/Asset/AssetSystemComponent.h>
#include <AzFramework/Components/TransformComponent.h>
#include <AzFramework/Components/NonUniformScaleComponent.h>
#include <AzFramework/Components/AzFrameworkConfigurationSystemComponent.h>
#include <AzFramework/Entity/GameEntityContextComponent.h>
#include <AzFramework/FileTag/FileTagComponent.h>
#include <AzFramework/Input/Contexts/InputContextComponent.h>
#include <AzFramework/Input/System/InputSystemComponent.h>
#include <AzFramework/Render/GameIntersectorComponent.h>
#include <AzFramework/Scene/SceneSystemComponent.h>
#include <AzFramework/Script/ScriptComponent.h>
#include <AzFramework/Script/ScriptRemoteDebugging.h>
#include <AzFramework/Spawnable/SpawnableSystemComponent.h>
#include <AzFramework/StreamingInstall/StreamingInstall.h>
#include <AzFramework/TargetManagement/TargetManagementComponent.h>
#include <AzFramework/Visibility/OctreeSystemComponent.h>
AZ_DEFINE_BUDGET(AzFramework);
namespace AzFramework
{
AzFrameworkModule::AzFrameworkModule()
: AZ::Module()
{
m_descriptors.insert(m_descriptors.end(), {
AzFramework::AssetCatalogComponent::CreateDescriptor(),
AzFramework::CustomAssetTypeComponent::CreateDescriptor(),
AzFramework::FileTag::ExcludeFileComponent::CreateDescriptor(),
AzFramework::TransformComponent::CreateDescriptor(),
AzFramework::NonUniformScaleComponent::CreateDescriptor(),
AzFramework::GameEntityContextComponent::CreateDescriptor(),
AzFramework::RenderGeometry::GameIntersectorComponent::CreateDescriptor(),
#if !defined(_RELEASE)
AzFramework::TargetManagementComponent::CreateDescriptor(),
#endif
AzFramework::CreateScriptDebugAgentFactory(),
AzFramework::AssetSystem::AssetSystemComponent::CreateDescriptor(),
AzFramework::InputSystemComponent::CreateDescriptor(),
AzFramework::InputContextComponent::CreateDescriptor(),
#if !defined(AZCORE_EXCLUDE_LUA)
AzFramework::ScriptComponent::CreateDescriptor(),
#endif
AzFramework::SceneSystemComponent::CreateDescriptor(),
AzFramework::StreamingInstall::StreamingInstallSystemComponent::CreateDescriptor(),
AzFramework::AzFrameworkConfigurationSystemComponent::CreateDescriptor(),
AzFramework::OctreeSystemComponent::CreateDescriptor(),
AzFramework::SpawnableSystemComponent::CreateDescriptor(),
});
}
AZ::ComponentTypeList AzFrameworkModule::GetRequiredSystemComponents() const
{
return AZ::ComponentTypeList
{
azrtti_typeid<AzFramework::OctreeSystemComponent>(),
};
}
}