Added API for finding components based on required/incompatible services.
Signed-off-by: Chris Galvan <chgalvan@amazon.com>
This commit is contained in:
@@ -36,6 +36,10 @@ namespace AzToolsFramework
|
||||
//! the entity type.
|
||||
virtual AZStd::vector<AZ::Uuid> FindComponentTypeIdsByEntityType(const AZStd::vector<AZStd::string>& componentTypeNames, EntityType entityType) = 0;
|
||||
|
||||
//! Return a list of type ids for components that match the required services filter,
|
||||
//! and don't conflict with any of the incompatible services filter
|
||||
virtual AZStd::vector<AZ::Uuid> FindComponentTypeIdsByService(const AZStd::vector<AZ::ComponentServiceType>& serviceFilter, const AZStd::vector<AZ::ComponentServiceType>& incompatibleServiceFilter) = 0;
|
||||
|
||||
//! Finds the component names from their type ids
|
||||
virtual AZStd::vector<AZStd::string> FindComponentTypeNames(const AZ::ComponentTypeList& componentTypeIds) = 0;
|
||||
|
||||
|
||||
+30
@@ -15,6 +15,7 @@
|
||||
#include <AzToolsFramework/ToolsComponents/EditorDisabledCompositionBus.h>
|
||||
#include <AzToolsFramework/ToolsComponents/EditorPendingCompositionBus.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityActionComponent.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityHelpers.h>
|
||||
#include <AzToolsFramework/UI/PropertyEditor/InstanceDataHierarchy.h>
|
||||
#include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
|
||||
|
||||
@@ -75,6 +76,7 @@ namespace AzToolsFramework
|
||||
serializeContext->Class<EditorComponentAPIComponent, AZ::Component>();
|
||||
|
||||
serializeContext->RegisterGenericType<AZStd::vector<AZ::EntityComponentIdPair>>();
|
||||
serializeContext->RegisterGenericType<AZStd::vector<AZ::ComponentServiceType>>();
|
||||
}
|
||||
|
||||
if (auto behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
|
||||
@@ -99,6 +101,7 @@ namespace AzToolsFramework
|
||||
->Attribute(AZ::Script::Attributes::Module, "editor")
|
||||
->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All)
|
||||
->Event("FindComponentTypeIdsByEntityType", &EditorComponentAPIRequests::FindComponentTypeIdsByEntityType)
|
||||
->Event("FindComponentTypeIdsByService", &EditorComponentAPIRequests::FindComponentTypeIdsByService)
|
||||
->Event("FindComponentTypeNames", &EditorComponentAPIRequests::FindComponentTypeNames)
|
||||
->Event("BuildComponentTypeNameListByEntityType", &EditorComponentAPIRequests::BuildComponentTypeNameListByEntityType)
|
||||
->Event("AddComponentsOfType", &EditorComponentAPIRequests::AddComponentsOfType)
|
||||
@@ -216,6 +219,33 @@ namespace AzToolsFramework
|
||||
return foundTypeIds;
|
||||
}
|
||||
|
||||
AZStd::vector<AZ::Uuid> EditorComponentAPIComponent::FindComponentTypeIdsByService(const AZStd::vector<AZ::ComponentServiceType>& serviceFilter, const AZStd::vector<AZ::ComponentServiceType>& incompatibleServiceFilter)
|
||||
{
|
||||
AZStd::vector<AZ::Uuid> foundTypeIds;
|
||||
|
||||
m_serializeContext->EnumerateDerived<AZ::Component>(
|
||||
[&foundTypeIds, serviceFilter, incompatibleServiceFilter](const AZ::SerializeContext::ClassData* componentClass, const AZ::Uuid& knownType) -> bool
|
||||
{
|
||||
AZ_UNUSED(knownType);
|
||||
|
||||
if (componentClass->m_editData)
|
||||
{
|
||||
// If none of the required services are offered by this component, or the component
|
||||
// can not be added by the user, skip to the next component
|
||||
if (!OffersRequiredServices(componentClass, serviceFilter, incompatibleServiceFilter))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
foundTypeIds.push_back(componentClass->m_typeId);
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
return foundTypeIds;
|
||||
}
|
||||
|
||||
AZStd::vector<AZStd::string> EditorComponentAPIComponent::FindComponentTypeNames(const AZ::ComponentTypeList& componentTypeIds)
|
||||
{
|
||||
AZStd::vector<AZStd::string> foundTypeNames;
|
||||
|
||||
+1
@@ -35,6 +35,7 @@ namespace AzToolsFramework
|
||||
|
||||
// EditorComponentAPIBus ...
|
||||
AZStd::vector<AZ::Uuid> FindComponentTypeIdsByEntityType(const AZStd::vector<AZStd::string>& componentTypeNames, EditorComponentAPIRequests::EntityType entityType) override;
|
||||
AZStd::vector<AZ::Uuid> FindComponentTypeIdsByService(const AZStd::vector<AZ::ComponentServiceType>& serviceFilter, const AZStd::vector<AZ::ComponentServiceType>& incompatibleServiceFilter) override;
|
||||
AZStd::vector<AZStd::string> FindComponentTypeNames(const AZ::ComponentTypeList& componentTypeIds) override;
|
||||
AZStd::vector<AZStd::string> BuildComponentTypeNameListByEntityType(EditorComponentAPIRequests::EntityType entityType) override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user