Open 3D Engine Multiplayer Gem 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.
Multiplayer::NetworkEntityManager Class Referencefinal

#include <NetworkEntityManager.h>

Inherits Multiplayer::INetworkEntityManager, AzFramework::RootSpawnableNotificationBus::Handler, and AzFramework::SpawnableAssetEventsBus::Handler.

Public Member Functions

void DispatchLocalDeferredRpcMessages ()
 
void Reset ()
 Used to release all memory prior to shutdown.
 
void Initialize (const HostId &hostId, AZStd::unique_ptr< IEntityDomain > entityDomain) override
 
bool IsInitialized () const override
 
IEntityDomainGetEntityDomain () const override
 
NetworkEntityTrackerGetNetworkEntityTracker () override
 
NetworkEntityAuthorityTrackerGetNetworkEntityAuthorityTracker () override
 
MultiplayerComponentRegistryGetMultiplayerComponentRegistry () override
 
const HostId & GetHostId () const override
 
ConstNetworkEntityHandle GetEntity (NetEntityId netEntityId) const override
 
NetEntityId GetNetEntityIdById (const AZ::EntityId &entityId) const override
 
EntityList CreateEntitiesImmediate (const AzFramework::Spawnable &spawnable, NetEntityRole netEntityRole, const AZ::Transform &transform, AutoActivate autoActivate)
 
EntityList CreateEntitiesImmediate (const PrefabEntityId &prefabEntryId, NetEntityRole netEntityRole, const AZ::Transform &transform, AutoActivate autoActivate=AutoActivate::Activate) override
 
EntityList CreateEntitiesImmediate (const PrefabEntityId &prefabEntryId, NetEntityId netEntityId, NetEntityRole netEntityRole, AutoActivate autoActivate, const AZ::Transform &transform) override
 
AZStd::unique_ptr< AzFramework::EntitySpawnTicket > RequestNetSpawnableInstantiation (const AZ::Data::Asset< AzFramework::Spawnable > &netSpawnable, const AZ::Transform &transform) override
 
void SetupNetEntity (AZ::Entity *netEntity, PrefabEntityId prefabEntityId, NetEntityRole netEntityRole) override
 
uint32_t GetEntityCount () const override
 
NetworkEntityHandle AddEntityToEntityMap (NetEntityId netEntityId, AZ::Entity *entity) override
 
void RemoveEntityFromEntityMap (NetEntityId netEntityId) override
 
void MarkForRemoval (const ConstNetworkEntityHandle &entityHandle) override
 
bool IsMarkedForRemoval (const ConstNetworkEntityHandle &entityHandle) const override
 
void ClearEntityFromRemovalList (const ConstNetworkEntityHandle &entityHandle) override
 
void ClearAllEntities () override
 Clears out and deletes all entities registered with the entity manager.
 
void AddEntityMarkedDirtyHandler (AZ::Event<>::Handler &entityMarkedDirtyHandle) override
 
void AddEntityNotifyChangesHandler (AZ::Event<>::Handler &entityNotifyChangesHandle) override
 
void AddEntityExitDomainHandler (EntityExitDomainEvent::Handler &entityExitDomainHandler) override
 
void AddControllersActivatedHandler (ControllersActivatedEvent::Handler &controllersActivatedHandler) override
 
void AddControllersDeactivatedHandler (ControllersDeactivatedEvent::Handler &controllersDeactivatedHandler) override
 
void NotifyEntitiesDirtied () override
 Notifies entities that they should process their dirty state.
 
void NotifyEntitiesChanged () override
 Notifies entities that they should process change notifications.
 
void NotifyControllersActivated (const ConstNetworkEntityHandle &entityHandle, EntityIsMigrating entityIsMigrating) override
 
void NotifyControllersDeactivated (const ConstNetworkEntityHandle &entityHandle, EntityIsMigrating entityIsMigrating) override
 
void HandleLocalRpcMessage (NetworkEntityRpcMessage &message) override
 
void HandleEntitiesExitDomain (const NetEntityIdSet &entitiesNotInDomain) override
 
void ForceAssumeAuthority (const ConstNetworkEntityHandle &entityHandle) override
 
void MarkAlwaysRelevantToClients (const ConstNetworkEntityHandle &entityHandle, bool alwaysRelevant) override
 
