Open 3D Engine AzCore API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::SliceComponent::SliceReference Class Reference

#include <SliceComponent.h>

Public Types

using SliceInstances = AZStd::unordered_set< SliceInstance >
 
using PrefabInstances = SliceInstances
 

Public Member Functions

 AZ_TYPE_INFO (SliceReference, "{F181B80D-44F0-4093-BB0D-C638A9A734BE}")
 
SliceInstanceCreateInstance (const AZ::IdUtils::Remapper< AZ::EntityId >::IdMapper &customMapper=nullptr, SliceInstanceId sliceInstanceId=SliceInstanceId::CreateRandom())
 
SliceInstanceCreateInstanceFromExistingEntities (AZStd::vector< AZ::Entity * > &entities, const EntityIdToEntityIdMap &assetToLiveIdMap, SliceInstanceId sliceInstanceId=SliceInstanceId::CreateRandom())
 
SliceInstanceCloneInstance (SliceInstance *instance, EntityIdToEntityIdMap &sourceToCloneEntityIdMap)
 
void RestoreAndClearCachedInstance (SliceInstance &cachedInstance)
 
SliceInstanceFindInstance (const SliceInstanceId &instanceId)
 Locates an instance by Id.
 
SliceReference::SliceInstances::iterator RemoveInstance (SliceInstances::iterator itr)
 
bool RemoveInstance (SliceInstance *instance)
 Removes an instance of the slice.
 
bool RemoveEntity (EntityId entityId, bool isDeleteEntity, SliceInstance *instance=nullptr)
 Remove an entity if belongs to some of the instances.
 
const SliceInstancesGetInstances () const
 Retrieves the list of instances for this reference.
 
SliceInstancesGetInstances ()
 Retrieves the list of instances for this reference.
 
const Data::Asset< SliceAsset > & GetSliceAsset () const
 Retrieves the underlying asset pointer.
 
SliceComponentGetSliceComponent () const
 Retrieves the SliceComponent this reference belongs to.
 
bool IsInstantiated () const
 Checks if instances are instantiated.
 
bool GetInstanceEntityAncestry (const AZ::EntityId &instanceEntityId, EntityAncestorList &ancestors, u32 maxLevels=8) const
 
void ComputeDataPatch ()
 Compute data patch for all instances.
 
void ComputeDataPatch (SliceInstance *instance)
 Compute data patch for an individual instance.
 

Protected Member Functions

void ComputeDataPatchForInstanceKnownToReference (SliceInstance &instance, SerializeContext *serializeContext, InstantiatedContainer &sourceContainer)
 
SliceInstanceCreateEmptyInstance (const SliceInstanceId &instanceId=SliceInstanceId::CreateRandom())
 Creates a new Id'd instance slot internally, but does not instantiate it.
 
SliceInstancePrepareCreateInstance (const SliceInstanceId &sliceInstanceId, bool allowUninstantiated)
 
SliceInstanceFinalizeCreateInstance (SliceInstance &instance, void *remapContainer, const AZ::Uuid &classUuid, AZ::SerializeContext *serializeContext, const AZ::IdUtils::Remapper< AZ::EntityId >::IdMapper &customMapper=nullptr)
 Helper that performs EntityID remaps, registers the instance in the SliceReference's EntityInfoMap and fixes up MetaDataEntities.
 
bool Instantiate (const AZ::ObjectStream::FilterDescriptor &filterDesc)
 Instantiate all instances (by default we just hold the deltas - data patch), the Slice component controls the instantiate state.
 
void UnInstantiate ()
 
void InstantiateInstance (SliceInstance &instance, const AZ::ObjectStream::FilterDescriptor &filterDesc)
 
void AddInstanceToEntityInfoMap (SliceInstance &instance)
 
void RemoveInstanceFromEntityInfoMap (SliceInstance &instance)
 
void FixUpMetadataEntityForSliceInstance (SliceInstance *sliceInstance)
 

Protected Attributes

bool m_isInstantiated
 
SliceComponentm_component = nullptr
 
SliceInstances m_instances
 Instances of the slice in our slice reference.
 
Data::Asset< SliceAssetm_asset { Data::AssetLoadBehavior::PreLoad }
 Asset reference to a dependent slice reference.
 

