#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}") | |
SliceInstance * | CreateInstance (const AZ::IdUtils::Remapper< AZ::EntityId >::IdMapper &customMapper=nullptr, SliceInstanceId sliceInstanceId=SliceInstanceId::CreateRandom()) |
SliceInstance * | CreateInstanceFromExistingEntities (AZStd::vector< AZ::Entity * > &entities, const EntityIdToEntityIdMap &assetToLiveIdMap, SliceInstanceId sliceInstanceId=SliceInstanceId::CreateRandom()) |
SliceInstance * | CloneInstance (SliceInstance *instance, EntityIdToEntityIdMap &sourceToCloneEntityIdMap) |
void | RestoreAndClearCachedInstance (SliceInstance &cachedInstance) |
SliceInstance * | FindInstance (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 SliceInstances & | GetInstances () const |
Retrieves the list of instances for this reference. | |
SliceInstances & | GetInstances () |
Retrieves the list of instances for this reference. | |
const Data::Asset< SliceAsset > & | GetSliceAsset () const |
Retrieves the underlying asset pointer. | |
SliceComponent * | GetSliceComponent () 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) |
SliceInstance * | CreateEmptyInstance (const SliceInstanceId &instanceId=SliceInstanceId::CreateRandom()) |
Creates a new Id'd instance slot internally, but does not instantiate it. | |
SliceInstance * | PrepareCreateInstance (const SliceInstanceId &sliceInstanceId, bool allowUninstantiated) |
SliceInstance * | FinalizeCreateInstance (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 |
SliceComponent * | m_component = nullptr |
SliceInstances | m_instances |
Instances of the slice in our slice reference. | |
Data::Asset< SliceAsset > | m_asset { Data::AssetLoadBehavior::PreLoad } |
Asset reference to a dependent slice reference. | |
Friends | |
class | SliceComponent |
Reference to a dependent slice. Each dependent slice can have one or more instances in the current slice.
SliceInstance * AZ::SliceComponent::SliceReference::CloneInstance | ( | SliceInstance * | instance, |
EntityIdToEntityIdMap & | sourceToCloneEntityIdMap | ||
) |
Clones an existing slice instance
instance | Source slice instance to be cloned |
sourceToCloneEntityIdMap | [out] The map between source entity ids and clone entity ids |
|
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.
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).
customMapper | Used to generate runtime entity ids for the new instance. By default runtime ids are randomly generated. |
sliceInstanceId | The 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. |
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
entities | A list of existing entities that will be moved into the new instance's InstantiatedContainer |
assetToLiveIdMap | A mapping between the asset EntityIDs of the slice asset and the "Live" entities passed in |
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 this reference a null SliceInstance is returned as error. |
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.
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. |
|
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
SliceReference::SliceInstances::iterator AZ::SliceComponent::SliceReference::RemoveInstance | ( | SliceInstances::iterator | itr | ) |
Remove a slice instance.
itr | The iterator to the slice instance to remove. |
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.
cachedInstance | A valid, cached slice instance that used to be owned by this reference. |