void MarkAlwaysRelevantToServers (const ConstNetworkEntityHandle &entityHandle, bool alwaysRelevant) override
 
const NetEntityHandleSet & GetAlwaysRelevantToClientsSet () const override
 
const NetEntityHandleSet & GetAlwaysRelevantToServersSet () const override
 
void SetMigrateTimeoutTimeMs (AZ::TimeMs timeoutTimeMs) override
 
void DebugDraw () const override
 Visualization of network entity manager state.
 
void OnRootSpawnableAssigned (AZ::Data::Asset< AzFramework::Spawnable > rootSpawnable, uint32_t generation) override
 
void OnRootSpawnableReleased (uint32_t generation) override
 
void OnResolveAliases (AzFramework::Spawnable::EntityAliasVisitor &aliases, const AzFramework::SpawnableMetaData &metadata, const AzFramework::Spawnable::EntityList &entities) override
 
- Public Member Functions inherited from Multiplayer::INetworkEntityManager
 AZ_RTTI (INetworkEntityManager, "{109759DE-9492-439C-A0B1-AE46E6FD029C}")
 
virtual void Initialize (const HostId &hostId, AZStd::unique_ptr< IEntityDomain > entityDomain)=0
 
virtual bool IsInitialized () const =0
 
virtual IEntityDomainGetEntityDomain () const =0
 
virtual NetworkEntityTrackerGetNetworkEntityTracker ()=0
 
virtual NetworkEntityAuthorityTrackerGetNetworkEntityAuthorityTracker ()=0
 
virtual MultiplayerComponentRegistryGetMultiplayerComponentRegistry ()=0
 
virtual const HostId & GetHostId () const =0
 
virtual EntityList CreateEntitiesImmediate (const PrefabEntityId &prefabEntryId, NetEntityRole netEntityRole, const AZ::Transform &transform, AutoActivate autoActivate=AutoActivate::Activate)=0
 
virtual EntityList CreateEntitiesImmediate (const PrefabEntityId &prefabEntryId, NetEntityId netEntityId, NetEntityRole netEntityRole, AutoActivate autoActivate, const AZ::Transform &transform)=0
 
virtual AZStd::unique_ptr< AzFramework::EntitySpawnTicket > RequestNetSpawnableInstantiation (const AZ::Data::Asset< AzFramework::Spawnable > &netSpawnable, const AZ::Transform &transform)=0
 
virtual void SetupNetEntity (AZ::Entity *netEntity, PrefabEntityId prefabEntityId, NetEntityRole netEntityRole)=0
 
virtual ConstNetworkEntityHandle GetEntity (NetEntityId netEntityId) const =0
 
virtual uint32_t GetEntityCount () const =0
 
virtual NetEntityId GetNetEntityIdById (const AZ::EntityId &entityId) const =0
 
virtual NetworkEntityHandle AddEntityToEntityMap (NetEntityId netEntityId, AZ::Entity *entity)=0
 
virtual void RemoveEntityFromEntityMap (NetEntityId netEntityId)=0
 
virtual void MarkForRemoval (const ConstNetworkEntityHandle &entityHandle)=0
 
virtual bool IsMarkedForRemoval (const ConstNetworkEntityHandle &entityHandle) const =0
 
virtual void ClearEntityFromRemovalList (const ConstNetworkEntityHandle &entityHandle)=0
 
virtual void ClearAllEntities ()=0
 Clears out and deletes all entities registered with the entity manager.
 
virtual void AddEntityMarkedDirtyHandler (AZ::Event<>::Handler &entityMarkedDirtyHandle)=0
 
virtual void AddEntityNotifyChangesHandler (AZ::Event<>::Handler &entityNotifyChangesHandle)=0
 
virtual void AddEntityExitDomainHandler (EntityExitDomainEvent::Handler &entityExitDomainHandler)=0
 
virtual void AddControllersActivatedHandler (ControllersActivatedEvent::Handler &controllersActivatedHandler)=0
 
virtual void AddControllersDeactivatedHandler (ControllersDeactivatedEvent::Handler &controllersDeactivatedHandler)=0
 
virtual void NotifyEntitiesDirtied ()=0
 Notifies entities that they should process their dirty state.
 
virtual void NotifyEntitiesChanged ()=0
 Notifies entities that they should process change notifications.
 
virtual void NotifyControllersActivated (const ConstNetworkEntityHandle &entityHandle, EntityIsMigrating entityIsMigrating)=0
 
virtual void NotifyControllersDeactivated (const ConstNetworkEntityHandle &entityHandle, EntityIsMigrating entityIsMigrating)=0
 
virtual void HandleLocalRpcMessage (NetworkEntityRpcMessage &message)=0
 
virtual void HandleEntitiesExitDomain (const NetEntityIdSet &entitiesNotInDomain)=0
 
virtual void ForceAssumeAuthority (const ConstNetworkEntityHandle &entityHandle)=0
 
virtual void MarkAlwaysRelevantToClients (const ConstNetworkEntityHandle &entityHandle, bool alwaysRelevant)=0
 
virtual void MarkAlwaysRelevantToServers (const ConstNetworkEntityHandle &entityHandle, bool alwaysRelevant)=0
 
virtual const NetEntityHandleSet & GetAlwaysRelevantToClientsSet () const =0
 
virtual const NetEntityHandleSet & GetAlwaysRelevantToServersSet () const =0
 
virtual void SetMigrateTimeoutTimeMs (AZ::TimeMs timeoutTimeMs)=0
 
virtual void DebugDraw () const =0
 Visualization of network entity manager state.
 

Static Public Attributes

static constexpr AZ::Crc32 NetworkEntityTag = AZ_CRC_CE("Network")
 

Additional Inherited Members

- Public Types inherited from Multiplayer::INetworkEntityManager
using EntityList = AZStd::vector< NetworkEntityHandle >
 

Detailed Description

Implementation of the networked entity manager interface. This class creates and manages all networked entities.

Member Function Documentation

◆ AddControllersActivatedHandler()

void Multiplayer::NetworkEntityManager::AddControllersActivatedHandler ( ControllersActivatedEvent::Handler &  controllersActivatedHandler)
overridevirtual

Adds an event handler to be invoked when an entities controllers have activated

Parameters
controllersActivatedHandlerevent handler for the entity

Implements Multiplayer::INetworkEntityManager.

◆ AddControllersDeactivatedHandler()

void Multiplayer::NetworkEntityManager::AddControllersDeactivatedHandler ( ControllersDeactivatedEvent::Handler &  controllersDeactivatedHandler)
overridevirtual

Adds an event handler to be invoked when an entities controllers have been deactivated

Parameters
controllersDeactivatedHandlerevent handler for the entity

Implements Multiplayer::INetworkEntityManager.

◆ AddEntityExitDomainHandler()

void Multiplayer::NetworkEntityManager::AddEntityExitDomainHandler ( EntityExitDomainEvent::Handler &  entityExitDomainHandler)
overridevirtual

Adds an event handler to be invoked when we notify entities to send their change notifications.

Parameters
entityNotifyChangesHandleevent handler for the dirtied entity

Implements Multiplayer::INetworkEntityManager.

◆ AddEntityMarkedDirtyHandler()

void Multiplayer::NetworkEntityManager::AddEntityMarkedDirtyHandler ( AZ::Event<>::Handler &  entityMarkedDirtyHandle)
overridevirtual

Adds an event handler to be invoked when we notify which entities have been marked dirty.

Parameters
entityMarkedDirtyHandleevent handler for the dirtied entity

Implements Multiplayer::INetworkEntityManager.

◆ AddEntityNotifyChangesHandler()

void Multiplayer::NetworkEntityManager::AddEntityNotifyChangesHandler ( AZ::Event<>::Handler &  entityNotifyChangesHandle)
overridevirtual

Adds an event handler to be invoked when we notify entities to send their change notifications.

Parameters
entityNotifyChangesHandleevent handler for the dirtied entity

Implements Multiplayer::INetworkEntityManager.

◆ AddEntityToEntityMap()

NetworkEntityHandle Multiplayer::NetworkEntityManager::AddEntityToEntityMap ( NetEntityId  netEntityId,
AZ::Entity *  entity 
)
overridevirtual

Adds the provided entity to the internal entity map identified by the provided netEntityId.

Parameters
netEntityIdthe identifier to use for the added entity
entitythe entity to add to the internal entity map
Returns
a NetworkEntityHandle for the newly added entity

