#include <PrefabSystemComponent.h>
Inherits AZ::Component, AzToolsFramework::Prefab::PrefabSystemComponentInterface, AZ::SystemTickBus::Handler, and AzToolsFramework::AssetBrowser::AssetBrowserFileActionNotificationBus::Handler.
Public Types | |
using | TargetTemplateIdToLinkIdMap = AZStd::unordered_map< TemplateId, AZStd::pair< AZStd::unordered_set< LinkId >, bool > > |
Public Member Functions | |
AZ_COMPONENT (PrefabSystemComponent, "{27203AE6-A398-4614-881B-4EEB5E9B34E9}") | |
void | Init () override |
void | Activate () override |
void | Deactivate () override |
void | OnSystemTick () override |
void | OnSourceFilePathNameChanged (const AZStd::string_view fromPathName, const AZStd::string_view toPathName) override |
void | OnSourceFolderPathNameChanged (const AZStd::string_view fromPathName, const AZStd::string_view toPathName) override |
TemplateReference | FindTemplate (TemplateId id) override |
LinkReference | FindLink (const LinkId &id) override |
TemplateId | AddTemplate (const AZ::IO::Path &filePath, PrefabDom prefabDom) override |
void | UpdateTemplateFilePath (TemplateId templateId, const AZ::IO::PathView &filePath) override |
void | RemoveTemplate (TemplateId templateId) override |
void | RemoveAllTemplates () override |
AZStd::unique_ptr< Instance > | InstantiatePrefab (AZ::IO::PathView filePath, InstanceOptionalReference parent=AZStd::nullopt, const InstantiatedEntitiesCallback &instantiatedEntitiesCallback={}) override |
AZStd::unique_ptr< Instance > | InstantiatePrefab (TemplateId templateId, InstanceOptionalReference parent=AZStd::nullopt, const InstantiatedEntitiesCallback &instantiatedEntitiesCallback={}) override |
LinkId | AddLink (TemplateId sourceTemplateId, TemplateId targetTemplateId, PrefabDomValue::MemberIterator &instanceIterator, InstanceOptionalReference instance) override |
LinkId | CreateLink (TemplateId linkTargetId, TemplateId linkSourceId, const InstanceAlias &instanceAlias, const PrefabDomConstReference linkPatches, const LinkId &linkId=InvalidLinkId) override |
bool | RemoveLink (const LinkId &linkId) override |
TemplateId | GetTemplateIdFromFilePath (AZ::IO::PathView filePath) const override |
bool | IsTemplateDirty (TemplateId templateId) override |
void | SetTemplateDirtyFlag (TemplateId templateId, bool dirty) override |
bool | AreDirtyTemplatesPresent (TemplateId rootTemplateId) override |
void | SaveAllDirtyTemplates (TemplateId rootTemplateId) override |
AZStd::set< AZ::IO::PathView > | GetDirtyTemplatePaths (TemplateId rootTemplateId) override |
AZStd::unique_ptr< Instance > | CreatePrefab (const AZStd::vector< AZ::Entity * > &entities, AZStd::vector< AZStd::unique_ptr< Instance > > &&nestedInstances, AZ::IO::PathView filePath, AZStd::unique_ptr< AZ::Entity > containerEntity=nullptr, InstanceOptionalReference parent=AZStd::nullopt, bool shouldCreateLinks=true) override |
AZStd::unique_ptr< Instance > | CreatePrefabWithCustomEntityAliases (const AZStd::map< EntityAlias, AZ::Entity * > &entities, AZStd::vector< AZStd::unique_ptr< Instance > > &&nestedInstances, AZ::IO::PathView filePath, AZStd::unique_ptr< AZ::Entity > containerEntity=nullptr, InstanceOptionalReference parent=AZStd::nullopt, bool shouldCreateLinks=true) override |
PrefabDom & | FindTemplateDom (TemplateId templateId) override |
void | UpdatePrefabTemplate (TemplateId templateId, const PrefabDom &updatedDom) override |
void | PropagateTemplateChanges (TemplateId templateId, InstanceOptionalConstReference instanceToExclude=AZStd::nullopt) override |
void | UpdatePrefabInstances (TemplateId templateId, InstanceOptionalConstReference instanceToExclude=AZStd::nullopt) |
The prefab system component provides a central point for owning manipulating prefabs.
|
overridevirtual |
Add a new Link into Prefab System Component and create a unique id for it.
sourceTemplateId | The Id of Template whose instance is referred by targetTemplate. |
targetTemplateId | The Id of Template which owns this Link. |
instanceIterator | The Prefab DOM value iterator that points to the instance associated by this Link. |
instance | The instance that this link may point to. This is optional and can also take the value of nullopt. |
Implements AzToolsFramework::Prefab::PrefabSystemComponentInterface.
|
overridevirtual |
Add a new Template into Prefab System Component and create a unique id for it.
filePath | A file path where the Template file is located. |
prefabDom | A Prefab DOM presenting this Template. |
Implements AzToolsFramework::Prefab::PrefabSystemComponentInterface.
|
overridevirtual |
Recursive function to check if the template is dirty or if any dirty templates are presents in the links of the template.
rootTemplateId | The id of the template provided as the beginning template to check the outgoing links. |
Implements AzToolsFramework::Prefab::PrefabSystemComponentInterface.
|
overridevirtual |
Create a new Link with Prefab System Component and create a unique id for it.
linkTargetId | The Id of Template which owns this Link. |
linkSourceId | The Id of Template whose instance is referred by targetTemplate. |
instanceAlias | The alias of the instance that should be included in link. |
linkId | The id of the link. If invalid, create a new link id. If valid, use to recreate a prior link. |
Implements AzToolsFramework::Prefab::PrefabSystemComponentInterface.
|
overridevirtual |
Builds a new Prefab Template out of entities and instances and returns the first instance comprised of these entities and instances.
entities | A vector of entities that will be used in the new instance. May be empty. |
nestedInstances | A vector of Prefab Instances that will be nested in the new instance, will be consumed and moved. May be empty. |
filePath | The path to associate the template of the new instance to. |
containerEntity | The container entity for the prefab to be created. It will be created if a nullptr is provided. |
parent | Reference of an instance the created instance will be placed under, if given. |
shouldCreateLinks | The flag indicating if links should be created between the templates of the instance and its nested instances. |
Implements AzToolsFramework::Prefab::PrefabSystemComponentInterface.
|
overridevirtual |
Creates a prefab instance using the entities and nested instances provided.
entities | The map of entities to add to the instance. Map ensures insertion order. |
nestedInstances | The instances to add to the newly created instance. |
filePath | The path at which the prefab should be created. |
containerEntity | The container entity for the new instance. |
parent | The parent instance of the newly created instance. |
Implements AzToolsFramework::Prefab::PrefabSystemComponentInterface.
|
overridevirtual |
|
overridevirtual |
|
overridevirtual |
|
overridevirtual |
Recursive function that fetches the set of dirty templates given a starting template to check for outgoing links.
rootTemplateId | The id of the template provided as the beginning template to check the outgoing links. |
Implements AzToolsFramework::Prefab::PrefabSystemComponentInterface.
|
overridevirtual |
Get id of Template on given file path if it has already been loaded into Prefab System Component.
filePath | A path to a Prefab Template file. |
Implements AzToolsFramework::Prefab::PrefabSystemComponentInterface.
|
overridevirtual |
Generates a new Prefab Instance based on the Template whose source is stored in filepath.
filePath | The path to the prefab source file containing the template being instantiated. |
parent | Reference of the target instance the instantiated instance will be placed under. |
instantiatedEntitiesCallback | An optional callback that can be used to modify the instantiated entities. |
Implements AzToolsFramework::Prefab::PrefabSystemComponentInterface.
|
overridevirtual |
Generates a new Prefab Instance based on the Template referenced by templateId.
templateId | The id of the template being instantiated. |
parent | Reference of the target instance the instantiated instance will be placed under. |
instantiatedEntitiesCallback | An optional callback that can be used to modify the instantiated entities. |
Implements AzToolsFramework::Prefab::PrefabSystemComponentInterface.
|
overridevirtual |
Gets the value of the dirty flag of the template with the id provided.
templateId | The id of the template to query. |
Implements AzToolsFramework::Prefab::PrefabSystemComponentInterface.
|
overridevirtual |
|
overridevirtual |
Remove all Templates from the Prefab System Component.
Implements AzToolsFramework::Prefab::PrefabSystemComponentInterface.
|
overridevirtual |
Remove the Link associated with the given id from Prefab System Component.
linkId | A unique id of a Link. |
Implements AzToolsFramework::Prefab::PrefabSystemComponentInterface.
|
overridevirtual |
Remove the Template associated with the given id from Prefab System Component.
templateId | A unique id of a Template. |
Implements AzToolsFramework::Prefab::PrefabSystemComponentInterface.
|
overridevirtual |
Recursive function to save if the template is dirty and save all the dirty templates in the links of the template.
rootTemplateId | The id of the template provided as the beginning template to check the outgoing links. |
Implements AzToolsFramework::Prefab::PrefabSystemComponentInterface.
|
overridevirtual |
Sets the dirty flag of the template to the value provided.
templateId | The id of the template to flag. |
dirty | The new value of the dirty flag. |
Implements AzToolsFramework::Prefab::PrefabSystemComponentInterface.
void AzToolsFramework::Prefab::PrefabSystemComponent::UpdatePrefabInstances | ( | TemplateId | templateId, |
InstanceOptionalConstReference | instanceToExclude = AZStd::nullopt |
||
) |
Updates all Instances owned by a Template.
templateId | The id of the Template owning Instances to update. |
instanceToExclude | An optional reference to an instance of the template being updated that should not be refreshed as part of propagation.Defaults to nullopt, which means that all instances will be refreshed. |
|
overridevirtual |
Updates a template with the given updated DOM.
templateId | The id of the template to update. |
updatedDom | The DOM to update the template with. |
Implements AzToolsFramework::Prefab::PrefabSystemComponentInterface.
|
overridevirtual |
Updates relative filepath location of a prefab (in case of SaveAs operation).
templateId | An id of a Template to change filepath of. |
filePath | new relative path of the Template. |
Implements AzToolsFramework::Prefab::PrefabSystemComponentInterface.