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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user