Implements Multiplayer::INetworkEntityManager.

◆ ClearAllEntities()

void Multiplayer::NetworkEntityManager::ClearAllEntities ( )
overridevirtual

Clears out and deletes all entities registered with the entity manager.

Implements Multiplayer::INetworkEntityManager.

◆ ClearEntityFromRemovalList()

void Multiplayer::NetworkEntityManager::ClearEntityFromRemovalList ( const ConstNetworkEntityHandle entityHandle)
overridevirtual

Unmarks the specified entity so it will no longer be removed and deleted.

Parameters
entityHandlethe entity to unmark for removal and deletion

Implements Multiplayer::INetworkEntityManager.

◆ CreateEntitiesImmediate() [1/2]

EntityList Multiplayer::NetworkEntityManager::CreateEntitiesImmediate ( const PrefabEntityId prefabEntryId,
NetEntityId  netEntityId,
NetEntityRole  netEntityRole,
AutoActivate  autoActivate,
const AZ::Transform &  transform 
)
overridevirtual

Creates new entities of the given archetype This interface is internally used to spawn replicated entities

Parameters
prefabEntryIdthe name of the spawnable to spawn

Implements Multiplayer::INetworkEntityManager.

◆ CreateEntitiesImmediate() [2/2]

EntityList Multiplayer::NetworkEntityManager::CreateEntitiesImmediate ( const PrefabEntityId prefabEntryId,
NetEntityRole  netEntityRole,
const AZ::Transform &  transform,
AutoActivate  autoActivate = AutoActivate::Activate 
)
overridevirtual

Creates new entities of the given archetype

Parameters
prefabEntryIdthe name of the spawnable to spawn

Implements Multiplayer::INetworkEntityManager.

◆ DebugDraw()

void Multiplayer::NetworkEntityManager::DebugDraw ( ) const
overridevirtual

Visualization of network entity manager state.

Implements Multiplayer::INetworkEntityManager.

◆ ForceAssumeAuthority()

void Multiplayer::NetworkEntityManager::ForceAssumeAuthority ( const ConstNetworkEntityHandle entityHandle)
overridevirtual

Forcibly assumes authoritative control over the given entity. This should only be used in the event of the unexpected loss of the previous authority, any other usage could corrupt the simulation.

Parameters
entityHandlethe entity to forcibly assume authoritative control over

Implements Multiplayer::INetworkEntityManager.

◆ GetAlwaysRelevantToClientsSet()

const NetEntityHandleSet & Multiplayer::NetworkEntityManager::GetAlwaysRelevantToClientsSet ( ) const
overridevirtual

Retrieves the set of network entities that should always be relevant to client connections.

Returns
the set of network entities that should always be relevant to client connections

Implements Multiplayer::INetworkEntityManager.

◆ GetAlwaysRelevantToServersSet()

const NetEntityHandleSet & Multiplayer::NetworkEntityManager::GetAlwaysRelevantToServersSet ( ) const
overridevirtual

Retrieves the set of network entities that should always be relevant to server connections.

Returns
the set of network entities that should always be relevant to server connections

Implements Multiplayer::INetworkEntityManager.

◆ GetEntity()

ConstNetworkEntityHandle Multiplayer::NetworkEntityManager::GetEntity ( NetEntityId  netEntityId) const
overridevirtual

Returns an ConstEntityPtr for the provided entityId.

Parameters
netEntityIdthe netEntityId to get an ConstEntityPtr for
Returns
the requested ConstEntityPtr

Implements Multiplayer::INetworkEntityManager.

◆ GetEntityCount()

uint32_t Multiplayer::NetworkEntityManager::GetEntityCount ( ) const
overridevirtual

Returns the total number of entities tracked by this INetworkEntityManager instance.

Returns
the total number of entities tracked by this INetworkEntityManager instance

Implements Multiplayer::INetworkEntityManager.

◆ GetEntityDomain()

IEntityDomain * Multiplayer::NetworkEntityManager::GetEntityDomain ( ) const
overridevirtual

Returns the entity domain associated with this network entity manager, this will be nullptr on clients.

Returns
boolean the entity domain for this network entity manager

Implements Multiplayer::INetworkEntityManager.

◆ GetHostId()

