Fix Entity id consistency issue & refactor prefab workflows/tests (#4373)

* Fix Entity id consistency issue & refactor prefab workflows/test framework

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

* Update comments

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

* Modify CreatePrefab and remove extra spaces

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

* Address comments

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

* Refactor prefab instance constructors

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

* Remove commented out code

Signed-off-by: chiyteng <chiyteng@amazon.com>
This commit is contained in:
chiyenteng
2021-10-01 10:02:00 -07:00
committed by GitHub
parent b984335b30
commit 23322edde7
32 changed files with 284 additions and 225 deletions
@@ -18,8 +18,9 @@
#include <AzToolsFramework/API/ToolsApplicationAPI.h>
#include <AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.h>
#include <AzToolsFramework/Prefab/EditorPrefabComponent.h>
#include <AzToolsFramework/Prefab/Instance/InstanceEntityMapperInterface.h>
#include <AzToolsFramework/Prefab/Instance/Instance.h>
#include <AzToolsFramework/Prefab/Instance/InstanceEntityIdMapper.h>
#include <AzToolsFramework/Prefab/Instance/InstanceEntityMapperInterface.h>
#include <AzToolsFramework/Prefab/PrefabDomUtils.h>
#include <AzToolsFramework/Prefab/PrefabLoader.h>
#include <AzToolsFramework/Prefab/PrefabSystemComponentInterface.h>
@@ -317,17 +318,18 @@ namespace AzToolsFramework
const AZStd::vector<AZ::Entity*>& entities, AZStd::vector<AZStd::unique_ptr<Prefab::Instance>>&& nestedPrefabInstances,
AZ::IO::PathView filePath, Prefab::InstanceOptionalReference instanceToParentUnder)
{
AZStd::unique_ptr<Prefab::Instance> createdPrefabInstance =
m_prefabSystemComponent->CreatePrefab(entities, AZStd::move(nestedPrefabInstances), filePath, nullptr, false);
if (!instanceToParentUnder)
{
instanceToParentUnder = *m_rootInstance;
}
AZStd::unique_ptr<Prefab::Instance> createdPrefabInstance = m_prefabSystemComponent->CreatePrefab(
entities, AZStd::move(nestedPrefabInstances), filePath, nullptr, instanceToParentUnder, false);
if (createdPrefabInstance)
{
if (!instanceToParentUnder)
{
instanceToParentUnder = *m_rootInstance;
}
Prefab::Instance& addedInstance = instanceToParentUnder->get().AddInstance(AZStd::move(createdPrefabInstance));
Prefab::Instance& addedInstance = instanceToParentUnder->get().AddInstance(
AZStd::move(createdPrefabInstance));
AZ::Entity* containerEntity = addedInstance.m_containerEntity.get();
containerEntity->AddComponent(aznew Prefab::EditorPrefabComponent());
HandleEntitiesAdded({containerEntity});
@@ -341,16 +343,18 @@ namespace AzToolsFramework
Prefab::InstanceOptionalReference PrefabEditorEntityOwnershipService::InstantiatePrefab(
AZ::IO::PathView filePath, Prefab::InstanceOptionalReference instanceToParentUnder)
{
AZStd::unique_ptr<Prefab::Instance> createdPrefabInstance = m_prefabSystemComponent->InstantiatePrefab(filePath);
if (createdPrefabInstance)
if (!instanceToParentUnder)
{
if (!instanceToParentUnder)
{
instanceToParentUnder = *m_rootInstance;
}
instanceToParentUnder = *m_rootInstance;
}
Prefab::Instance& addedInstance = instanceToParentUnder->get().AddInstance(AZStd::move(createdPrefabInstance));
AZStd::unique_ptr<Prefab::Instance> instantiatedPrefabInstance =
m_prefabSystemComponent->InstantiatePrefab(filePath, instanceToParentUnder);
if (instantiatedPrefabInstance)
{
Prefab::Instance& addedInstance = instanceToParentUnder->get().AddInstance(
AZStd::move(instantiatedPrefabInstance));
HandleEntitiesAdded({addedInstance.m_containerEntity.get()});
return addedInstance;
}
@@ -15,6 +15,7 @@
#include <AzToolsFramework/Entity/EditorEntityHelpers.h>
#include <AzToolsFramework/Prefab/Instance/Instance.h>
#include <AzToolsFramework/Prefab/PrefabDomUtils.h>
#include <AzToolsFramework/Prefab/Instance/InstanceEntityIdMapper.h>
#include <AzToolsFramework/Prefab/Instance/InstanceEntityMapperInterface.h>
#include <AzToolsFramework/Prefab/Instance/TemplateInstanceMapperInterface.h>
@@ -28,24 +29,52 @@ namespace AzToolsFramework
}
Instance::Instance(AZStd::unique_ptr<AZ::Entity> containerEntity)
: Instance(AZStd::move(containerEntity), AZStd::nullopt, GenerateInstanceAlias())
{
m_instanceEntityMapper = AZ::Interface<InstanceEntityMapperInterface>::Get();
}
Instance::Instance(InstanceOptionalReference parent)
: Instance(nullptr, parent, GenerateInstanceAlias())
{
}
Instance::Instance(InstanceAlias alias)
: Instance(nullptr, AZStd::nullopt, AZStd::move(alias))
{
}
Instance::Instance(AZStd::unique_ptr<AZ::Entity> containerEntity, InstanceOptionalReference parent)
: Instance(AZStd::move(containerEntity), parent, GenerateInstanceAlias())
{
}
Instance::Instance(AZStd::unique_ptr<AZ::Entity> containerEntity, InstanceOptionalReference parent, InstanceAlias alias)
: m_parent(parent.has_value() ? &parent->get() : nullptr)
, m_alias(AZStd::move(alias))
, m_containerEntity(containerEntity ? AZStd::move(containerEntity) : AZStd::make_unique<AZ::Entity>())
, m_instanceEntityMapper(AZ::Interface<InstanceEntityMapperInterface>::Get())
, m_templateInstanceMapper(AZ::Interface<TemplateInstanceMapperInterface>::Get())
{
AZ_Assert(m_instanceEntityMapper,
"Instance Entity Mapper Interface could not be found. "
"It is a requirement for the Prefab Instance class. "
"Check that it is being correctly initialized.");
m_templateInstanceMapper = AZ::Interface<TemplateInstanceMapperInterface>::Get();
AZ_Assert(m_templateInstanceMapper,
"Template Instance Mapper Interface could not be found. "
"It is a requirement for the Prefab Instance class. "
"Check that it is being correctly initialized.");
m_alias = GenerateInstanceAlias();
m_containerEntity = containerEntity ? AZStd::move(containerEntity)
: AZStd::make_unique<AZ::Entity>();
if (parent)
{
AliasPath absoluteInstancePath = m_parent->GetAbsoluteInstanceAliasPath();
absoluteInstancePath.Append(m_alias);
absoluteInstancePath.Append(PrefabDomUtils::ContainerEntityName);
AZ::EntityId newContainerEntityId = InstanceEntityIdMapper::GenerateEntityIdForAliasPath(absoluteInstancePath);
m_containerEntity->SetId(newContainerEntityId);
}
RegisterEntity(m_containerEntity->GetId(), PrefabDomUtils::ContainerEntityName);
}
@@ -69,12 +98,12 @@ namespace AzToolsFramework
}
}
const TemplateId& Instance::GetTemplateId() const
TemplateId Instance::GetTemplateId() const
{
return m_templateId;
}
void Instance::SetTemplateId(const TemplateId& templateId)
void Instance::SetTemplateId(TemplateId templateId)
{
// If we aren't changing the template Id, there's no need to unregister / re-register
if (templateId == m_templateId)
@@ -295,20 +324,21 @@ namespace AzToolsFramework
}
Instance& Instance::AddInstance(AZStd::unique_ptr<Instance> instance)
{
InstanceAlias newInstanceAlias = GenerateInstanceAlias();
return AddInstance(AZStd::move(instance), newInstanceAlias);
}
Instance& Instance::AddInstance(AZStd::unique_ptr<Instance> instance, InstanceAlias newInstanceAlias)
{
AZ_Assert(instance.get(), "instance argument is nullptr");
if (instance->GetInstanceAlias().empty())
{
instance->m_alias = GenerateInstanceAlias();
}
AZ_Assert(
m_nestedInstances.find(newInstanceAlias) == m_nestedInstances.end(),
m_nestedInstances.find(instance->GetInstanceAlias()) == m_nestedInstances.end(),
"InstanceAlias' unique id collision, this should never happen.");
instance->m_parent = this;
instance->m_alias = newInstanceAlias;
return *(m_nestedInstances[newInstanceAlias] = std::move(instance));
auto& alias = instance->GetInstanceAlias();
return *(m_nestedInstances[alias] = AZStd::move(instance));
}
void Instance::DetachNestedInstances(const AZStd::function<void(AZStd::unique_ptr<Instance>)>& callback)
@@ -65,6 +65,9 @@ namespace AzToolsFramework
Instance();
explicit Instance(AZStd::unique_ptr<AZ::Entity> containerEntity);
explicit Instance(InstanceOptionalReference parent);
explicit Instance(AZStd::unique_ptr<AZ::Entity> containerEntity, InstanceOptionalReference parent);
explicit Instance(InstanceAlias alias);
virtual ~Instance();
Instance(const Instance& rhs) = delete;
@@ -72,8 +75,8 @@ namespace AzToolsFramework
static void Reflect(AZ::ReflectContext* context);
const TemplateId& GetTemplateId() const;
void SetTemplateId(const TemplateId& templateId);
TemplateId GetTemplateId() const;
void SetTemplateId(TemplateId templateId);
const AZ::IO::Path& GetTemplateSourcePath() const;
void SetTemplateSourcePath(AZ::IO::PathView sourcePath);
@@ -97,7 +100,6 @@ namespace AzToolsFramework
void Reset();
Instance& AddInstance(AZStd::unique_ptr<Instance> instance);
Instance& AddInstance(AZStd::unique_ptr<Instance> instance, InstanceAlias instanceAlias);
AZStd::unique_ptr<Instance> DetachNestedInstance(const InstanceAlias& instanceAlias);
void DetachNestedInstances(const AZStd::function<void(AZStd::unique_ptr<Instance>)>& callback);
@@ -184,6 +186,8 @@ namespace AzToolsFramework
private:
static constexpr const char s_aliasPathSeparator = '/';
Instance(AZStd::unique_ptr<AZ::Entity> containerEntity, InstanceOptionalReference parent, InstanceAlias alias);
void ClearEntities();
void RemoveEntities(const AZStd::function<bool(const AZStd::unique_ptr<AZ::Entity>&)>& filter);
@@ -27,7 +27,7 @@ namespace AzToolsFramework
}
bool TemplateInstanceMapper::RegisterTemplate(const TemplateId& templateId)
bool TemplateInstanceMapper::RegisterTemplate(TemplateId templateId)
{
const bool result = m_templateIdToInstancesMap.emplace(templateId, InstanceSet()).second;
AZ_Assert(result,
@@ -39,7 +39,7 @@ namespace AzToolsFramework
return result;
}
bool TemplateInstanceMapper::UnregisterTemplate(const TemplateId& templateId)
bool TemplateInstanceMapper::UnregisterTemplate(TemplateId templateId)
{
const bool result = m_templateIdToInstancesMap.erase(templateId) != 0;
AZ_Assert(result,
@@ -53,7 +53,7 @@ namespace AzToolsFramework
bool TemplateInstanceMapper::RegisterInstanceToTemplate(Instance& instance)
{
const TemplateId& templateId = instance.GetTemplateId();
TemplateId templateId = instance.GetTemplateId();
if (templateId == InvalidTemplateId)
{
return false;
@@ -79,7 +79,7 @@ namespace AzToolsFramework
found->second.erase(&instance) != 0;
}
InstanceSetConstReference TemplateInstanceMapper::FindInstancesOwnedByTemplate(const TemplateId& templateId) const
InstanceSetConstReference TemplateInstanceMapper::FindInstancesOwnedByTemplate(TemplateId templateId) const
{
auto found = m_templateIdToInstancesMap.find(templateId);
@@ -26,10 +26,10 @@ namespace AzToolsFramework
TemplateInstanceMapper();
~TemplateInstanceMapper() override;
InstanceSetConstReference FindInstancesOwnedByTemplate(const TemplateId& templateId) const override;
InstanceSetConstReference FindInstancesOwnedByTemplate(TemplateId templateId) const override;
bool RegisterTemplate(const TemplateId& templateId);
bool UnregisterTemplate(const TemplateId& templateId);
bool RegisterTemplate(TemplateId templateId);
bool UnregisterTemplate(TemplateId templateId);
protected:
bool RegisterInstanceToTemplate(Instance& instance) override;
@@ -24,7 +24,7 @@ namespace AzToolsFramework
AZ_RTTI(TemplateInstanceMapperInterface, "{5DCCCDAA-3441-4266-9670-B349386E0129}");
virtual ~TemplateInstanceMapperInterface() = default;
virtual InstanceSetConstReference FindInstancesOwnedByTemplate(const TemplateId& templateId) const = 0;
virtual InstanceSetConstReference FindInstancesOwnedByTemplate(TemplateId templateId) const = 0;
protected:
// Only the Instance class is allowed to register and unregister Instances.
@@ -122,12 +122,12 @@ namespace AzToolsFramework
!m_instanceName.empty();
}
const TemplateId& Link::GetSourceTemplateId() const
TemplateId Link::GetSourceTemplateId() const
{
return m_sourceTemplateId;
}
const TemplateId& Link::GetTargetTemplateId() const
TemplateId Link::GetTargetTemplateId() const
{
return m_targetTemplateId;
}
@@ -48,8 +48,8 @@ namespace AzToolsFramework
bool IsValid() const;
const TemplateId& GetSourceTemplateId() const;
const TemplateId& GetTargetTemplateId() const;
TemplateId GetSourceTemplateId() const;
TemplateId GetTargetTemplateId() const;
LinkId GetId() const;
@@ -92,7 +92,17 @@ namespace AzToolsFramework
AZStd::unique_ptr<Instance> PrefabSystemComponent::CreatePrefab(
const AZStd::vector<AZ::Entity*>& entities, AZStd::vector<AZStd::unique_ptr<Instance>>&& instancesToConsume,
AZ::IO::PathView filePath, AZStd::unique_ptr<AZ::Entity> containerEntity, bool shouldCreateLinks)
AZ::IO::PathView filePath, AZStd::unique_ptr<AZ::Entity> containerEntity, InstanceOptionalReference parent,
bool shouldCreateLinks)
{
AZStd::unique_ptr<Instance> newInstance = AZStd::make_unique<Instance>(AZStd::move(containerEntity), parent);
CreatePrefab(entities, AZStd::move(instancesToConsume), filePath, newInstance, shouldCreateLinks);
return newInstance;
}
void PrefabSystemComponent::CreatePrefab(
const AZStd::vector<AZ::Entity*>& entities, AZStd::vector<AZStd::unique_ptr<Instance>>&& instancesToConsume,
AZ::IO::PathView filePath, AZStd::unique_ptr<Instance>& newInstance, bool shouldCreateLinks)
{
AZ::IO::Path relativeFilePath = m_prefabLoader.GenerateRelativePath(filePath);
if (GetTemplateIdFromFilePath(relativeFilePath) != InvalidTemplateId)
@@ -101,11 +111,9 @@ namespace AzToolsFramework
"Filepath %s has already been registered with the Prefab System Component",
relativeFilePath.c_str());
return nullptr;
return;
}
AZStd::unique_ptr<Instance> newInstance = AZStd::make_unique<Instance>(AZStd::move(containerEntity));
for (AZ::Entity* entity : entities)
{
AZ_Assert(entity, "Prefab - Null entity passed in during Create Prefab");
@@ -136,8 +144,6 @@ namespace AzToolsFramework
{
newInstance->SetTemplateId(newTemplateId);
}
return newInstance;
}
void PrefabSystemComponent::PropagateTemplateChanges(TemplateId templateId, InstanceOptionalReference instanceToExclude)
@@ -171,7 +177,7 @@ namespace AzToolsFramework
}
}
void PrefabSystemComponent::UpdatePrefabInstances(const TemplateId& templateId, InstanceOptionalReference instanceToExclude)
void PrefabSystemComponent::UpdatePrefabInstances(TemplateId templateId, InstanceOptionalReference instanceToExclude)
{
m_instanceUpdateExecutor.AddTemplateInstancesToQueue(templateId, instanceToExclude);
}
@@ -256,7 +262,8 @@ namespace AzToolsFramework
}
}
AZStd::unique_ptr<Instance> PrefabSystemComponent::InstantiatePrefab(AZ::IO::PathView filePath)
AZStd::unique_ptr<Instance> PrefabSystemComponent::InstantiatePrefab(
AZ::IO::PathView filePath, InstanceOptionalReference parent)
{
// Retrieve the template id for the source prefab filepath
Prefab::TemplateId templateId = GetTemplateIdFromFilePath(filePath);
@@ -276,10 +283,11 @@ namespace AzToolsFramework
return nullptr;
}
return InstantiatePrefab(templateId);
return InstantiatePrefab(templateId, parent);
}
AZStd::unique_ptr<Instance> PrefabSystemComponent::InstantiatePrefab(const TemplateId& templateId)
AZStd::unique_ptr<Instance> PrefabSystemComponent::InstantiatePrefab(
TemplateId templateId, InstanceOptionalReference parent)
{
TemplateReference instantiatingTemplate = FindTemplate(templateId);
@@ -292,7 +300,7 @@ namespace AzToolsFramework
return nullptr;
}
auto newInstance = AZStd::make_unique<Instance>();
auto newInstance = AZStd::make_unique<Instance>(parent);
Instance::EntityList newEntities;
if (!PrefabDomUtils::LoadInstanceFromPrefabDom(*newInstance, newEntities, instantiatingTemplate->get().GetPrefabDom()))
{
@@ -354,7 +362,7 @@ namespace AzToolsFramework
return newTemplateId;
}
TemplateReference PrefabSystemComponent::FindTemplate(const TemplateId& id)
TemplateReference PrefabSystemComponent::FindTemplate(TemplateId id)
{
auto found = m_templateIdMap.find(id);
if (found != m_templateIdMap.end())
@@ -466,7 +474,7 @@ namespace AzToolsFramework
templateToChange.SetFilePath(filePath);
}
void PrefabSystemComponent::RemoveTemplate(const TemplateId& templateId)
void PrefabSystemComponent::RemoveTemplate(TemplateId templateId)
{
auto findTemplateResult = FindTemplate(templateId);
if (!findTemplateResult.has_value())
@@ -553,8 +561,8 @@ namespace AzToolsFramework
}
LinkId PrefabSystemComponent::AddLink(
const TemplateId& sourceTemplateId,
const TemplateId& targetTemplateId,
TemplateId sourceTemplateId,
TemplateId targetTemplateId,
PrefabDomValue::MemberIterator& instanceIterator,
InstanceOptionalReference instance)
{
@@ -616,8 +624,8 @@ namespace AzToolsFramework
}
LinkId PrefabSystemComponent::CreateLink(
const TemplateId& linkTargetId,
const TemplateId& linkSourceId,
TemplateId linkTargetId,
TemplateId linkSourceId,
const InstanceAlias& instanceAlias,
const PrefabDomConstReference linkPatches,
const LinkId& linkId)
@@ -774,7 +782,7 @@ namespace AzToolsFramework
}
}
bool PrefabSystemComponent::IsTemplateDirty(const TemplateId& templateId)
bool PrefabSystemComponent::IsTemplateDirty(TemplateId templateId)
{
auto templateRef = FindTemplate(templateId);
@@ -786,7 +794,7 @@ namespace AzToolsFramework
return false;
}
void PrefabSystemComponent::SetTemplateDirtyFlag(const TemplateId& templateId, bool dirty)
void PrefabSystemComponent::SetTemplateDirtyFlag(TemplateId templateId, bool dirty)
{
auto templateRef = FindTemplate(templateId);
@@ -940,7 +948,7 @@ namespace AzToolsFramework
return true;
}
bool PrefabSystemComponent::GenerateLinksForNewTemplate(const TemplateId& newTemplateId, Instance& instance)
bool PrefabSystemComponent::GenerateLinksForNewTemplate(TemplateId newTemplateId, Instance& instance)
{
TemplateReference newTemplateReference = FindTemplate(newTemplateId);
if (!newTemplateReference.has_value())
@@ -980,7 +988,7 @@ namespace AzToolsFramework
}
const PrefabDomValue& source = instanceSourceReference->get();
const TemplateId& nestedTemplateId = GetTemplateIdFromFilePath(source.GetString());
TemplateId nestedTemplateId = GetTemplateIdFromFilePath(source.GetString());
if (nestedTemplateId == InvalidTemplateId)
{
AZ_Error("Prefab", false,
@@ -84,7 +84,7 @@ namespace AzToolsFramework
* @param id A unique id of a Template.
* @return Reference of Template if the Template exists.
*/
TemplateReference FindTemplate(const TemplateId& id) override;
TemplateReference FindTemplate(TemplateId id) override;
/**
* Find Link with given Link id from Prefab System Component.
@@ -112,7 +112,7 @@ namespace AzToolsFramework
* Remove the Template associated with the given id from Prefab System Component.
* @param templateId A unique id of a Template.
*/
void RemoveTemplate(const TemplateId& templateId) override;
void RemoveTemplate(TemplateId templateId) override;
/**
* Remove all Templates from the Prefab System Component.
@@ -121,17 +121,21 @@ namespace AzToolsFramework
/**
* Generates a new Prefab Instance based on the Template whose source is stored in filepath.
* @param filePath the path to the prefab source file containing the template being instantiated.
* @param filePath The path to the prefab source file containing the template being instantiated.
* @param parent Reference of the target instance the instantiated instance will be placed under.
* @return A unique_ptr to the newly instantiated instance. Null if operation failed.
*/
AZStd::unique_ptr<Instance> InstantiatePrefab(AZ::IO::PathView filePath) override;
AZStd::unique_ptr<Instance> InstantiatePrefab(
AZ::IO::PathView filePath, InstanceOptionalReference parent = AZStd::nullopt) override;
/**
* Generates a new Prefab Instance based on the Template referenced by templateId
* @param templateId the id of the template being instantiated.
* Generates a new Prefab Instance based on the Template referenced by templateId.
* @param templateId The id of the template being instantiated.
* @param parent Reference of the target instance the instantiated instance will be placed under.
* @return A unique_ptr to the newly instantiated instance. Null if operation failed.
*/
AZStd::unique_ptr<Instance> InstantiatePrefab(const TemplateId& templateId) override;
AZStd::unique_ptr<Instance> InstantiatePrefab(
TemplateId templateId, InstanceOptionalReference parent = AZStd::nullopt) override;
/**
* Add a new Link into Prefab System Component and create a unique id for it.
@@ -142,8 +146,8 @@ namespace AzToolsFramework
* @return A unique id for the new Link.
*/
LinkId AddLink(
const TemplateId& sourceTemplateId,
const TemplateId& targetTemplateId,
TemplateId sourceTemplateId,
TemplateId targetTemplateId,
PrefabDomValue::MemberIterator& instanceIterator,
InstanceOptionalReference instance) override;
@@ -157,8 +161,8 @@ namespace AzToolsFramework
* @return A unique id for the new Link.
*/
LinkId CreateLink(
const TemplateId& linkTargetId,
const TemplateId& linkSourceId,
TemplateId linkTargetId,
TemplateId linkSourceId,
const InstanceAlias& instanceAlias,
const PrefabDomConstReference linkPatches,
const LinkId& linkId = InvalidLinkId) override;
@@ -181,14 +185,14 @@ namespace AzToolsFramework
* @param templateId The id of the template to query.
* @return The value of the dirty flag on the template.
*/
bool IsTemplateDirty(const TemplateId& templateId) override;
bool IsTemplateDirty(TemplateId templateId) override;
/**
* Sets the dirty flag of the template to the value provided.
* @param templateId The id of the template to flag.
* @param dirty The new value of the dirty flag.
*/
void SetTemplateDirtyFlag(const TemplateId& templateId, bool dirty) override;
void SetTemplateDirtyFlag(TemplateId templateId, bool dirty) override;
bool AreDirtyTemplatesPresent(TemplateId rootTemplateId) override;
@@ -200,20 +204,21 @@ namespace AzToolsFramework
/**
* Builds a new Prefab Template out of entities and instances and returns the first instance comprised of
* these entities and instances
* @param entities A vector of entities that will be used in the new instance. May be empty
* these entities and instances.
* @param entities A vector of entities that will be used in the new instance. May be empty.
* @param instances A vector of Prefab Instances that will be nested in the new instance, will be consumed and moved.
* May be empty
* @param filePath the path to associate the template of the new instance to.
* May be empty.
* @param filePath The path to associate the template of the new instance to.
* @param containerEntity The container entity for the prefab to be created. It will be created if a nullptr is provided.
* @param parent Reference of an instance the created instance will be placed under, if given.
* @param shouldCreateLinks The flag indicating if links should be created between the templates of the instance
* and its nested instances.
* @return A pointer to the newly created instance. nullptr on failure
* @return A pointer to the newly created instance. nullptr on failure.
*/
AZStd::unique_ptr<Instance> CreatePrefab(
const AZStd::vector<AZ::Entity*>& entities, AZStd::vector<AZStd::unique_ptr<Instance>>&& instancesToConsume,
AZ::IO::PathView filePath, AZStd::unique_ptr<AZ::Entity> containerEntity = nullptr,
bool ShouldCreateLinks = true) override;
InstanceOptionalReference parent = AZStd::nullopt, bool shouldCreateLinks = true) override;
PrefabDom& FindTemplateDom(TemplateId templateId) override;
@@ -232,11 +237,26 @@ namespace AzToolsFramework
*
* @param templateId The id of the Template owning Instances to update.
*/
void UpdatePrefabInstances(const TemplateId& templateId, InstanceOptionalReference instanceToExclude = AZStd::nullopt);
void UpdatePrefabInstances(TemplateId templateId, InstanceOptionalReference instanceToExclude = AZStd::nullopt);
private:
AZ_DISABLE_COPY_MOVE(PrefabSystemComponent);
/**
* Builds a new Prefab Template out of entities and instances and returns the first instance comprised of
* these entities and instances.
* @param entities A vector of entities that will be used in the new instance. May be empty.
* @param instances A vector of Prefab Instances that will be nested in the new instance, will be consumed and moved.
* May be empty.
* @param filePath The path to associate the template of the new instance to.
* @param instance Reference of a pointer to the newly created instance which needs initiation.
* @param shouldCreateLinks The flag indicating if links should be created between the templates of the instance
* and its nested instances.
*/
void CreatePrefab(const AZStd::vector<AZ::Entity*>& entities,
AZStd::vector<AZStd::unique_ptr<Instance>>&& instancesToConsume, AZ::IO::PathView filePath,
AZStd::unique_ptr<Instance>& instance, bool shouldCreateLinks);
/**
* Updates all the linked Instances corresponding to the linkIds in the provided queue.
* Queue gets populated with more linkId lists as linked instances are updated. Updating stops when the queue is empty.
@@ -310,7 +330,7 @@ namespace AzToolsFramework
* @param instance The instance that the template was created from. This needs to be editable for inserting linkId into it.
* @return bool on whether the operation succeeded
*/
bool GenerateLinksForNewTemplate(const TemplateId& newTemplateId, Instance& instance);
bool GenerateLinksForNewTemplate(TemplateId newTemplateId, Instance& instance);
/**
* Create a unique Template id for newly created Template.
@@ -29,28 +29,28 @@ namespace AzToolsFramework
public:
AZ_RTTI(PrefabSystemComponentInterface, "{8E95A029-67F9-4F74-895F-DDBFE29516A0}");
virtual TemplateReference FindTemplate(const TemplateId& id) = 0;
virtual TemplateReference FindTemplate(TemplateId id) = 0;
virtual LinkReference FindLink(const LinkId& id) = 0;
virtual TemplateId AddTemplate(const AZ::IO::Path& filePath, PrefabDom prefabDom) = 0;
virtual void UpdateTemplateFilePath(TemplateId templateId, const AZ::IO::PathView& filePath) = 0;
virtual void RemoveTemplate(const TemplateId& templateId) = 0;
virtual void RemoveTemplate(TemplateId templateId) = 0;
virtual void RemoveAllTemplates() = 0;
virtual LinkId AddLink(const TemplateId& sourceTemplateId, const TemplateId& targetTemplateId,
virtual LinkId AddLink(TemplateId sourceTemplateId, TemplateId targetTemplateId,
PrefabDomValue::MemberIterator& instanceIterator, InstanceOptionalReference instance) = 0;
//creates a new Link
virtual LinkId CreateLink(
const TemplateId& linkTargetId, const TemplateId& linkSourceId, const InstanceAlias& instanceAlias,
TemplateId linkTargetId, TemplateId linkSourceId, const InstanceAlias& instanceAlias,
const PrefabDomConstReference linkPatches, const LinkId& linkId = InvalidLinkId) = 0;
virtual void RemoveLink(const LinkId& linkId) = 0;
virtual TemplateId GetTemplateIdFromFilePath(AZ::IO::PathView filePath) const = 0;
virtual bool IsTemplateDirty(const TemplateId& templateId) = 0;
virtual void SetTemplateDirtyFlag(const TemplateId& templateId, bool dirty) = 0;
virtual bool IsTemplateDirty(TemplateId templateId) = 0;
virtual void SetTemplateDirtyFlag(TemplateId templateId, bool dirty) = 0;
//! Recursive function to check if the template is dirty or if any dirty templates are presents in the links of the template.
//! @param rootTemplateId The id of the template provided as the beginning template to check the outgoing links.
@@ -69,11 +69,14 @@ namespace AzToolsFramework
virtual void UpdatePrefabTemplate(TemplateId templateId, const PrefabDom& updatedDom) = 0;
virtual void PropagateTemplateChanges(TemplateId templateId, InstanceOptionalReference instanceToExclude = AZStd::nullopt) = 0;
virtual AZStd::unique_ptr<Instance> InstantiatePrefab(AZ::IO::PathView filePath) = 0;
virtual AZStd::unique_ptr<Instance> InstantiatePrefab(const TemplateId& templateId) = 0;
virtual AZStd::unique_ptr<Instance> InstantiatePrefab(
AZ::IO::PathView filePath, InstanceOptionalReference parent = AZStd::nullopt) = 0;
virtual AZStd::unique_ptr<Instance> InstantiatePrefab(
TemplateId templateId, InstanceOptionalReference parent = AZStd::nullopt) = 0;
virtual AZStd::unique_ptr<Instance> CreatePrefab(const AZStd::vector<AZ::Entity*>& entities,
AZStd::vector<AZStd::unique_ptr<Instance>>&& instancesToConsume, AZ::IO::PathView filePath,
AZStd::unique_ptr<AZ::Entity> containerEntity = nullptr, bool ShouldCreateLinks = true) = 0;
AZStd::unique_ptr<AZ::Entity> containerEntity = nullptr, InstanceOptionalReference parent = AZStd::nullopt,
bool shouldCreateLinks = true) = 0;
};
@@ -33,7 +33,7 @@ namespace AzToolsFramework
void PrefabUndoInstance::Capture(
const PrefabDom& initialState,
const PrefabDom& endState,
const TemplateId& templateId)
TemplateId templateId)
{
m_templateId = templateId;
@@ -136,8 +136,8 @@ namespace AzToolsFramework
}
void PrefabUndoInstanceLink::Capture(
const TemplateId& targetId,
const TemplateId& sourceId,
TemplateId targetId,
TemplateId sourceId,
const InstanceAlias& instanceAlias,
PrefabDom linkPatches,
const LinkId linkId)
@@ -49,7 +49,7 @@ namespace AzToolsFramework
void Capture(
const PrefabDom& initialState,
const PrefabDom& endState,
const TemplateId& templateId);
TemplateId templateId);
void Undo() override;
void Redo() override;
@@ -95,8 +95,8 @@ namespace AzToolsFramework
//capture for add/remove
void Capture(
const TemplateId& targetId,
const TemplateId& sourceId,
TemplateId targetId,
TemplateId sourceId,
const InstanceAlias& instanceAlias,
PrefabDom linkPatches = PrefabDom(),
const LinkId linkId = InvalidLinkId);
@@ -72,7 +72,7 @@ namespace Benchmark
AZStd::unique_ptr<Instance> instance = m_prefabSystemComponent->CreatePrefab(
entities
, {}
, m_pathString);
, m_pathString);
state.PauseTiming();
@@ -165,7 +165,7 @@ namespace Benchmark
{
nestedInstanceRoot = m_prefabSystemComponent->CreatePrefab(
{},
MakeInstanceList( AZStd::move(nestedInstanceRoot) ),
MakeInstanceList(AZStd::move(nestedInstanceRoot)),
m_paths[instanceCounter]);
}
@@ -36,7 +36,7 @@ namespace Benchmark
AZStd::unique_ptr<Instance> enclosingInstance = m_prefabSystemComponent->CreatePrefab(
{},
MakeInstanceList( AZStd::move(nestedInstance) ),
MakeInstanceList(AZStd::move(nestedInstance)),
enclosingTemplatePath);
TemplateId templateToInstantiateId = enclosingInstance->GetTemplateId();
@@ -99,7 +99,7 @@ namespace Benchmark
{
currentInstanceRoot = m_prefabSystemComponent->CreatePrefab(
{},
MakeInstanceList( AZStd::move(currentInstanceRoot) ),
MakeInstanceList(AZStd::move(currentInstanceRoot)),
m_paths[currentDepth - 1]);
}
@@ -151,7 +151,7 @@ namespace Benchmark
{
currentInstanceRoot = m_prefabSystemComponent->CreatePrefab(
{},
MakeInstanceList( AZStd::move(currentInstanceRoot) ),
MakeInstanceList(AZStd::move(currentInstanceRoot)),
m_paths[currentDepth]);
}
@@ -214,7 +214,7 @@ namespace Benchmark
currentInstanceRoot = m_prefabSystemComponent->CreatePrefab(
{},
MakeInstanceList( AZStd::move(currentInstanceRoot), AZStd::move(extraNestedInstance) ),
MakeInstanceList(AZStd::move(currentInstanceRoot), AZStd::move(extraNestedInstance)),
m_paths[currentDepth]);
}
@@ -54,7 +54,7 @@ namespace UnitTest
// Create a street prefab that nests the car and sportscar instances created above. The container entity will be created as part of the process.
AZStd::unique_ptr<AzToolsFramework::Prefab::Instance> streetInstance =
m_prefabSystemComponent->CreatePrefab({}, MakeInstanceList( AZStd::move(carInstance), AZStd::move(sportsCarInstance) ), "test/street");
m_prefabSystemComponent->CreatePrefab({}, MakeInstanceList(AZStd::move(carInstance), AZStd::move(sportsCarInstance)), "test/street");
ASSERT_TRUE(streetInstance);
m_instanceMap[StreetEntityName] = streetInstance.get();
@@ -320,7 +320,7 @@ namespace UnitTest
Instance& addedInstance = *addedInstancePtr;
//create a first instance where the instance will be removed
AZStd::unique_ptr<Instance> firstInstance = m_prefabSystemComponent->CreatePrefab({}, MakeInstanceList( AZStd::move(addedInstancePtr) ), "test/path");
AZStd::unique_ptr<Instance> firstInstance = m_prefabSystemComponent->CreatePrefab({}, MakeInstanceList(AZStd::move(addedInstancePtr)), "test/path");
ASSERT_TRUE(firstInstance);
//get added instance alias
@@ -44,11 +44,11 @@ namespace UnitTest
ASSERT_TRUE(firstInstance);
AZStd::unique_ptr<AzToolsFramework::Prefab::Instance> secondInstance = m_prefabSystemComponent->CreatePrefab({},
MakeInstanceList( AZStd::move(firstInstance) ), "test/path2");
MakeInstanceList(AZStd::move(firstInstance)), "test/path2");
ASSERT_TRUE(secondInstance);
AZStd::unique_ptr<AzToolsFramework::Prefab::Instance> thirdInstance = m_prefabSystemComponent->CreatePrefab({},
MakeInstanceList( AZStd::move(secondInstance) ), "test/path3");
MakeInstanceList(AZStd::move(secondInstance)), "test/path3");
ASSERT_TRUE(thirdInstance);
//Instantiate it
@@ -21,8 +21,8 @@ namespace UnitTest
using namespace AzToolsFramework::Prefab;
LinkData CreateLinkData(
const InstanceData& instanceData,
const TemplateId& sourceTemplateId,
const TemplateId& targetTemplateId)
TemplateId sourceTemplateId,
TemplateId targetTemplateId)
{
LinkData newLinkData;
newLinkData.m_instanceData = instanceData;
@@ -17,8 +17,8 @@ namespace UnitTest
{
LinkData CreateLinkData(
const InstanceData& instanceData,
const AzToolsFramework::Prefab::TemplateId& sourceTemplateId,
const AzToolsFramework::Prefab::TemplateId& targetTemplateId);
AzToolsFramework::Prefab::TemplateId sourceTemplateId,
AzToolsFramework::Prefab::TemplateId targetTemplateId);
InstanceData CreateInstanceDataWithNoPatches(
const AZStd::string& name,
@@ -56,7 +56,7 @@ namespace UnitTest
}
void ValidateInstances(
const TemplateId& templateId,
TemplateId templateId,
const PrefabDomValue& expectedContent,
const PrefabDomPath& contentPath,
bool isContentAnInstance,
@@ -204,7 +204,7 @@ namespace UnitTest
}
void ValidateEntitiesOfInstances(
const AzToolsFramework::Prefab::TemplateId& templateId,
AzToolsFramework::Prefab::TemplateId templateId,
const AzToolsFramework::Prefab::PrefabDom& expectedPrefabDom,
const AZStd::vector<EntityAlias>& entityAliases)
{
@@ -219,7 +219,7 @@ namespace UnitTest
}
void ValidateNestedInstancesOfInstances(
const AzToolsFramework::Prefab::TemplateId& templateId,
AzToolsFramework::Prefab::TemplateId templateId,
const AzToolsFramework::Prefab::PrefabDom& expectedPrefabDom,
const AZStd::vector<InstanceAlias>& nestedInstanceAliases)
{
@@ -118,7 +118,7 @@ namespace UnitTest
const PrefabDomValue& patches);
void ValidateInstances(
const TemplateId& templateId,
TemplateId templateId,
const PrefabDomValue& expectedContent,
const PrefabDomPath& contentPath,
bool isContentAnInstance = false,
@@ -147,12 +147,12 @@ namespace UnitTest
void ComparePrefabDomValues(PrefabDomValueConstReference valueA, PrefabDomValueConstReference valueB);
void ValidateEntitiesOfInstances(
const AzToolsFramework::Prefab::TemplateId& templateId,
AzToolsFramework::Prefab::TemplateId templateId,
const AzToolsFramework::Prefab::PrefabDom& expectedPrefabDom,
const AZStd::vector<EntityAlias>& entityAliases);
void ValidateNestedInstancesOfInstances(
const AzToolsFramework::Prefab::TemplateId& templateId,
AzToolsFramework::Prefab::TemplateId templateId,
const AzToolsFramework::Prefab::PrefabDom& expectedPrefabDom,
const AZStd::vector<InstanceAlias>& nestedInstanceAliases);
@@ -18,14 +18,14 @@ namespace UnitTest
{
//create two prefabs for test
//create prefab 1
firstInstance = AZStd::move(m_prefabSystemComponent->CreatePrefab({ }, {}, "test/path0"));
firstInstance = AZStd::move(m_prefabSystemComponent->CreatePrefab({}, {}, "test/path0"));
ASSERT_TRUE(firstInstance);
//get template id
ownerId = firstInstance->GetTemplateId();
//create prefab 2
secondInstance = AZStd::move(m_prefabSystemComponent->CreatePrefab({ }, {}, "test/path1"));
secondInstance = AZStd::move(m_prefabSystemComponent->CreatePrefab({}, {}, "test/path1"));
ASSERT_TRUE(secondInstance);
//get template id
@@ -120,7 +120,7 @@ namespace UnitTest
// Create an enclosing Template with 0 entities and 1 nested Instance.
AZStd::unique_ptr<Instance> nestedInstance1 = m_prefabSystemComponent->InstantiatePrefab(newNestedTemplateId);
AZStd::unique_ptr<Instance> newEnclosingInstance = m_prefabSystemComponent->CreatePrefab({}, MakeInstanceList( AZStd::move(nestedInstance1) ), PrefabMockFilePath);
AZStd::unique_ptr<Instance> newEnclosingInstance = m_prefabSystemComponent->CreatePrefab({}, MakeInstanceList(AZStd::move(nestedInstance1)), PrefabMockFilePath);
TemplateId newEnclosingTemplateId = newEnclosingInstance->GetTemplateId();
EXPECT_TRUE(newEnclosingTemplateId != InvalidTemplateId);
PrefabDom& newEnclosingTemplateDom = m_prefabSystemComponent->FindTemplateDom(newEnclosingTemplateId);
@@ -284,7 +284,7 @@ namespace UnitTest
AZStd::unique_ptr<Instance> nestedInstance2 = m_prefabSystemComponent->InstantiatePrefab(newNestedTemplateId);
AZStd::unique_ptr<Instance> newEnclosingInstance = m_prefabSystemComponent->CreatePrefab(
{},
MakeInstanceList( AZStd::move(nestedInstance1), AZStd::move(nestedInstance2) ),
MakeInstanceList(AZStd::move(nestedInstance1), AZStd::move(nestedInstance2)),
PrefabMockFilePath);
TemplateId newEnclosingTemplateId = newEnclosingInstance->GetTemplateId();
EXPECT_TRUE(newEnclosingTemplateId != InvalidTemplateId);
@@ -41,7 +41,7 @@ namespace UnitTest
AZStd::unique_ptr<Instance> wheel1UnderAxle = m_prefabSystemComponent->InstantiatePrefab(wheelTemplateId);
AZStd::unique_ptr<Instance> wheel2UnderAxle = m_prefabSystemComponent->InstantiatePrefab(wheelTemplateId);
AZStd::unique_ptr<Instance> axleInstance = m_prefabSystemComponent->CreatePrefab({},
MakeInstanceList( AZStd::move(wheel1UnderAxle), AZStd::move(wheel2UnderAxle) ), AxlePrefabMockFilePath);
MakeInstanceList(AZStd::move(wheel1UnderAxle), AZStd::move(wheel2UnderAxle)), AxlePrefabMockFilePath);
const TemplateId axleTemplateId = axleInstance->GetTemplateId();
const AZStd::vector<InstanceAlias> wheelInstanceAliasesUnderAxle = axleInstance->GetNestedInstanceAliases(wheelTemplateId);
PrefabDom& axleTemplateDom = m_prefabSystemComponent->FindTemplateDom(axleTemplateId);
@@ -51,7 +51,7 @@ namespace UnitTest
AZStd::unique_ptr<Instance> axle2UnderCar = m_prefabSystemComponent->InstantiatePrefab(axleTemplateId);
AZStd::unique_ptr<Instance> spareWheelUnderCar = m_prefabSystemComponent->InstantiatePrefab(wheelTemplateId);
AZStd::unique_ptr<Instance> carInstance = m_prefabSystemComponent->CreatePrefab({},
MakeInstanceList( AZStd::move(axle1UnderCar), AZStd::move(axle2UnderCar), AZStd::move(spareWheelUnderCar) ), CarPrefabMockFilePath);
MakeInstanceList(AZStd::move(axle1UnderCar), AZStd::move(axle2UnderCar), AZStd::move(spareWheelUnderCar)), CarPrefabMockFilePath);
const TemplateId carTemplateId = carInstance->GetTemplateId();
const AZStd::vector<InstanceAlias> axleInstanceAliasesUnderCar = carInstance->GetNestedInstanceAliases(axleTemplateId);
const AZStd::vector<InstanceAlias> wheelInstanceAliasesUnderCar = carInstance->GetNestedInstanceAliases(wheelTemplateId);
@@ -93,7 +93,7 @@ namespace UnitTest
// Create an axle with 0 entities and 1 wheel instance.
AZStd::unique_ptr<Instance> wheel1UnderAxle = m_prefabSystemComponent->InstantiatePrefab(wheelTemplateId);
AZStd::unique_ptr<Instance> axleInstance = m_prefabSystemComponent->CreatePrefab({},
MakeInstanceList( AZStd::move(wheel1UnderAxle) ), AxlePrefabMockFilePath);
MakeInstanceList(AZStd::move(wheel1UnderAxle)), AxlePrefabMockFilePath);
const TemplateId axleTemplateId = axleInstance->GetTemplateId();
PrefabDom& axleTemplateDom = m_prefabSystemComponent->FindTemplateDom(axleTemplateId);
AZStd::vector<InstanceAlias> wheelInstanceAliasesUnderAxle = axleInstance->GetNestedInstanceAliases(wheelTemplateId);
@@ -105,7 +105,7 @@ namespace UnitTest
AZStd::unique_ptr<Instance> axle1UnderCar = m_prefabSystemComponent->InstantiatePrefab(axleTemplateId);
AZStd::unique_ptr<Instance> axle2UnderCar = m_prefabSystemComponent->InstantiatePrefab(axleTemplateId);
AZStd::unique_ptr<Instance> carInstance = m_prefabSystemComponent->CreatePrefab({},
MakeInstanceList( AZStd::move(axle1UnderCar), AZStd::move(axle2UnderCar) ), CarPrefabMockFilePath);
MakeInstanceList(AZStd::move(axle1UnderCar), AZStd::move(axle2UnderCar)), CarPrefabMockFilePath);
const TemplateId carTemplateId = carInstance->GetTemplateId();
const AZStd::vector<InstanceAlias> axleInstanceAliasesUnderCar = carInstance->GetNestedInstanceAliases(axleTemplateId);
PrefabDom& carTemplateDom = m_prefabSystemComponent->FindTemplateDom(carTemplateId);
@@ -151,7 +151,7 @@ namespace UnitTest
// Create an axle with 0 entities and 1 wheel instance.
AZStd::unique_ptr<Instance> wheel1UnderAxle = m_prefabSystemComponent->InstantiatePrefab(wheelTemplateId);
AZStd::unique_ptr<Instance> axleInstance = m_prefabSystemComponent->CreatePrefab({},
MakeInstanceList( AZStd::move(wheel1UnderAxle) ), AxlePrefabMockFilePath);
MakeInstanceList(AZStd::move(wheel1UnderAxle)), AxlePrefabMockFilePath);
const TemplateId axleTemplateId = axleInstance->GetTemplateId();
PrefabDom& axleTemplateDom = m_prefabSystemComponent->FindTemplateDom(axleTemplateId);
const AZStd::vector<InstanceAlias> wheelInstanceAliasesUnderAxle = axleInstance->GetNestedInstanceAliases(wheelTemplateId);
@@ -159,7 +159,7 @@ namespace UnitTest
// Create a car with 0 entities and 1 axle instance.
AZStd::unique_ptr<Instance> axleUnderCar = m_prefabSystemComponent->InstantiatePrefab(axleTemplateId);
AZStd::unique_ptr<Instance> carInstance = m_prefabSystemComponent->CreatePrefab({},
MakeInstanceList( AZStd::move(axleUnderCar) ), CarPrefabMockFilePath);
MakeInstanceList(AZStd::move(axleUnderCar)), CarPrefabMockFilePath);
const TemplateId carTemplateId = carInstance->GetTemplateId();
const AZStd::vector<InstanceAlias> axleInstanceAliasesUnderCar = carInstance->GetNestedInstanceAliases(axleTemplateId);
PrefabDom& carTemplateDom = m_prefabSystemComponent->FindTemplateDom(carTemplateId);
@@ -205,7 +205,7 @@ namespace UnitTest
// Create an axle with 0 entities and 1 wheel instance.
AZStd::unique_ptr<Instance> wheel1UnderAxle = m_prefabSystemComponent->InstantiatePrefab(wheelTemplateId);
AZStd::unique_ptr<Instance> axleInstance = m_prefabSystemComponent->CreatePrefab({},
MakeInstanceList( AZStd::move(wheel1UnderAxle) ), AxlePrefabMockFilePath);
MakeInstanceList(AZStd::move(wheel1UnderAxle)), AxlePrefabMockFilePath);
const TemplateId axleTemplateId = axleInstance->GetTemplateId();
PrefabDom& axleTemplateDom = m_prefabSystemComponent->FindTemplateDom(axleTemplateId);
const AZStd::vector<InstanceAlias> wheelInstanceAliasesUnderAxle = axleInstance->GetNestedInstanceAliases(wheelTemplateId);
@@ -213,7 +213,7 @@ namespace UnitTest
// Create a car with 0 entities and 1 axle instance.
AZStd::unique_ptr<Instance> axleUnderCar = m_prefabSystemComponent->InstantiatePrefab(axleTemplateId);
AZStd::unique_ptr<Instance> carInstance = m_prefabSystemComponent->CreatePrefab({},
MakeInstanceList( AZStd::move(axleUnderCar) ), CarPrefabMockFilePath);
MakeInstanceList(AZStd::move(axleUnderCar)), CarPrefabMockFilePath);
const TemplateId carTemplateId = carInstance->GetTemplateId();
const AZStd::vector<InstanceAlias> axleInstanceAliasesUnderCar = carInstance->GetNestedInstanceAliases(axleTemplateId);
PrefabDom& carTemplateDom = m_prefabSystemComponent->FindTemplateDom(carTemplateId);
@@ -253,7 +253,7 @@ namespace UnitTest
AZStd::unique_ptr<Instance> wheel1UnderAxle = m_prefabSystemComponent->InstantiatePrefab(wheelTemplateId);
AZStd::unique_ptr<Instance> wheel2UnderAxle = m_prefabSystemComponent->InstantiatePrefab(wheelTemplateId);
AZStd::unique_ptr<Instance> axleInstance = m_prefabSystemComponent->CreatePrefab({},
MakeInstanceList( AZStd::move(wheel1UnderAxle), AZStd::move(wheel2UnderAxle) ),
MakeInstanceList(AZStd::move(wheel1UnderAxle), AZStd::move(wheel2UnderAxle) ),
AxlePrefabMockFilePath);
const TemplateId axleTemplateId = axleInstance->GetTemplateId();
PrefabDom& axleTemplateDom = m_prefabSystemComponent->FindTemplateDom(axleTemplateId);
@@ -265,7 +265,7 @@ namespace UnitTest
// Create a car with 0 entities and 1 axle instance.
AZStd::unique_ptr<Instance> axle1UnderCar = m_prefabSystemComponent->InstantiatePrefab(axleTemplateId);
AZStd::unique_ptr<Instance> carInstance = m_prefabSystemComponent->CreatePrefab({},
MakeInstanceList( AZStd::move(axle1UnderCar) ), CarPrefabMockFilePath);
MakeInstanceList(AZStd::move(axle1UnderCar)), CarPrefabMockFilePath);
const TemplateId carTemplateId = carInstance->GetTemplateId();
const AZStd::vector<InstanceAlias> axleInstanceAliasesUnderCar = carInstance->GetNestedInstanceAliases(axleTemplateId);
PrefabDom& carTemplateDom = m_prefabSystemComponent->FindTemplateDom(carTemplateId);
@@ -320,7 +320,7 @@ namespace UnitTest
// Create an axle with 0 entities and 1 wheel instance.
AZStd::unique_ptr<Instance> wheel1UnderAxle = m_prefabSystemComponent->InstantiatePrefab(wheelTemplateId);
AZStd::unique_ptr<Instance> axleInstance = m_prefabSystemComponent->CreatePrefab({},
MakeInstanceList( AZStd::move(wheel1UnderAxle) ), AxlePrefabMockFilePath);
MakeInstanceList(AZStd::move(wheel1UnderAxle)), AxlePrefabMockFilePath);
const TemplateId axleTemplateId = axleInstance->GetTemplateId();
PrefabDom& axleTemplateDom = m_prefabSystemComponent->FindTemplateDom(axleTemplateId);
const AZStd::vector<InstanceAlias> wheelInstanceAliasesUnderAxle = axleInstance->GetNestedInstanceAliases(wheelTemplateId);
@@ -328,7 +328,7 @@ namespace UnitTest
// Create a car with 0 entities and 1 axle instance.
AZStd::unique_ptr<Instance> axleUnderCar = m_prefabSystemComponent->InstantiatePrefab(axleTemplateId);
AZStd::unique_ptr<Instance> carInstance = m_prefabSystemComponent->CreatePrefab({},
MakeInstanceList( AZStd::move(axleUnderCar) ), CarPrefabMockFilePath);
MakeInstanceList(AZStd::move(axleUnderCar)), CarPrefabMockFilePath);
const TemplateId carTemplateId = carInstance->GetTemplateId();
const AZStd::vector<InstanceAlias> axleInstanceAliasesUnderCar = carInstance->GetNestedInstanceAliases(axleTemplateId);
PrefabDom& carTemplateDom = m_prefabSystemComponent->FindTemplateDom(carTemplateId);
@@ -381,7 +381,7 @@ namespace UnitTest
// Create an axle with 0 entities and 1 wheel instance.
AZStd::unique_ptr<Instance> wheel1UnderAxle = m_prefabSystemComponent->InstantiatePrefab(wheelTemplateId);
AZStd::unique_ptr<Instance> axleInstance = m_prefabSystemComponent->CreatePrefab({},
MakeInstanceList( AZStd::move(wheel1UnderAxle) ), AxlePrefabMockFilePath);
MakeInstanceList(AZStd::move(wheel1UnderAxle)), AxlePrefabMockFilePath);
const TemplateId axleTemplateId = axleInstance->GetTemplateId();
PrefabDom& axleTemplateDom = m_prefabSystemComponent->FindTemplateDom(axleTemplateId);
const AZStd::vector<InstanceAlias> wheelInstanceAliasesUnderAxle = axleInstance->GetNestedInstanceAliases(wheelTemplateId);
@@ -389,7 +389,7 @@ namespace UnitTest
// Create a car with 0 entities and 1 axle instance.
AZStd::unique_ptr<Instance> axleUnderCar = m_prefabSystemComponent->InstantiatePrefab(axleTemplateId);
AZStd::unique_ptr<Instance> carInstance = m_prefabSystemComponent->CreatePrefab({},
MakeInstanceList( AZStd::move(axleUnderCar) ), CarPrefabMockFilePath);
MakeInstanceList(AZStd::move(axleUnderCar)), CarPrefabMockFilePath);
const TemplateId carTemplateId = carInstance->GetTemplateId();
const AZStd::vector<InstanceAlias> axleInstanceAliasesUnderCar = carInstance->GetNestedInstanceAliases(axleTemplateId);
PrefabDom& carTemplateDom = m_prefabSystemComponent->FindTemplateDom(carTemplateId);
@@ -68,7 +68,7 @@ namespace UnitTest
// Create a car with 0 entities and 1 axle instance.
AZStd::unique_ptr<Instance> axleUnderCar = m_prefabSystemComponent->InstantiatePrefab(axleTemplateId);
AZStd::unique_ptr<Instance> carInstance = m_prefabSystemComponent->CreatePrefab({},
MakeInstanceList( AZStd::move(axleUnderCar) ), CarPrefabMockFilePath);
MakeInstanceList(AZStd::move(axleUnderCar)), CarPrefabMockFilePath);
const TemplateId carTemplateId = carInstance->GetTemplateId();
const AZStd::vector<InstanceAlias> axleInstanceAliasesUnderCar = carInstance->GetNestedInstanceAliases(axleTemplateId);
PrefabDom& carTemplateDom = m_prefabSystemComponent->FindTemplateDom(carTemplateId);