Friends

class SliceComponent
 

Detailed Description

Reference to a dependent slice. Each dependent slice can have one or more instances in the current slice.

Member Typedef Documentation

◆ PrefabInstances

Member Function Documentation

◆ CloneInstance()

SliceInstance * AZ::SliceComponent::SliceReference::CloneInstance ( SliceInstance instance,
EntityIdToEntityIdMap sourceToCloneEntityIdMap 
)

Clones an existing slice instance

Parameters
instanceSource slice instance to be cloned
sourceToCloneEntityIdMap[out] The map between source entity ids and clone entity ids
Returns
A clone of instance

◆ ComputeDataPatchForInstanceKnownToReference()

void AZ::SliceComponent::SliceReference::ComputeDataPatchForInstanceKnownToReference ( SliceInstance instance,
SerializeContext serializeContext,
InstantiatedContainer sourceContainer 
)
protected

Internal only function that computes the data patch for the given instance. This assumes that the instance has already been verified to be related to this slice.

◆ CreateInstance()

SliceInstance * AZ::SliceComponent::SliceReference::CreateInstance ( const AZ::IdUtils::Remapper< AZ::EntityId >::IdMapper &  customMapper = nullptr,
SliceInstanceId  sliceInstanceId = SliceInstanceId::CreateRandom() 
)

Create a new instance of the slice (with new IDs for every entity).

Parameters
customMapperUsed to generate runtime entity ids for the new instance. By default runtime ids are randomly generated.
sliceInstanceIdThe id assigned to the slice instance to be created. If no argument is passed in and random id will be generated as default. If the same sliceInstanceId is already registered to this reference a null SliceInstance is returned as error.
Returns
A pointer to the newly created slice instance. Returns nullptr on error.

◆ CreateInstanceFromExistingEntities()

SliceInstance * AZ::SliceComponent::SliceReference::CreateInstanceFromExistingEntities ( AZStd::vector< AZ::Entity * > &  entities,
const EntityIdToEntityIdMap assetToLiveIdMap,
SliceInstanceId  sliceInstanceId = SliceInstanceId::CreateRandom() 
)

Create a new instance of the slice out of a list of existing entities

Parameters
entitiesA list of existing entities that will be moved into the new instance's InstantiatedContainer
assetToLiveIdMapA mapping between the asset EntityIDs of the slice asset and the "Live" entities passed in
sliceInstanceIdThe 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 this reference a null SliceInstance is returned as error.
Returns
A pointer to the newly created slice instance. Returns nullptr on error or if the SliceComponent is not instantiated.

◆ GetInstanceEntityAncestry()

bool AZ::SliceComponent::SliceReference::GetInstanceEntityAncestry ( const AZ::EntityId instanceEntityId,
EntityAncestorList ancestors,
u32  maxLevels = 8 
) const

Retrieves the specified entity's chain of ancestors and their associated assets along the slice data hierarchy.

Parameters
instanceEntityId- Must be Id of an entity within a live instance.
ancestors- Output list of ancestors, up to maxLevels.
maxLevels- Maximum cascade levels to explore.

◆ PrepareCreateInstance()

SliceInstance * AZ::SliceComponent::SliceReference::PrepareCreateInstance ( const SliceInstanceId sliceInstanceId,
bool  allowUninstantiated 
)
protected

Helper that returns a valid empty instance if the slice reference is able to make instances at time of call Otherwise returns a null slice instance

◆ RemoveInstance()

SliceReference::SliceInstances::iterator AZ::SliceComponent::SliceReference::RemoveInstance ( SliceInstances::iterator  itr)

Remove a slice instance.

Parameters
itrThe iterator to the slice instance to remove.
Returns
The iterator following the last removed slice instance.

◆ RestoreAndClearCachedInstance()

void AZ::SliceComponent::SliceReference::RestoreAndClearCachedInstance ( SliceInstance cachedInstance)

Restores ownership of the passed in slice instance to this SliceReference, and clears the passed in slice instance. This is used primarily by the layer system, to allow layers to briefly take ownership of slice instances that are saved to those layers.

Parameters
cachedInstanceA valid, cached slice instance that used to be owned by this reference.

The documentation for this class was generated from the following file: