Open 3D Engine AzToolsFramework 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.
AzToolsFramework::EntityCompositionRequests Class Referenceabstract

Inherits AZ::EBusTraits.

Classes

struct  AddComponentsResults
 
struct  PendingComponentInfo
 
struct  RemoveComponentsResults
 

Public Types

using EntityToAddedComponentsMap = AZStd::unordered_map< AZ::EntityId, AddComponentsResults >
 
using AddComponentsOutcome = AZ::Outcome< EntityToAddedComponentsMap, AZStd::string >
 
using AddExistingComponentsOutcome = AZ::Outcome< AddComponentsResults, AZStd::string >
 
using EntityToRemoveComponentsResultMap = AZStd::unordered_map< AZ::EntityId, RemoveComponentsResults >
 
using RemoveComponentsOutcome = AZ::Outcome< EntityToRemoveComponentsResultMap, AZStd::string >
 
using ScrubEntityResults = RemoveComponentsResults
 
using EntityToScrubEntityResultsMap = AZStd::unordered_map< AZ::EntityId, ScrubEntityResults >
 
using ScrubEntitiesOutcome = AZ::Outcome< EntityToScrubEntityResultsMap, AZStd::string >
 
using ComponentServicesList = AZStd::vector< AZ::ComponentServiceType >
 

Public Member Functions

virtual AddComponentsOutcome AddComponentsToEntities (const EntityIdList &entityIds, const AZ::ComponentTypeList &componentsToAdd)=0
 
virtual AddExistingComponentsOutcome AddExistingComponentsToEntityById (const AZ::EntityId &entityId, const AZStd::vector< AZ::Component * > &componentsToAdd)=0
 
virtual RemoveComponentsOutcome RemoveComponents (const AZStd::vector< AZ::Component * > &componentsToRemove)=0
 
virtual ScrubEntitiesOutcome ScrubEntities (const EntityList &entities)=0
 
virtual void CutComponents (const AZStd::vector< AZ::Component * > &components)=0
 
virtual void CopyComponents (const AZStd::vector< AZ::Component * > &components)=0
 
virtual void PasteComponentsToEntity (AZ::EntityId entityId)=0
 
virtual bool HasComponentsToPaste ()=0
 
virtual void EnableComponents (const AZStd::vector< AZ::Component * > &components)=0
 
virtual void DisableComponents (const AZStd::vector< AZ::Component * > &components)=0
 
virtual PendingComponentInfo GetPendingComponentInfo (const AZ::Component *component)=0
 
virtual AZStd::string GetComponentName (const AZ::Component *component)=0
 

Member Typedef Documentation

◆ AddComponentsOutcome

Outcome will be true if successful and return the above results structure to indicate what happened Outcome will be false if critical underlying system failure occurred (which is not expected) and an error string will describe the problem

◆ AddExistingComponentsOutcome

Outcome will be true if successful and return one instance of the above AddComponentsResults structure (since only one entity is involved)

◆ EntityToAddedComponentsMap

Stores a map of entity ids to component results that were added during AddComponentsToEntities. You can use this to look up what exactly happened to each entity involved. Components requested to be added will be stored in either addedPendingComponents or addedValidComponents Any other previously pending components that are now valid will be stored in additionalValidatedComponents

Member Function Documentation

◆ AddComponentsToEntities()

virtual AddComponentsOutcome AzToolsFramework::EntityCompositionRequests::AddComponentsToEntities ( const EntityIdList &  entityIds,
const AZ::ComponentTypeList &  componentsToAdd 
)
pure virtual

Add the specified component types to the specified entities.

Parameters
entityIdsEntities to receive the new components.
componentsToAddA list of AZ::Uuid representing the unique id of the type of components to add.
Returns
Returns a successful outcome if components were added to entities. If the operation could not be completed then the failed outcome contains a string describing what went wrong.

◆ AddExistingComponentsToEntityById()

virtual AddExistingComponentsOutcome AzToolsFramework::EntityCompositionRequests::AddExistingComponentsToEntityById ( const AZ::EntityId &  entityId,
const AZStd::vector< AZ::Component * > &  componentsToAdd 
)
pure virtual

