Class that represents a prefab instance instantiated from a prefab template. More...
#include <Instance.h>
Public Types | |
using | AliasToInstanceMap = AZStd::unordered_map< InstanceAlias, AZStd::unique_ptr< Instance > > |
using | AliasToEntityMap = AZStd::unordered_map< EntityAlias, AZStd::unique_ptr< AZ::Entity > > |
Public Member Functions | |
AZ_CLASS_ALLOCATOR (Instance, AZ::SystemAllocator) | |
AZ_RTTI (Instance, "{D4219332-A648-4285-9CA6-B7F095987CD3}") | |
virtual | ~Instance () |
Destructor. | |
TemplateId | GetTemplateId () const |
void | SetTemplateId (TemplateId templateId) |
const AZ::IO::Path & | GetTemplateSourcePath () const |
void | SetTemplateSourcePath (AZ::IO::Path sourcePath) |
void | SetContainerEntityName (AZStd::string containerName) |
AZStd::unique_ptr< AZ::Entity > | DetachEntity (const AZ::EntityId &entityId) |
void | DetachEntities (const AZStd::function< void(AZStd::unique_ptr< AZ::Entity >)> &callback) |
void | DetachAllEntitiesInHierarchy (const AZStd::function< void(AZStd::unique_ptr< AZ::Entity >)> &callback) |
bool | DestroyEntity (const AZ::EntityId &entityId) |
AZStd::unique_ptr< AZ::Entity > | ReplaceEntity (AZStd::unique_ptr< AZ::Entity > &&entity, EntityAliasView alias) |
void | RemoveEntitiesInHierarchy (const AZStd::function< bool(const AZStd::unique_ptr< AZ::Entity > &)> &filter) |
Instance & | AddInstance (AZStd::unique_ptr< Instance > instance) |
AZStd::unique_ptr< Instance > | DetachNestedInstance (const InstanceAlias &instanceAlias) |
void | DetachNestedInstances (const AZStd::function< void(AZStd::unique_ptr< Instance >)> &callback) |
void | Reset () |
AZStd::vector< EntityAlias > | GetEntityAliases () |
size_t | GetEntityAliasCount () const |
void | GetNestedInstances (const AZStd::function< void(AZStd::unique_ptr< Instance > &)> &callback) |
AZ::EntityId | GetEntityId (const EntityAlias &alias) const |
AZ::EntityId | GetEntityIdFromAliasPath (AliasPathView relativeAliasPath) const |
AZStd::vector< InstanceAlias > | GetNestedInstanceAliases (TemplateId templateId) const |
void | ActivateContainerEntity () |
Activates the container entity. | |
void | SetLinkId (LinkId linkId) |
LinkId | GetLinkId () const |
AZStd::unique_ptr< AZ::Entity > | DetachContainerEntity () |
bool | DestroyContainerEntity () |
const InstanceAlias & | GetInstanceAlias () const |
AliasPath | GetAbsoluteInstanceAliasPath () const |
AliasPath | GetAliasPathRelativeToInstance (const AZ::EntityId &entity) const |
Instance () | |
Instance (AZStd::unique_ptr< AZ::Entity > containerEntity) | |
Instance (InstanceOptionalReference parent) | |
Instance (InstanceOptionalReference parent, InstanceAlias alias) | |
Instance (InstanceOptionalReference parent, InstanceAlias alias, EntityIdInstanceRelationship entityIdInstanceRelationship) | |
Instance (AZStd::unique_ptr< AZ::Entity > containerEntity, InstanceOptionalReference parent) | |
Instance (InstanceAlias alias) | |
Instance (EntityIdInstanceRelationship entityIdInstanceRelationship) | |
Instance (InstanceAlias alias, EntityIdInstanceRelationship entityIdInstanceRelationship) | |
Instance (const Instance &rhs)=delete | |
Instance & | operator= (const Instance &rhs)=delete |
bool | AddEntity (AZ::Entity &entity) |
bool | AddEntity (AZStd::unique_ptr< AZ::Entity > &&entity) |
bool | AddEntity (AZ::Entity &entity, EntityAlias entityAlias) |
bool | AddEntity (AZStd::unique_ptr< AZ::Entity > &&entity, EntityAlias entityAlias) |
void | GetEntityIds (const AZStd::function< bool(AZ::EntityId)> &callback) const |
void | GetEntityIdToAlias (const AZStd::function< bool(AZ::EntityId, EntityAliasView)> &callback) const |
void | GetEntities (const AZStd::function< bool(AZStd::unique_ptr< AZ::Entity > &)> &callback) |
void | GetConstEntities (const AZStd::function< bool(const AZ::Entity &)> &callback) const |
void | GetAllEntityIdsInHierarchy (const AZStd::function< bool(AZ::EntityId)> &callback) const |
void | GetAllEntitiesInHierarchy (const AZStd::function< bool(AZStd::unique_ptr< AZ::Entity > &)> &callback) |
void | GetAllEntitiesInHierarchyConst (const AZStd::function< bool(const AZ::Entity &)> &callback) const |
EntityAliasOptionalReference | GetEntityAlias (AZ::EntityId id) |
EntityAliasView | GetEntityAlias (AZ::EntityId id) const |
AZStd::pair< Instance *, EntityAliasView > | FindInstanceAndAlias (AZ::EntityId entity) |
AZStd::pair< const Instance *, EntityAliasView > | FindInstanceAndAlias (AZ::EntityId entity) const |
EntityOptionalReference | GetEntity (const EntityAlias &alias) |
EntityOptionalConstReference | GetEntity (const EntityAlias &alias) const |
AZStd::pair< Instance *, AZ::EntityId > | GetInstanceAndEntityIdFromAliasPath (AliasPathView relativeAliasPath) |
AZStd::pair< const Instance *, AZ::EntityId > | GetInstanceAndEntityIdFromAliasPath (AliasPathView relativeAliasPath) const |
InstanceOptionalReference | FindNestedInstance (const InstanceAlias &nestedInstanceAlias) |
InstanceOptionalConstReference | FindNestedInstance (const InstanceAlias &nestedInstanceAlias) const |
InstanceOptionalReference | GetParentInstance () |
InstanceOptionalConstReference | GetParentInstance () const |
bool | HasParentInstance () const |
bool | IsParentInstance (const Instance &instance) const |
AZ::EntityId | GetContainerEntityId () const |
bool | HasContainerEntity () const |
EntityOptionalReference | GetContainerEntity () |
EntityOptionalConstReference | GetContainerEntity () const |
void | SetContainerEntity (AZ::Entity &entity) |
PrefabDomConstReference | GetCachedInstanceDom () const |
PrefabDomReference | GetCachedInstanceDom () |
void | SetCachedInstanceDom (PrefabDomValueConstReference instanceDom) |
Static Public Member Functions | |
static void | Reflect (AZ::ReflectContext *context) |
static EntityAlias | GenerateEntityAlias () |
static InstanceAlias | GenerateInstanceAlias () |
Friends | |
class | AzToolsFramework::PrefabEditorEntityOwnershipService |
class | JsonInstanceSerializer |
class | InstanceEntityIdMapper |
Class that represents a prefab instance instantiated from a prefab template.
AzToolsFramework::Prefab::Instance::Instance | ( | ) |
Construtors.
|
delete |
Disables copy constructor and copy assignment.
bool AzToolsFramework::Prefab::Instance::AddEntity | ( | AZ::Entity & | entity | ) |
Adds entity to the instance. It registers the entity id and moves the entity ownership to the instance.
Instance & AzToolsFramework::Prefab::Instance::AddInstance | ( | AZStd::unique_ptr< Instance > | instance | ) |
Adds a new nested instance.
instance | The new nested instance. |
bool AzToolsFramework::Prefab::Instance::DestroyContainerEntity | ( | ) |
Detaches and deletes the container entity from the instance.
bool AzToolsFramework::Prefab::Instance::DestroyEntity | ( | const AZ::EntityId & | entityId | ) |
Detaches and deletes an entity from the instance.
entityId | The entity id to be detached and destroyed. |
void AzToolsFramework::Prefab::Instance::DetachAllEntitiesInHierarchy | ( | const AZStd::function< void(AZStd::unique_ptr< AZ::Entity >)> & | callback | ) |
Detaches all entities in the instance hierarchy. Includes all direct entities, all nested entities, and all container entities. Note that without container entities the hierarchy that remains cannot be used further without restoring new ones.
callback | A user provided callback that can be used to capture ownership and manipulate the detached entities. |
AZStd::unique_ptr< AZ::Entity > AzToolsFramework::Prefab::Instance::DetachContainerEntity | ( | ) |
Detaches the container entity from the instance. It unregisters the entity id and moves the entity ownership to the caller.
void AzToolsFramework::Prefab::Instance::DetachEntities | ( | const AZStd::function< void(AZStd::unique_ptr< AZ::Entity >)> & | callback | ) |
Detaches entities from the instance. It unregisters the entity ids and moves the entity ownerships to the callback provided by the caller.
callback | A user provided callback that can be used to capture ownership and manipulate the detached entities. |
AZStd::unique_ptr< AZ::Entity > AzToolsFramework::Prefab::Instance::DetachEntity | ( | const AZ::EntityId & | entityId | ) |
Detaches an entity from the instance. It unregisters the entity id and moves the entity ownership to the caller.
entityId | The entity id to be detached. |
AZStd::unique_ptr< Instance > AzToolsFramework::Prefab::Instance::DetachNestedInstance | ( | const InstanceAlias & | instanceAlias | ) |
Detaches a nested instance from the instance. It removes the nested instance and moves the instance ownership to the caller.
entityId | The entity id to be detached. |
void AzToolsFramework::Prefab::Instance::DetachNestedInstances | ( | const AZStd::function< void(AZStd::unique_ptr< Instance >)> & | callback | ) |
Detaches entities from the instance. It removes nested instances and moves the instance ownerships to the callback provided by the caller.
callback | A user provided callback that can be used to capture ownership and manipulate the detached instances. |
AZStd::pair< Instance *, EntityAliasView > AzToolsFramework::Prefab::Instance::FindInstanceAndAlias | ( | AZ::EntityId | entity | ) |
Searches for the entity in this instance and its nested instances. If the entity isn't found then the returned instance will be null and the alias will be empty.
InstanceOptionalReference AzToolsFramework::Prefab::Instance::FindNestedInstance | ( | const InstanceAlias & | nestedInstanceAlias | ) |
Finds a nested instance non-recursively by instance alias.
|
static |
Entity and instance alias generator functions.
AliasPath AzToolsFramework::Prefab::Instance::GetAbsoluteInstanceAliasPath | ( | ) | const |
Gets absolute instance alias path seen from root instance.
AliasPath AzToolsFramework::Prefab::Instance::GetAliasPathRelativeToInstance | ( | const AZ::EntityId & | entity | ) | const |
Gets relative alias path to entity.
entity | The entity that the relative path points to. |
void AzToolsFramework::Prefab::Instance::GetAllEntityIdsInHierarchy | ( | const AZStd::function< bool(AZ::EntityId)> & | callback | ) | const |
Gets the entity ids for all entities in hierarchy in the Instance DOM. A callback can be provided to manipulates the entities. Note: These are recursive operations that trace all nested instances.
PrefabDomConstReference AzToolsFramework::Prefab::Instance::GetCachedInstanceDom | ( | ) | const |
Getter and setter for cached instance DOM.
AZ::EntityId AzToolsFramework::Prefab::Instance::GetContainerEntityId | ( | ) | const |
Query, getter and setter functions for container entity.
EntityOptionalReference AzToolsFramework::Prefab::Instance::GetEntity | ( | const EntityAlias & | alias | ) |
Gets entity by a user provided entity alias.
EntityAliasOptionalReference AzToolsFramework::Prefab::Instance::GetEntityAlias | ( | AZ::EntityId | id | ) |
Gets the entity alias for a given entity id in the Instance DOM.
size_t AzToolsFramework::Prefab::Instance::GetEntityAliasCount | ( | ) | const |
Gets the entity alias count in the Instance DOM.
AZStd::vector< EntityAlias > AzToolsFramework::Prefab::Instance::GetEntityAliases | ( | ) |
Gets the aliases for the entities in the Instance DOM.
AZ::EntityId AzToolsFramework::Prefab::Instance::GetEntityId | ( | const EntityAlias & | alias | ) | const |
Gets the id for a given EnitityAlias in the Instance DOM.
alias | Entity alias used to retrieve the entity id. |
AZ::EntityId AzToolsFramework::Prefab::Instance::GetEntityIdFromAliasPath | ( | AliasPathView | relativeAliasPath | ) | const |
Retrieves the entity id from an alias path that's relative to this instance.
relativeAliasPath | Entity alias path relative to this instance. |
void AzToolsFramework::Prefab::Instance::GetEntityIds | ( | const AZStd::function< bool(AZ::EntityId)> & | callback | ) | const |
Gets the entities or entity ids in the Instance DOM. A callback can be provided to manipulates the entities. Note: These are non-recursive operations.
const InstanceAlias & AzToolsFramework::Prefab::Instance::GetInstanceAlias | ( | ) | const |
Getter for instance alias.
AZStd::pair< Instance *, AZ::EntityId > AzToolsFramework::Prefab::Instance::GetInstanceAndEntityIdFromAliasPath | ( | AliasPathView | relativeAliasPath | ) |
LinkId AzToolsFramework::Prefab::Instance::GetLinkId | ( | ) | const |
Gets link id.
AZStd::vector< InstanceAlias > AzToolsFramework::Prefab::Instance::GetNestedInstanceAliases | ( | TemplateId | templateId | ) | const |
Gets the aliases of all the nested instances, which are sourced by the template with the given id.
templateId | The source template id of the nested instances. |
void AzToolsFramework::Prefab::Instance::GetNestedInstances | ( | const AZStd::function< void(AZStd::unique_ptr< Instance > &)> & | callback | ) |
Gets the nested instances in the instance DOM. Note: This is a non-recursive operation.
callback | A user provided callback that manipulates the nested instances. |
InstanceOptionalReference AzToolsFramework::Prefab::Instance::GetParentInstance | ( | ) |
Query functions for parent instance.
TemplateId AzToolsFramework::Prefab::Instance::GetTemplateId | ( | ) | const |
Gets template id.
const AZ::IO::Path & AzToolsFramework::Prefab::Instance::GetTemplateSourcePath | ( | ) | const |
Gets template source path.
|
static |
AzCore Reflection.
context | reflection context. |
void AzToolsFramework::Prefab::Instance::RemoveEntitiesInHierarchy | ( | const AZStd::function< bool(const AZStd::unique_ptr< AZ::Entity > &)> & | filter | ) |
Detaches entities in the instance hierarchy based on the provided filter.
filter | A user provided filter used to decide whether an entity should be detached. Returns true to detach. |
AZStd::unique_ptr< AZ::Entity > AzToolsFramework::Prefab::Instance::ReplaceEntity | ( | AZStd::unique_ptr< AZ::Entity > && | entity, |
EntityAliasView | alias | ||
) |
Replaces the entity stored under the provided alias with a new one.
entity | The new entity. |
alias | The alias of the entity that will be replaced. |
void AzToolsFramework::Prefab::Instance::Reset | ( | ) |
Resets the instance to an initial state. It unregisters the instance, entities and nested instances.
void AzToolsFramework::Prefab::Instance::SetContainerEntityName | ( | AZStd::string | containerName | ) |
Sets container entity name.
containerName | New container entity name to be set. |
void AzToolsFramework::Prefab::Instance::SetLinkId | ( | LinkId | linkId | ) |
Sets link id.
linkId | Link id to be set. |
void AzToolsFramework::Prefab::Instance::SetTemplateId | ( | TemplateId | templateId | ) |
Sets template id.
templateId | Template id to be set. |
void AzToolsFramework::Prefab::Instance::SetTemplateSourcePath | ( | AZ::IO::Path | sourcePath | ) |
Sets template source path.
sourcePath | Template source path to be set. |