const HostId & Multiplayer::NetworkEntityManager::GetHostId ( ) const
overridevirtual

Returns the HostId for this INetworkEntityManager instance.

Returns
the HostId for this INetworkEntityManager instance

Implements Multiplayer::INetworkEntityManager.

◆ GetMultiplayerComponentRegistry()

MultiplayerComponentRegistry * Multiplayer::NetworkEntityManager::GetMultiplayerComponentRegistry ( )
overridevirtual

◆ GetNetEntityIdById()

NetEntityId Multiplayer::NetworkEntityManager::GetNetEntityIdById ( const AZ::EntityId &  entityId) const
overridevirtual

Returns the Net Entity ID for a given AZ Entity ID.

Parameters
entityIdthe AZ Entity ID
Returns
the Net Entity ID

Implements Multiplayer::INetworkEntityManager.

◆ GetNetworkEntityAuthorityTracker()

NetworkEntityAuthorityTracker * Multiplayer::NetworkEntityManager::GetNetworkEntityAuthorityTracker ( )
overridevirtual

◆ GetNetworkEntityTracker()

NetworkEntityTracker * Multiplayer::NetworkEntityManager::GetNetworkEntityTracker ( )
overridevirtual

Returns the NetworkEntityTracker for this INetworkEntityManager instance.

Returns
the NetworkEntityTracker for this INetworkEntityManager instance

Implements Multiplayer::INetworkEntityManager.

◆ HandleEntitiesExitDomain()

void Multiplayer::NetworkEntityManager::HandleEntitiesExitDomain ( const NetEntityIdSet &  entitiesNotInDomain)
overridevirtual

Handles a set of entities transitioning between entity domains.

Parameters
entitiesNotInDomainthe set of entities that are no longer contained within our entity domain

Implements Multiplayer::INetworkEntityManager.

◆ HandleLocalRpcMessage()

void Multiplayer::NetworkEntityManager::HandleLocalRpcMessage ( NetworkEntityRpcMessage message)
overridevirtual

Handle a local rpc message.

Parameters
entityRpcMessagethe local rpc message to handle

Implements Multiplayer::INetworkEntityManager.

◆ Initialize()

void Multiplayer::NetworkEntityManager::Initialize ( const HostId &  hostId,
AZStd::unique_ptr< IEntityDomain entityDomain 
)
overridevirtual

◆ IsInitialized()

bool Multiplayer::NetworkEntityManager::IsInitialized ( ) const
overridevirtual

Returns whether or not the network entity manager has been initialized.

Returns
boolean true if this network entity manager has been intialized

Implements Multiplayer::INetworkEntityManager.

◆ IsMarkedForRemoval()

bool Multiplayer::NetworkEntityManager::IsMarkedForRemoval ( const ConstNetworkEntityHandle entityHandle) const
overridevirtual

Returns true if the indicated entity is marked for removal.

Parameters
entityHandlethe entity to test if marked for removal
Returns
boolean true if the specified entity is marked for removal, false otherwise

Implements Multiplayer::INetworkEntityManager.

◆ MarkAlwaysRelevantToClients()

void Multiplayer::NetworkEntityManager::MarkAlwaysRelevantToClients ( const ConstNetworkEntityHandle entityHandle,
bool  alwaysRelevant 
)
overridevirtual

Will toggle whether or not the provided entity should always be relevant to client connections. Use carefully, as this will cause the entity to bypass normal relevancy checks and could cause bandwidth issues.

Parameters
entityHandleconst network entity handle to the entity to override relevancy for
alwaysRelevanta true value will enable always relevant, false will disable

Implements Multiplayer::INetworkEntityManager.

◆ MarkAlwaysRelevantToServers()

void Multiplayer::NetworkEntityManager::MarkAlwaysRelevantToServers ( const ConstNetworkEntityHandle entityHandle,
bool  alwaysRelevant 
)
overridevirtual

Will toggle whether or not the provided entity should always be relevant to server connections. Use carefully, as this will cause the entity to bypass normal relevancy checks and could cause bandwidth issues.

Parameters
entityHandleconst network entity handle to the entity to override relevancy for
alwaysRelevanta true value will enable always relevant, false will disable

Implements Multiplayer::INetworkEntityManager.

◆ MarkForRemoval()

