Added EntityExists for automation
Signed-off-by: AMZN-AlexOteiza <aljanru@amazon.co.uk>
This commit is contained in:
@@ -414,6 +414,9 @@ namespace AzToolsFramework
|
||||
//! Gets an existing entity id from a known id.
|
||||
virtual AZ::EntityId GetExistingEntity(AZ::u64 id) = 0;
|
||||
|
||||
//! Returns if an entity with the given id exists
|
||||
virtual bool EntityExists(AZ::EntityId id) = 0;
|
||||
|
||||
/*!
|
||||
* Delete all currently-selected entities.
|
||||
*/
|
||||
|
||||
@@ -378,6 +378,7 @@ namespace AzToolsFramework
|
||||
->Event("CreateNewEntityAtPosition", &ToolsApplicationRequests::CreateNewEntityAtPosition)
|
||||
->Event("GetCurrentLevelEntityId", &ToolsApplicationRequests::GetCurrentLevelEntityId)
|
||||
->Event("GetExistingEntity", &ToolsApplicationRequests::GetExistingEntity)
|
||||
->Event("EntityExists", &ToolsApplicationRequests::EntityExists)
|
||||
->Event("DeleteEntityById", &ToolsApplicationRequests::DeleteEntityById)
|
||||
->Event("DeleteEntities", &ToolsApplicationRequests::DeleteEntities)
|
||||
->Event("DeleteEntityAndAllDescendants", &ToolsApplicationRequests::DeleteEntityAndAllDescendants)
|
||||
@@ -483,7 +484,7 @@ namespace AzToolsFramework
|
||||
EBUS_EVENT_RESULT(serializeContext, AZ::ComponentApplicationBus, GetSerializeContext);
|
||||
AZ_Assert(serializeContext, "No serialization context found");
|
||||
|
||||
const AZ::Entity::ComponentArrayType& editorComponents = source.GetComponents();
|
||||
const AZ::Entity::ComponentArrayType& editorComponents = source.GetUserComponents();
|
||||
|
||||
// Propagate components from source entity to target, in preparation for exporting target.
|
||||
for (AZ::Component* component : editorComponents)
|
||||
@@ -493,15 +494,15 @@ namespace AzToolsFramework
|
||||
|
||||
if (asEditorComponent)
|
||||
{
|
||||
const size_t oldComponentCount = target.GetComponents().size();
|
||||
const size_t oldComponentCount = target.GetUserComponents().size();
|
||||
|
||||
asEditorComponent->BuildGameEntity(&target);
|
||||
|
||||
// Applying same Id persistence trick as we do in the slice compiler. Once we're off levels,
|
||||
// this code all goes away and everything runs through the slice compiler.
|
||||
if (target.GetComponents().size() > oldComponentCount)
|
||||
if (target.GetUserComponents().size() > oldComponentCount)
|
||||
{
|
||||
AZ::Component* newComponent = target.GetComponents().back();
|
||||
AZ::Component* newComponent = target.GetUserComponents().back();
|
||||
AZ_Error("Export", asEditorComponent->GetId() != AZ::InvalidComponentId, "For entity \"%s\", component \"%s\" doesn't have a valid component id",
|
||||
source.GetName().c_str(), asEditorComponent->RTTI_GetType().ToString<AZStd::string>().c_str());
|
||||
newComponent->SetId(asEditorComponent->GetId());
|
||||
@@ -783,6 +784,11 @@ namespace AzToolsFramework
|
||||
return AZ::EntityId{id};
|
||||
}
|
||||
|
||||
bool ToolsApplication::EntityExists(AZ::EntityId id)
|
||||
{
|
||||
return FindEntity(id) != nullptr;
|
||||
}
|
||||
|
||||
void ToolsApplication::DeleteSelected()
|
||||
{
|
||||
if (IsPrefabSystemEnabled())
|
||||
|
||||
@@ -115,6 +115,7 @@ namespace AzToolsFramework
|
||||
AZ::EntityId CreateNewEntity(AZ::EntityId parentId = AZ::EntityId()) override;
|
||||
AZ::EntityId CreateNewEntityAtPosition(const AZ::Vector3& pos, AZ::EntityId parentId = AZ::EntityId()) override;
|
||||
AZ::EntityId GetExistingEntity(AZ::u64 id) override;
|
||||
bool EntityExists(AZ::EntityId id) override;
|
||||
void DeleteSelected() override;
|
||||
void DeleteEntityById(AZ::EntityId entityId) override;
|
||||
void DeleteEntities(const EntityIdList& entities) override;
|
||||
|
||||
Reference in New Issue
Block a user