Add the specified existing components to the specified entity.

Parameters
entityIdThe AZ::EntityId to add the existing components to, with full editor-level checking with pending component support
componentsToAddA list of AZ::Component* containing existing components to add. (Note: These components must not already be tied to another entity!)
Returns
Returns a successful outcome if components were added to entities. If the operation could not be completed then the failed outcome contains a string describing what went wrong.

◆ CopyComponents()

virtual void AzToolsFramework::EntityCompositionRequests::CopyComponents ( const AZStd::vector< AZ::Component * > &  components)
pure virtual

Copies the given components from their respective entities (multiple source entities are supported) into mime data on the clipboard for pasting elsewhere

Parameters
componentsvector of components to copy

◆ CutComponents()

virtual void AzToolsFramework::EntityCompositionRequests::CutComponents ( const AZStd::vector< AZ::Component * > &  components)
pure virtual

Removes the given components from their respective entities (currently only single entity is supported) and copies the data to the clipboard if successful

Parameters
componentsvector of components to cut (this method will delete the components provided on successful removal)

◆ DisableComponents()

virtual void AzToolsFramework::EntityCompositionRequests::DisableComponents ( const AZStd::vector< AZ::Component * > &  components)
pure virtual

Disables the given components

Parameters
componentsvector of components to disable

◆ EnableComponents()

virtual void AzToolsFramework::EntityCompositionRequests::EnableComponents ( const AZStd::vector< AZ::Component * > &  components)
pure virtual

Enables the given components

Parameters
componentsvector of components to enable

◆ GetComponentName()

virtual AZStd::string AzToolsFramework::EntityCompositionRequests::GetComponentName ( const AZ::Component *  component)
pure virtual

Returns a name for the given component Note: This will always dig into the underlying type. e.g. you will never get the GenericComponentWrapper name, but always the actual underlying component

Parameters
componentthe pointer to the component for which you want the name.

◆ HasComponentsToPaste()

virtual bool AzToolsFramework::EntityCompositionRequests::HasComponentsToPaste ( )
pure virtual

Checks if there is component data available to paste into an entity

Returns
true if paste is available, false otherwise

◆ PasteComponentsToEntity()

virtual void AzToolsFramework::EntityCompositionRequests::PasteComponentsToEntity ( AZ::EntityId  entityId)
pure virtual

Pastes components from the mime data on the clipboard (assuming it is component data) to the given entity

Parameters
entityIdthe Id of the entity to paste to

◆ RemoveComponents()

virtual RemoveComponentsOutcome AzToolsFramework::EntityCompositionRequests::RemoveComponents ( const AZStd::vector< AZ::Component * > &  componentsToRemove)
pure virtual

Removes the specified components from the specified entities.

Parameters
componentsToRemoveList of component pointers to remove (from their respective entities).
Returns
true if the components were successfully removed or false otherwise.

◆ ScrubEntities()

virtual ScrubEntitiesOutcome AzToolsFramework::EntityCompositionRequests::ScrubEntities ( const EntityList &  entities)
pure virtual

Scrub entities so that they can be activated. Components will be moved to the pending list if they cannot be activated. If a component had been pending, but can now be activated, then it will be re-enabled.

ScrubEntities() may be called on entities before they are initialized.

Returns
If successful, outcome contains details about the scrubbing. If unsuccessful, outcome contains a string describing what went wrong.

To decipher the outcome, understand that when you run the scrub an entity, 4 possible things can happen to each component: 1) Component was active before and remains active now --> These can be retrieved from Entity::GetComponents() and are unchanged 2) Component was active before, but is now INACTIVE due to invalid requirements. --> These are on the Outcome's m_invalidatedComponents list. --> They are also added to a EditorPendingCompositionComponent on the entity. This component's job is to keep track of invalid components and save their data in case they become active again in a later scrub. 3) Components which were inactive before (because of #2 above, in a previous scrub), but now have their requirements satisfied during this new scrub. --> These will be in Entity::GetComponents() but also the m_validated components list to distinguish them from the first case 1) above. 4) "Hidden" built-in components may be deprecated or invalid.
—> These will be deleted and a warning will be issued. They will not be in any list, since they are deleted.


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