void Multiplayer::NetworkEntityManager::MarkForRemoval ( const ConstNetworkEntityHandle entityHandle)
overridevirtual

Marks the specified entity for removal and deletion.

Parameters
entityHandlethe entity to remove and delete

Implements Multiplayer::INetworkEntityManager.

◆ NotifyControllersActivated()

void Multiplayer::NetworkEntityManager::NotifyControllersActivated ( const ConstNetworkEntityHandle entityHandle,
EntityIsMigrating  entityIsMigrating 
)
overridevirtual

Notifies that an entities controllers have activated.

Parameters
entityHandlehandle to the entity whose controllers have activated
entityIsMigratingtrue if the entity is activating after a migration

Implements Multiplayer::INetworkEntityManager.

◆ NotifyControllersDeactivated()

void Multiplayer::NetworkEntityManager::NotifyControllersDeactivated ( const ConstNetworkEntityHandle entityHandle,
EntityIsMigrating  entityIsMigrating 
)
overridevirtual

Notifies that an entities controllers have been deactivated.

Parameters
entityHandlehandle to the entity whose controllers have been deactivated
entityIsMigratingtrue if the entity is deactivating due to a migration

Implements Multiplayer::INetworkEntityManager.

◆ NotifyEntitiesChanged()

void Multiplayer::NetworkEntityManager::NotifyEntitiesChanged ( )
overridevirtual

Notifies entities that they should process change notifications.

Implements Multiplayer::INetworkEntityManager.

◆ NotifyEntitiesDirtied()

void Multiplayer::NetworkEntityManager::NotifyEntitiesDirtied ( )
overridevirtual

Notifies entities that they should process their dirty state.

Implements Multiplayer::INetworkEntityManager.

◆ OnResolveAliases()

void Multiplayer::NetworkEntityManager::OnResolveAliases ( AzFramework::Spawnable::EntityAliasVisitor &  aliases,
const AzFramework::SpawnableMetaData &  metadata,
const AzFramework::Spawnable::EntityList &  entities 
)
override

SpawnableAssetEventsBus

◆ OnRootSpawnableAssigned()

void Multiplayer::NetworkEntityManager::OnRootSpawnableAssigned ( AZ::Data::Asset< AzFramework::Spawnable >  rootSpawnable,
uint32_t  generation 
)
override

RootSpawnableNotificationBus

◆ RemoveEntityFromEntityMap()

void Multiplayer::NetworkEntityManager::RemoveEntityFromEntityMap ( NetEntityId  netEntityId)
overridevirtual

Removes the provided netEntityId from the internal entity map.

Parameters
netEntityIdthe identifier to use for the added entity

Implements Multiplayer::INetworkEntityManager.

◆ RequestNetSpawnableInstantiation()

AZStd::unique_ptr< AzFramework::EntitySpawnTicket > Multiplayer::NetworkEntityManager::RequestNetSpawnableInstantiation ( const AZ::Data::Asset< AzFramework::Spawnable > &  netSpawnable,
const AZ::Transform &  transform 
)
overridevirtual

Requests a network spawnable to instantiate at a given transform This is an async function. The instantiated entities are not available immediately but will be constructed by the spawnable system The spawnable ticket has to be kept for the whole lifetime of the entities

Parameters
netSpawnablethe network spawnable to spawn
transformthe transform where the spawnable should be spawned
Returns
the ticket for managing the spawned entities

Implements Multiplayer::INetworkEntityManager.

◆ SetMigrateTimeoutTimeMs()

void Multiplayer::NetworkEntityManager::SetMigrateTimeoutTimeMs ( AZ::TimeMs  timeoutTimeMs)
overridevirtual

Overrides the default timeout time used during entity migrations.

Parameters
timeoutTimeMsthe timeout time to use in milliseconds

Implements Multiplayer::INetworkEntityManager.

◆ SetupNetEntity()

void Multiplayer::NetworkEntityManager::SetupNetEntity ( AZ::Entity *  netEntity,
PrefabEntityId  prefabEntityId,
NetEntityRole  netEntityRole 
)
overridevirtual

Configures new networked entity

Parameters
netEntitythe entity to setup
prefabEntryIdthe name of the spawnable the entity originated from
netEntityRolethe net role the entity should be setup for

Implements Multiplayer::INetworkEntityManager.


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