#include <SliceComponent.h>
Inherits AZ::Component, and Data::AssetBus::MultiHandler.
Classes | |
struct | Ancestor |
class | DataFlagsPerEntity |
struct | EntityInfo |
struct | EntityRestoreInfo |
struct | InstantiatedContainer |
class | SliceInstance |
class | SliceInstanceAddress |
class | SliceReference |
Public Member Functions | |
AZ_COMPONENT (SliceComponent, "{AFD304E4-1773-47C8-855A-8B622398934F}", Data::AssetEvents) | |
SerializeContext * | GetSerializeContext () const |
void | SetSerializeContext (SerializeContext *context) |
void | ListenForAssetChanges () |
Connect to asset bus for dependencies. | |
void | ListenForDependentAssetChanges () |
const EntityList & | GetNewEntities () const |
Returns list of the entities that are "new" for the current slice (not based on an existing slice) | |
bool | IsNewEntity (EntityId entityId) const |
Returns true for entities that are "new" entities in this slice (entities not based on another slice) | |
bool | GetEntities (EntityList &entities) |
void | EraseEntities (const EntityList &entities) |
void | AddEntities (const EntityList &entities) |
void | ReplaceEntities (const EntityList &entities) |
void | AddSliceInstances (SliceAssetToSliceInstancePtrs &sliceInstances, AZStd::unordered_set< const SliceInstance * > &instancesOut) |
bool | GetEntityIds (EntityIdSet &entities) |
size_t | GetInstantiatedEntityCount () const |
bool | GetMetadataEntityIds (EntityIdSet &entities) |
const SliceList & | GetSlices () const |
Returns list of all slices and their instantiated entities (for this slice component) | |
SliceList & | GetSlices () |
Returns list of all slices and their instantiated entities (for this slice component) | |
const SliceList & | GetInvalidSlices () const |
SliceReference * | GetSlice (const Data::Asset< SliceAsset > &sliceAsset) |
SliceReference * | GetSlice (const Data::AssetId &sliceAssetId) |
SliceInstanceAddress | AddSlice (const Data::Asset< SliceAsset > &sliceAsset, const AZ::IdUtils::Remapper< AZ::EntityId >::IdMapper &customMapper=nullptr, SliceInstanceId sliceInstanceId=SliceInstanceId::CreateRandom()) |
SliceInstanceAddress | AddSliceUsingExistingEntities (const Data::Asset< SliceAsset > &sliceAsset, const AZ::SliceComponent::EntityIdToEntityIdMap &assetToLiveMap, SliceInstanceId sliceInstanceId=SliceInstanceId::CreateRandom()) |
SliceReference * | AddSlice (SliceReference &sliceReference) |
Adds a slice reference (moves it) along with its instance information. | |
SliceInstanceAddress | AddSliceInstance (SliceReference *sliceReference, SliceInstance *sliceInstance) |
Adds a slice (moves it) from another already generated reference/instance pair. | |
SliceInstanceAddress | CloneAndAddSubSliceInstance (const SliceInstance *sourceSliceInstance, const AZStd::vector< AZ::SliceComponent::SliceInstanceAddress > &sourceSubSliceInstanceAncestry, const AZ::SliceComponent::SliceInstanceAddress &sourceSubSliceInstanceAddress, AZ::SliceComponent::EntityIdToEntityIdMap *out_sourceToCloneEntityIdMap=nullptr, bool preserveIds=false) |
bool | RemoveSlice (const Data::Asset< SliceAsset > &sliceAsset) |
Remove an entire slice asset reference and all its instances. | |
bool | RemoveSlice (const SliceReference *slice) |
bool | RemoveSliceInstance (SliceInstance *instance) |
Removes the slice instance, if this is last instance the SliceReference will be removed too. | |
bool | RemoveSliceInstance (SliceInstanceAddress sliceAddress) |
void | AddEntity (Entity *entity) |
Adds entity to the current slice and takes ownership over it (you should not manage/delete it) | |
AZ::Entity * | FindEntity (EntityId entityId) |
bool | RemoveEntity (Entity *entity, bool isDeleteEntity=true, bool isRemoveEmptyInstance=true) |
bool | RemoveEntity (EntityId entityId, bool isDeleteEntity=true, bool isRemoveEmptyInstance=true) |
Same as RemoveEntity but by using entityId. | |
bool | RemoveMetaDataEntity (EntityId metaDataEntityId) |
void | RemoveAllEntities (bool deleteEntities=true, bool removeEmptyInstances=true) |
void | RemoveLooseEntity (EntityId entityId) |
SliceInstanceAddress | FindSlice (Entity *entity) |
SliceInstanceAddress | FindSlice (EntityId entityId) |
bool | FlattenSlice (SliceReference *toFlatten, const EntityId &toFlattenRoot) |
bool | GetEntityRestoreInfo (const AZ::EntityId entityId, EntityRestoreInfo &info) |
SliceInstanceAddress | RestoreEntity (AZ::Entity *entity, const EntityRestoreInfo &restoreInfo, bool isEntityAdd=false) |
void | SetMyAsset (SliceAsset *asset) |
const SliceAsset * | GetMyAsset () const |
const DataPatch::FlagsMap & | GetEntityDataFlags (EntityId entityId) const |
bool | SetEntityDataFlags (EntityId entityId, const DataPatch::FlagsMap &dataFlags) |
DataPatch::Flags | GetEffectOfEntityDataFlagsAtAddress (EntityId, const DataPatch::AddressType &dataAddress) const |
DataPatch::Flags | GetEntityDataFlagsAtAddress (EntityId entityId, const DataPatch::AddressType &dataAddress) const |
bool | SetEntityDataFlagsAtAddress (EntityId entityId, const DataPatch::AddressType &dataAddress, DataPatch::Flags flags) |
bool | GetInstanceMetadataEntities (EntityList &outMetadataEntities) |
bool | GetAllInstanceMetadataEntities (EntityList &outMetadataEntities) |
bool | GetAllMetadataEntities (EntityList &outMetadataEntities) |
AZ::Entity * | GetMetadataEntity () |
void | GetReferencedSliceAssets (AssetIdSet &idSet, bool recurse=true) |
SliceComponent * | Clone (AZ::SerializeContext &serializeContext, SliceInstanceToSliceInstanceMap *sourceToCloneSliceInstanceMap=nullptr) const |
void | AllowPartialInstantiation (bool allow) |
bool | IsAllowPartialInstantiation () const |
bool | IsDynamic () const |
void | SetIsDynamic (bool isDynamic) |
InstantiateResult | Instantiate () |
bool | IsInstantiated () const |
void | GenerateNewEntityIds (EntityIdToEntityIdMap *previousToNewIdMap=nullptr) |
void | InitMetadata () |
void | RemoveAndCacheInstances (const SliceReferenceToInstancePtrs &instancesToRemove) |
void | RestoreCachedInstances () |
const DataFlagsPerEntity & | GetDataFlagsForInstances () const |
Public Member Functions inherited from AZ::Component | |
AZ_TYPE_INFO_WITH_NAME_DECL (Component) | |
AZ_RTTI_NO_TYPE_INFO_DECL () | |
Component () | |
virtual | ~Component () |
Entity * | GetEntity () const |
EntityId | GetEntityId () const |
NamedEntityId | GetNamedEntityId () const |
ComponentId | GetId () const |
virtual TypeId | GetUnderlyingComponentType () const |
void | SetId (const ComponentId &id) |
virtual void | SetSerializedIdentifier (AZStd::string serializedIdentifer) |
virtual AZStd::string | GetSerializedIdentifier () const |
virtual ComponentValidationResult | ValidateComponentRequirements (const ImmutableEntityVector &, const AZStd::unordered_set< AZ::Crc32 > &) const |
bool | SetConfiguration (const AZ::ComponentConfig &config) |
bool | GetConfiguration (AZ::ComponentConfig &outConfig) const |
Static Public Member Functions | |
static void | GetMappingBetweenSubsliceAndSourceInstanceEntityIds (const SliceComponent::SliceInstance *sourceSliceInstance, const AZStd::vector< AZ::SliceComponent::SliceInstanceAddress > &sourceSubsliceInstanceAncestry, const AZ::SliceComponent::SliceInstanceAddress &sourceSubsliceInstanceAddress, AZ::SliceComponent::EntityIdToEntityIdMap &subsliceToLiveMappingResult, bool flipMapping=false) |
Protected Types | |
typedef AZStd::vector< AZ::Data::AssetId > | AssetIdVector |
Protected Member Functions | |
void | Activate () override |
void | Deactivate () override |
void | OnAssetReloaded (Data::Asset< Data::AssetData > asset) override |
void | PrepareSave () |
Prepare component entity for save, if this is a leaf entity, data patch will be build. | |
void | BuildEntityInfoMap () |
Populate the entity info map. This will re-populate it even if already populated. | |
void | RebuildEntityInfoMapIfNecessary () |
Repopulate the entity info map if it was already populated. | |
DataFlagsPerEntity * | GetCorrectBundleOfDataFlags (EntityId entityId) |
Return the appropriate DataFlagsPerEntity collection containing this entity's data flags. | |
const DataFlagsPerEntity * | GetCorrectBundleOfDataFlags (EntityId entityId) const |
void | BuildDataFlagsForInstances () |
void | CleanMetadataAssociations () |
const EntityInfoMap & | GetEntityInfoMap () const |
Returns the entity info map (and builds it if necessary). | |
SliceReference * | AddOrGetSliceReference (const Data::Asset< SliceAsset > &sliceAsset) |
Returns the reference associated with the specified asset Id. If none is present, one will be created. | |
SliceComponent::SliceList::iterator | RemoveSliceReference (SliceComponent::SliceList::iterator sliceReferenceIt) |
Removes a slice reference (and all instances) by iterator. | |
void | PushInstantiateCycle (const AZ::Data::AssetId &assetId) |
Utility function to add an assetId to the cycle checker vector. | |
bool | CheckContainsInstantiateCycle (const AZ::Data::AssetId &assetId) |
void | PopInstantiateCycle (const AZ::Data::AssetId &assetId) |
Utility function to pop an assetId to the cycle checker vector (also checks to make sure its at the tail of it and clears it) | |
Protected Member Functions inherited from AZ::Component | |
virtual void | Init () |
virtual void | Activate ()=0 |
virtual void | Deactivate ()=0 |
virtual bool | ReadInConfig (const ComponentConfig *baseConfig) |
virtual bool | WriteOutConfig (ComponentConfig *outBaseConfig) const |
virtual void | SetEntity (Entity *entity) |
virtual void | OnAfterEntitySet () |
Function to call after setting the entity in this component. | |
Static Protected Member Functions | |
static void | GetProvidedServices (ComponentDescriptor::DependencyArrayType &provided) |
ComponentDescriptor::GetProvidedServices | |
static void | GetDependentServices (ComponentDescriptor::DependencyArrayType &dependent) |
ComponentDescriptor::GetDependentServices | |
static void | Reflect (ReflectContext *reflection) |
ComponentDescriptor::Reflect | |
static void | ApplyEntityMapId (EntityIdToEntityIdMap &destination, const EntityIdToEntityIdMap &mapping) |
Utility function to apply a EntityIdToEntityIdMap to a EntityIdToEntityIdMap (the mapping will override values in the destination) | |
Protected Attributes | |
SliceAsset * | m_myAsset |
Pointer to the asset we belong to, note this is just a reference stored by the handler, we don't need Asset<SliceAsset> as it's not a reference to another asset. | |
SerializeContext * | m_serializeContext |
EntityInfoMap | m_entityInfoMap |
A cached mapping built for quick lookups between an EntityId and its owning SliceInstance. | |
EntityInfoMap | m_metaDataEntityInfoMap |
A cached mapping built for quick lookups between a MetaDataEntityId and its owning SliceInstance. | |
EntityList | m_entities |
Entities that are new (not based on a slice). | |
SliceList | m_slices |
List of base slices and their instances in the world. | |
SliceAssetToSliceInstances | m_cachedSliceInstances |
Slice instances saved in layers on the root slice are cached here during the serialization process. | |
SliceList | m_cachedSliceReferences |
Slice references saved in layers on the root slice are cached here during the serialization process. | |
SliceList | m_invalidSlices |
List of slice references that did not load correctly. | |
AZ::Entity | m_metadataEntity |
Entity for attaching slice metadata components. | |
DataFlagsPerEntity | m_dataFlagsForNewEntities |
DataFlags for new entities (DataFlags for entities based on a slice are stored within the SliceInstance) | |
DataFlagsPerEntity | m_cachedDataFlagsForInstances |
Cached DataFlags to be used when instantiating instances of this slice. | |
bool | m_hasGeneratedCachedDataFlags |
Whether the cached DataFlags have been generated yet. | |
AZStd::atomic< bool > | m_slicesAreInstantiated |
Instantiate state of the base slices (they should be instantiated or not) | |
bool | m_allowPartialInstantiation |
Instantiation is still allowed even if dependencies are missing. | |
bool | m_isDynamic |
Dynamic slices are available for instantiation at runtime. | |
AZ::Data::AssetFilterCB | m_assetLoadFilterCB |
Asset load filter callback to apply for internal loads during data patching. | |
AZ::u32 | m_filterFlags |
Asset load filter flags to apply for internal loads during data patching. | |
AZStd::recursive_mutex | m_instantiateMutex |
Used to prevent multiple threads from trying to instantiate the slices at once. | |
Protected Attributes inherited from AZ::Component | |
Entity * | m_entity |
Reference to the entity that owns the component. The value is null if the component is not attached to an entity. | |
ComponentId | m_id |
A component ID that is unique for an entity. This component ID is not unique across all entities. | |
Static Protected Attributes | |
static AssetIdVector | m_instantiateCycleChecker |
Used to prevent cyclic dependencies. | |
Friends | |
class | SliceComponentSerializationEvents |
class | SliceAssetHandler |
Slice component manages entities on the project graph (Slice is a node). SliceComponent with nested dependencies is an edit only concept. We have a runtime version with dependencies so that we can accelerate production by live tweaking of game objects. Otherwise all slices should be exported as list of entities (flat structure). There is an exception with the "dynamic" slices, which should still be a flat list of entities that you "clone" for dynamic reuse.
|
overrideprotectedvirtual |
Puts the component into an active state. The system calls this function once during activation of each entity that owns the component. You must override this function. The system calls a component's Activate() function only if all services and components that the component depends on are present and active. Use GetProvidedServices and GetDependentServices to specify these dependencies.
Implements AZ::Component.
void AZ::SliceComponent::AddEntities | ( | const EntityList & | entities | ) |
Adds the passed in entities to become owned and tracked by this slice. Used by the layer system to return entities that were briefly borrowed from the root slice. entities The list of entitites to add to this slice.
SliceInstanceAddress AZ::SliceComponent::AddSlice | ( | const Data::Asset< SliceAsset > & | sliceAsset, |
const AZ::IdUtils::Remapper< AZ::EntityId >::IdMapper & | customMapper = nullptr , |
||
SliceInstanceId | sliceInstanceId = SliceInstanceId::CreateRandom() |
||
) |
Adds a dependent slice, and instantiate the slices if needed.
sliceAsset | slice asset. |
customMapper | optional entity runtime id mapper. |
assetLoadFilter | Optional asset load filter. Any filtered-out asset references that are not already memory-resident will not trigger loads. |
sliceInstanceId | The id assigned to the slice instance to be created. If no argument is passed in a random id will be generated as default. If the same sliceInstanceId is already registered to the underlying SlicReference an invalid SliceInstanceAddress is returned as error. |
void AZ::SliceComponent::AddSliceInstances | ( | SliceAssetToSliceInstancePtrs & | sliceInstances, |
AZStd::unordered_set< const SliceInstance * > & | instancesOut | ||
) |
Adds the passed in slice instances to this slice. Used by the layer system on load, when a layer is loaded, it may contain one or more slice instances. This allows layers to populate the root slice with those instances.
sliceInstances | instances that will be given to this slice. It will be empty after this operation completes. |
SliceInstanceAddress AZ::SliceComponent::AddSliceUsingExistingEntities | ( | const Data::Asset< SliceAsset > & | sliceAsset, |
const AZ::SliceComponent::EntityIdToEntityIdMap & | assetToLiveMap, | ||
SliceInstanceId | sliceInstanceId = SliceInstanceId::CreateRandom() |
||
) |
sliceAsset | Asset of the slice being added |
assetToLiveMap | Mapping from the provided slice asset's EntityID's to existing EntityIDs. Existing EntityIDs should be owned by the SliceComponent making this call. |
sliceInstanceId | The id assigned to the slice instance to be created. If no argument is passed in a random id will be generated as default. If the same sliceInstanceId is already registered to an invalid SliceInstanceAddress is returned as error. |
|
inline |
Set whether the slice can be instantiated despite missing dependent slices (allowed by default).
|
protected |
Utility function to check if the given assetId would cause an instantiation cycle, and if so output the chain of slices that causes the cycle.
|
protected |
During instance instantiation, entities from root slices may be removed by data patches. We need to remove these from the metadata associations in our newly cloned instance metadata entities.
SliceComponent * AZ::SliceComponent::Clone | ( | AZ::SerializeContext & | serializeContext, |
SliceInstanceToSliceInstanceMap * | sourceToCloneSliceInstanceMap = nullptr |
||
) | const |
Clones the slice, its references, and its instances. Entity Ids are not regenerated during this process. This utility is currently used to clone slice asset data for data-push without modifying the existing asset in-memory.
serializeContext | SerializeContext to use for cloning |
sourceToCloneSliceInstanceMap | [out] (optional) The map between source SliceInstances and cloned SliceInstances. |
SliceInstanceAddress AZ::SliceComponent::CloneAndAddSubSliceInstance | ( | const SliceInstance * | sourceSliceInstance, |
const AZStd::vector< AZ::SliceComponent::SliceInstanceAddress > & | sourceSubSliceInstanceAncestry, | ||
const AZ::SliceComponent::SliceInstanceAddress & | sourceSubSliceInstanceAddress, | ||
AZ::SliceComponent::EntityIdToEntityIdMap * | out_sourceToCloneEntityIdMap = nullptr , |
||
bool | preserveIds = false |
||
) |
Given a sub-slice instance, create a slice reference based on the sub-slice instance's SliceAsset (if the slice reference doesn't already exist), then clone the sub-slice instance and add the clone to the slice reference just created.
sourceSliceInstance | The slice instance that contains the sub-slice instance. |
sourceSubSliceInstanceAncestry | The ancestry in order from sourceSubSlice to sourceSlice |
sourceSubSliceInstanceAddress | The address of the sub-slice instance to be cloned. |
out_sourceToCloneEntityIdMap | [Optional] If provided, the internal source to clone entity ID map will be returned |
preserveIds | [Optional] If true will not generate new IDs for the clone and will direct entity ID maps from base ID to existing live IDs of the original |
|
overrideprotectedvirtual |
Deactivates the component. The system calls this function when the owning entity is being deactivated. You must override this function. As a best practice, ensure that this function returns the component to a minimal footprint. The order of deactivation is the reverse of activation, so your component is deactivated before the components it depends on.
The system always calls the component's Deactivate() function before destroying the component. However, deactivation is not always followed by the destruction of the component. An entity and its components can be deactivated and reactivated without being destroyed. Ensure that your Deactivate() implementation can handle this scenario.
Implements AZ::Component.
void AZ::SliceComponent::EraseEntities | ( | const EntityList & | entities | ) |
Erases all entities passed in from this slice's m_entities list of loose, owned entities.
entities | The list of entities to erase. |
AZ::Entity * AZ::SliceComponent::FindEntity | ( | EntityId | entityId | ) |
Find an entity in the slice by entity Id.
SliceInstanceAddress AZ::SliceComponent::FindSlice | ( | Entity * | entity | ) |
Returns the slice information about an entity, if it belongs to the component and is in a slice.
entity | pointer to instantiated entity |
bool AZ::SliceComponent::FlattenSlice | ( | SliceReference * | toFlatten, |
const EntityId & | toFlattenRoot | ||
) |
Flattens a slice reference directly into the slice component and then removes the reference, all dependencies inherited from the reference will become directly owned by the slice component
toFlatten | The reference we are flattening into the component |
toFlattenRoot | The root entity used to determine common ancestry among the entities within the reference |
void AZ::SliceComponent::GenerateNewEntityIds | ( | EntityIdToEntityIdMap * | previousToNewIdMap = nullptr | ) |
Generate new entity Ids and remap references
previousToNewIdMap | Output map of previous entityIds to newly generated entityIds |
bool AZ::SliceComponent::GetAllInstanceMetadataEntities | ( | EntityList & | outMetadataEntities | ) |
Appends all metadata entities belonging to instances owned by this slice, including those in nested instances to the end of the given list.
bool AZ::SliceComponent::GetAllMetadataEntities | ( | EntityList & | outMetadataEntities | ) |
Gets all metadata entities belonging to this slice. This includes instance metadata components and the slice's own metadata component. Because the contents of the result could come from multiple objects, the calling function must provide its own container. Returns true if the operation succeeded (Even if the resulting container is empty)
const DataFlagsPerEntity & AZ::SliceComponent::GetDataFlagsForInstances | ( | ) | const |
Returns data flags for use when instantiating an instance of this slice. These data flags include those harvested from the entire slice ancestry.
DataPatch::Flags AZ::SliceComponent::GetEffectOfEntityDataFlagsAtAddress | ( | EntityId | , |
const DataPatch::AddressType & | dataAddress | ||
) | const |
Get effect of data flags at a particular address within this entity. Note that the "effect" of data flags could be impacted by data flags set at other addresses, and data flags set in the slice that this entity is based on.
bool AZ::SliceComponent::GetEntities | ( | EntityList & | entities | ) |
Returns all entities including the ones based on instances, you need to provide container as we don't keep all entities in one list (we can change that if we need it easily). If entities are not instantiated (the ones based on slices) Instantiate will be called
const DataPatch::FlagsMap & AZ::SliceComponent::GetEntityDataFlags | ( | EntityId | entityId | ) | const |
Return all data flags set for this entity. Addresses are relative the entity.
DataPatch::Flags AZ::SliceComponent::GetEntityDataFlagsAtAddress | ( | EntityId | entityId, |
const DataPatch::AddressType & | dataAddress | ||
) | const |
Get the data flags set at a particular address within this entity.
bool AZ::SliceComponent::GetEntityIds | ( | EntityIdSet & | entities | ) |
Adds the IDs of all non-metadata entities, including the ones based on instances, to the provided set.
entities | An entity ID set to add the IDs to |
bool AZ::SliceComponent::GetEntityRestoreInfo | ( | const AZ::EntityId | entityId, |
EntityRestoreInfo & | info | ||
) |
Extracts data required to restore the specified entity.
bool AZ::SliceComponent::GetInstanceMetadataEntities | ( | EntityList & | outMetadataEntities | ) |
Appends the metadata entities belonging only directly to each instance in the slice to the given list. Metadata entities belonging to any instances within each instance are omitted.
size_t AZ::SliceComponent::GetInstantiatedEntityCount | ( | ) | const |
Returns the count of all instantiated entities, including the ones based on instances. If the slice has not been instantiated then 0 is returned.
const SliceList & AZ::SliceComponent::GetInvalidSlices | ( | ) | const |
Returns the list of slice references associated with this slice that could not be loaded.
|
static |
sourceSliceInstance | The slice instance that contains the sub-slice instance |
sourceSubsliceInstanceAncestry | The ancestry in order from sourceSubslice to sourceSlice |
sourceSubsliceInstanceAddress | The address of the sub-slice instance to be cloned |
subsliceToLiveMappingResult | Stores the resulting mapping from the sub slice's base Entity Ids to the source slice's live Entity Ids |
flipMapping | subsliceToLiveMappingResult will be flipped to instead contain the mapping from source slice to sub slice. Defaults to false |
AZ::Entity * AZ::SliceComponent::GetMetadataEntity | ( | ) |
Gets the metadata entity belonging to this slice
bool AZ::SliceComponent::GetMetadataEntityIds | ( | EntityIdSet & | entities | ) |
Adds ID of every metadata entity that's part of this slice, including those based on instances, to the given set.
entities | An entity ID set to add the IDs to |
|
inline |
Gets the asset that owns this component.
void AZ::SliceComponent::GetReferencedSliceAssets | ( | AssetIdSet & | idSet, |
bool | recurse = true |
||
) |
Gathers referenced slice assets for this slice (slice assets this contains, slice assets this depends on)
idSet | the container that contains the referenced assets after this function is called |
recurse | whether to recurse. true by default so you get ALL referenced assets, false will return only directly-referenced assets |
void AZ::SliceComponent::InitMetadata | ( | ) |
Newly created slices and legacy slices won't have required metadata components. This will check to see if necessary components to the function of the metadata entities are present and
instance | Source slice instance |
InstantiateResult AZ::SliceComponent::Instantiate | ( | ) |
Instantiate entities for this slice, otherwise only the data are stored.
|
inline |
Returns whether or not the slice allows partial instantiation.
|
inline |
Returns whether or not this is a dynamic slice to be exported for runtime instantiation.
void AZ::SliceComponent::ListenForDependentAssetChanges | ( | ) |
This will listen for child asset changes and instruct all other slices in the slice hierarchy to do the same.
void AZ::SliceComponent::RemoveAllEntities | ( | bool | deleteEntities = true , |
bool | removeEmptyInstances = true |
||
) |
A performant way to remove every entity from a SliceComponent. Operates in the same way as though you were to loop through every entity in a SliceComponent and call RemoveEntity(entityId) on them, but using this method will be much faster and is highly recommended.
deleteEntities | true by default as we own all entities, pass false to just remove the entity and gain ownership of it |
removeEmptyInstances | true by default. When set to true, instances will be removed when the last of their entities is removed |
void AZ::SliceComponent::RemoveAndCacheInstances | ( | const SliceReferenceToInstancePtrs & | instancesToRemove | ) |
Removes the passed in instances from this slice, and caches them to restore later. Used by the layer system so layers can briefly take ownership of these instances. This allows the level slice to save with only slice instances and references unique to the level, and allows layers to save slices instances and references to themselves. instancesToRemove The collection of instances that should be removed from this slice.
bool AZ::SliceComponent::RemoveMetaDataEntity | ( | EntityId | metaDataEntityId | ) |
Removes and deletes a meta data entity from the current slice
metaDataEntityId | EntityId of the to be removed meta data entity |
void AZ::SliceComponent::ReplaceEntities | ( | const EntityList & | entities | ) |
Clears the m_entities list for this slice and replaces it with the passed in entity list. Used by the layer system to return entities it borrowed. Used as a performance shortcut, the layer system will have already retrieved a complete list of all entities managed by this slice.
entities | The list of entities to replace m_entities with. |
void AZ::SliceComponent::RestoreCachedInstances | ( | ) |
Restores slice instances that were cached when RemoveAndCacheInstances was called.
SliceInstanceAddress AZ::SliceComponent::RestoreEntity | ( | AZ::Entity * | entity, |
const EntityRestoreInfo & | restoreInfo, | ||
bool | isEntityAdd = false |
||
) |
Adds an entity back to an existing instance. This create a reference for the specified asset if it doesn't already exist. If the reference exists, but the instance with the specified id does not, one will be created. Ownership of the entity is transferred to the instance.
entity | A pointer to the entity to be restored. |
restoreInfo | An object holding various information for restoring the entity. Please see EntityRestoreInfo. |
isEntityAdd | specifies if the entity we're restoring is part of an entity add. Skips checks for if the entity is in the SliceComponent. As the entity will not be a part of the SliceComponent until it is restored. Defaults to false. |
bool AZ::SliceComponent::SetEntityDataFlags | ( | EntityId | entityId, |
const DataPatch::FlagsMap & | dataFlags | ||
) |
Set all data flags for this entity. Addresses should be relative the entity.
bool AZ::SliceComponent::SetEntityDataFlagsAtAddress | ( | EntityId | entityId, |
const DataPatch::AddressType & | dataAddress, | ||
DataPatch::Flags | flags | ||
) |
Set the data flags at a particular address within this entity.
|
inline |
Designates this slice as dynamic (can be instantiated at runtime).
|
inline |
Sets the asset that owns this component, which allows us to listen for asset changes.