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::NetworkEntityTracker Class Reference

This class allows entity netEntityIds to be looked up. More...

#include <NetworkEntityTracker.h>

Public Types

using EntityMap = AZStd::unordered_map< NetEntityId, AZ::Entity * >
 
using NetEntityIdMap = AZStd::unordered_map< AZ::EntityId, NetEntityId >
 
using NetBindingMap = AZStd::unordered_map< AZ::Entity *, NetBindComponent * >
 
using iterator = EntityMap::iterator
 
using const_iterator = EntityMap::const_iterator
 

Public Member Functions

void Add (NetEntityId netEntityId, AZ::Entity *entity)
 
void RegisterNetBindComponent (AZ::Entity *entity, NetBindComponent *component)
 
void UnregisterNetBindComponent (NetBindComponent *component)
 
NetworkEntityHandle Get (NetEntityId netEntityId)
 Returns an entity handle which can validate entity existence.
 
ConstNetworkEntityHandle Get (NetEntityId netEntityId) const
 
NetEntityId Get (const AZ::EntityId &entityId) const
 Returns Net Entity ID for a given AZ Entity ID.
 
bool Exists (NetEntityId netEntityId) const
 Returns true if the netEntityId exists.
 
AZ::Entity * GetRaw (NetEntityId netEntityId) const
 Get a raw pointer of an entity.
 
AZ::Entity * Move (EntityMap::iterator iter)
 Moves the given iterator out of the entity holder and returns the ptr.
 
NetBindComponentGetNetBindComponent (AZ::Entity *rawEntity) const
 
uint32_t GetChangeDirty (const AZ::Entity *entity) const
 
uint32_t GetDeleteChangeDirty () const
 
uint32_t GetAddChangeDirty () const
 
 AZ_DISABLE_COPY_MOVE (NetworkEntityTracker)
 Prevent copying and heap allocation.
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
iterator find (NetEntityId netEntityId)
 
const_iterator find (NetEntityId netEntityId) const
 
void erase (NetEntityId netEntityId)
 
iterator erase (EntityMap::iterator iter)
 
AZStd::size_t size () const
 
void clear ()
 

Detailed Description

This class allows entity netEntityIds to be looked up.

Member Function Documentation

◆ Add()

void Multiplayer::NetworkEntityTracker::Add ( NetEntityId  netEntityId,
AZ::Entity *  entity 
)

Adds a networked entity to the tracker.

Parameters
netEntityIdthe networkId of the entity to add
entitypointer to the entity corresponding to the networkId

◆ begin()

NetworkEntityTracker::iterator Multiplayer::NetworkEntityTracker::begin ( )
inline

Container overloads

◆ GetChangeDirty()

uint32_t Multiplayer::NetworkEntityTracker::GetChangeDirty ( const AZ::Entity *  entity) const
inline

Dirty tracking optimizations to avoid unnecessary hash lookups. There are two counts, one for adds and one for deletes If an entity is nullptr, check adds to check to see if our entity was added again If an entity is not nullptr, check removes which reminds us to see if the entity no longer exists Passing in the entity into this helper assists in retrieving the correct count, so we do not need to store both counts inside each handle

◆ GetNetBindComponent()

NetBindComponent * Multiplayer::NetworkEntityTracker::GetNetBindComponent ( AZ::Entity *  rawEntity) const
inline

Retrieves the NetBindComponent for the provided AZ::Entity, nullptr if the entity does not have netbinding.

Parameters
entitypointer to the entity to retrieve the NetBindComponent for
Returns
pointer to the entities NetBindComponent, or nullptr if the entity doesn't exist or does not have netbinding

◆ RegisterNetBindComponent()

void Multiplayer::NetworkEntityTracker::RegisterNetBindComponent ( AZ::Entity *  entity,
NetBindComponent component 
)

Registers a new NetBindComponent with the NetworkEntityTracker.

Parameters
entitypointer to the entity we are registering the NetBindComponent for
componentpointer to the NetBindComponent being registered

◆ UnregisterNetBindComponent()

void Multiplayer::NetworkEntityTracker::UnregisterNetBindComponent ( NetBindComponent component)

Unregisters a NetBindComponent from the NetworkEntityTracker.

Parameters
componentpointer to the NetBindComponent being removed

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