Open 3D Engine AzFramework 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.
AzFramework::EntityContext Class Reference

#include <EntityContext.h>

Inherits EntityIdContextQueryBus::MultiHandler, AZ::EntityBus::MultiHandler, EntityContextRequestBus::Handler, and EntityOwnershipServiceNotificationBus::Handler.

Inherited by AzFramework::GameEntityContextComponent.

Public Types

using SceneStorageType = EntityContext *
 The type used to store entity in AzFramework::Scene.
 

Public Member Functions

 AZ_TYPE_INFO (EntityContext, "{4F98A6B9-C7B5-450E-8A8A-30EEFC411EF5}")
 
 EntityContext (AZ::SerializeContext *serializeContext=nullptr)
 
 EntityContext (const EntityContextId &contextId, AZ::SerializeContext *serializeContext=nullptr)
 
 EntityContext (const EntityContextId &contextId, AZStd::unique_ptr< EntityOwnershipService > entityOwnershipService, AZ::SerializeContext *serializeContext=nullptr)
 
void InitContext ()
 
void DestroyContext ()
 
const EntityContextIdGetContextId () const
 
AZ::Entity * CreateEntity (const char *name) override
 
void AddEntity (AZ::Entity *entity) override
 
void ActivateEntity (AZ::EntityId entityId) override
 
void DeactivateEntity (AZ::EntityId entityId) override
 
bool DestroyEntity (AZ::Entity *entity) override
 
bool DestroyEntityById (AZ::EntityId entityId) override
 
AZ::Entity * CloneEntity (const AZ::Entity &sourceEntity) override
 
void ResetContext () override
 

Static Public Member Functions

static void Reflect (AZ::ReflectContext *context)
 
static AZStd::shared_ptr< SceneFindContainingScene (const EntityContextId &contextId)
 

Protected Member Functions

EntityContextId GetOwningContextId () override
 
void PrepareForEntityOwnershipServiceReset () override
 
void OnEntityOwnershipServiceReset () override
 
void OnEntitiesReloadedFromStream (const EntityList &entities) override
 
void OnEntityDestruction (const AZ::EntityId &entityId) override
 
void HandleEntitiesAdded (const EntityList &entities)
 
void HandleEntitiesRemoved (const EntityIdList &entityIds)
 
AZ::SerializeContext * GetSerializeContext () const
 
virtual void OnContextEntitiesAdded (const EntityList &)
 Entity context derived implementations can conduct specialized actions when internal events occur, such as adds/removals/resets.
 
virtual void OnContextEntityRemoved (const AZ::EntityId &)
 
virtual void OnRootEntityReloaded ()
 
virtual void PrepareForContextReset ()
 
virtual void OnContextReset ()
 
virtual bool ValidateEntitiesAreValidForContext (const EntityList &entities)
 
bool IsOwnedByThisContext (const AZ::EntityId &entityId)
 

Protected Attributes

AZ::SerializeContext * m_serializeContext
 
EntityContextId m_contextId
 Id of the context, used to address bus messages.
 
EntityContextEventBus::BusPtr m_eventBusPtr
 Pre-bound event bus for the context.
 
AZStd::unique_ptr< EntityOwnershipServicem_entityOwnershipService
 EntityOwnershipService is responsible for the management of entities used by this context. Such as loading, creation, etc.
 
bool m_contextIsResetting = false
 

Detailed Description

Provides services for a group of entities under the umbrella of a given context.

e.g. Edit-time entities and runtime entities would belong to separate contexts.

A context owns a root entity, which can be serialized in or out. Interfaces are provided for creating entities owned by the context.

Entity contexts are not required to use entities, but provide a package for managing independent prefab hierarchies (i.e. a level, a world, etc).

Member Function Documentation

◆ GetContextId()

const EntityContextId & AzFramework::EntityContext::GetContextId ( ) const
inline
Returns
the context's Id, which is used to listen on a given context's request or event bus.

◆ IsOwnedByThisContext()

bool AzFramework::EntityContext::IsOwnedByThisContext ( const AZ::EntityId &  entityId)
protected

Determine if the entity with the given ID is owned by this Entity Context

Parameters
entityIdAn entity ID to check
Returns
true if this context owns the entity with the given id.

◆ OnContextEntitiesAdded()

virtual void AzFramework::EntityContext::OnContextEntitiesAdded ( const EntityList &  )
inlineprotectedvirtual

Entity context derived implementations can conduct specialized actions when internal events occur, such as adds/removals/resets.

Reimplemented in AzFramework::GameEntityContextComponent.

◆ ValidateEntitiesAreValidForContext()

virtual bool AzFramework::EntityContext::ValidateEntitiesAreValidForContext ( const EntityList &  entities)
protectedvirtual

Used to validate that the given list of entities are valid for this context For example they could be non-UI entities being instantiated in a UI context

Reimplemented in AzFramework::GameEntityContextComponent.


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