Open 3D Engine Multiplayer Gem API Reference  24.09
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
Multiplayer::NetBindComponent Class Referencefinal

Component that provides net-binding to a networked entity. More...

#include <NetBindComponent.h>

Inherits AZ::Component.

Public Member Functions

 AZ_COMPONENT (NetBindComponent, "{DAA076B3-1A1C-4FEF-8583-1DF696971604}")
 
NetEntityRole GetNetEntityRole () const
 
bool IsNetEntityRoleAuthority () const
 
bool IsNetEntityRoleAutonomous () const
 
bool IsNetEntityRoleServer () const
 
bool IsNetEntityRoleClient () const
 
void SetAllowEntityMigration (EntityMigration value)
 
EntityMigration GetAllowEntityMigration () const
 
bool ValidatePropertyRead (const char *propertyName, NetEntityRole replicateFrom, NetEntityRole replicateTo) const
 
bool ValidatePropertyWrite (const char *propertyName, NetEntityRole replicateFrom, NetEntityRole replicateTo, bool isPredictable) const
 
bool HasController () const
 
NetEntityId GetNetEntityId () const
 
const PrefabEntityIdGetPrefabEntityId () const
 
void SetPrefabEntityId (const PrefabEntityId &prefabEntityId)
 
const AZ::Data::AssetId & GetPrefabAssetId () const
 
void SetPrefabAssetId (const AZ::Data::AssetId &val)
 
ConstNetworkEntityHandle GetEntityHandle () const
 
NetworkEntityHandle GetEntityHandle ()
 
void SetOwningConnectionId (AzNetworking::ConnectionId connectionId)
 
AzNetworking::ConnectionId GetOwningConnectionId () const
 
void EnablePlayerHostAutonomy (bool enabled)
 
MultiplayerComponentInputVector AllocateComponentInputs ()
 
bool IsProcessingInput () const
 
bool IsReprocessingInput () const
 
void CreateInput (NetworkInput &networkInput, float deltaTime)
 
void ProcessInput (NetworkInput &networkInput, float deltaTime)
 
void ReprocessInput (NetworkInput &networkInput, float deltaTime)
 
bool HandleRpcMessage (AzNetworking::IConnection *invokingConnection, NetEntityRole remoteRole, NetworkEntityRpcMessage &message)
 
bool HandlePropertyChangeMessage (AzNetworking::ISerializer &serializer, bool notifyChanges=true)
 
RpcSendEvent & GetSendAuthorityToClientRpcEvent ()
 
RpcSendEvent & GetSendAuthorityToAutonomousRpcEvent ()
 
RpcSendEvent & GetSendServerToAuthorityRpcEvent ()
 
RpcSendEvent & GetSendAutonomousToAuthorityRpcEvent ()
 
const ReplicationRecordGetPredictableRecord () const
 
void MarkDirty ()
 
void NotifyLocalChanges ()
 
void NotifySyncRewindState ()
 
void NotifyServerMigration (const HostId &remoteHostId)
 
void NotifyPreRender (float deltaTime)
 
void NotifyCorrection ()
 
void NetworkActivated ()
 
void AddEntityStopEventHandler (EntityStopEvent::Handler &eventHandler)
 
void AddEntityDirtiedEventHandler (EntityDirtiedEvent::Handler &eventHandler)
 
void AddEntitySyncRewindEventHandler (EntitySyncRewindEvent::Handler &eventHandler)
 
void AddEntityServerMigrationEventHandler (EntityServerMigrationEvent::Handler &eventHandler)
 
void AddEntityPreRenderEventHandler (EntityPreRenderEvent::Handler &eventHandler)
 
void AddEntityCorrectionEventHandler (EntityCorrectionEvent::Handler &handler)
 
void AddNetworkActivatedEventHandler (AZ::Event<>::Handler &handler)
 
bool SerializeEntityCorrection (AzNetworking::ISerializer &serializer)
 
bool SerializeStateDeltaMessage (ReplicationRecord &replicationRecord, AzNetworking::ISerializer &serializer)
 
void NotifyStateDeltaChanges (ReplicationRecord &replicationRecord)
 
void FillReplicationRecord (ReplicationRecord &replicationRecord) const
 
void FillTotalReplicationRecord (ReplicationRecord &replicationRecord) const
 
void Init () override
 
void Activate () override
 
void Deactivate () override
 

Static Public Member Functions

static void Reflect (AZ::ReflectContext *context)
 
static void GetProvidedServices (AZ::ComponentDescriptor::DependencyArrayType &provided)
 
static void GetIncompatibleServices (AZ::ComponentDescriptor::DependencyArrayType &incompatible)
 

Friends

class NetworkEntityManager
 
class EntityReplicationManager
 
class HierarchyTests
 
class HierarchyBenchmarkBase
 
class MultiplayerSystemTests
 
class NetworkEntityTests
 
class LocalPredictionPlayerInputTests
 

Detailed Description

Component that provides net-binding to a networked entity.

Member Function Documentation

◆ AllocateComponentInputs()

MultiplayerComponentInputVector Multiplayer::NetBindComponent::AllocateComponentInputs ( )

This allocates and returns an appropriate MultiplayerComponentInputVector for the components bound to this entity.

Returns
a MultiplayerComponentInputVector suitable for this entity

◆ EnablePlayerHostAutonomy()

void Multiplayer::NetBindComponent::EnablePlayerHostAutonomy ( bool  enabled)

Allows a player host to autonomously control their player entity, even though the entity is in an authority role. Note: If this entity is already activated this will reactivate all of the multiplayer component controllers in order for them to reactivate under autonomous control.

◆ GetAllowEntityMigration()

EntityMigration Multiplayer::NetBindComponent::GetAllowEntityMigration ( ) const

Retrieves whether or not the netbound entity is allowed to migrate between hosts.

Returns
EntityMigration::Enabled if the entity is allowed to migrate, EntityMigration::Disabled otherwise

◆ GetEntityHandle() [1/2]

NetworkEntityHandle Multiplayer::NetBindComponent::GetEntityHandle ( )

Returns a non-const network entity handle for this entity, this allows controller access so use it with great caution. Warning, this function is dangerous to use in game code as it makes it easy to write logic that will function incorrectly within multihost environments. Use carefully.

Returns
a non-const network entity handle to this entity

◆ GetEntityHandle() [2/2]

ConstNetworkEntityHandle Multiplayer::NetBindComponent::GetEntityHandle ( ) const

Returns a const network entity handle to this entity.

Returns
a const network entity handle to this entity

◆ GetNetEntityId()

NetEntityId Multiplayer::NetBindComponent::GetNetEntityId ( ) const

Returns the bound NetworkEntityId that represents this entity.

Returns
the bound NetworkEntityId that represents this entity

◆ GetOwningConnectionId()

AzNetworking::ConnectionId Multiplayer::NetBindComponent::GetOwningConnectionId ( ) const

Returns the AzNetworking::ConnectionId of the connection that owns this entity form a local prediction standpoint.

Returns
the AzNetworking::ConnectionId of the connection that owns this entity form a local prediction standpoint

◆ GetPrefabAssetId()

const AZ::Data::AssetId& Multiplayer::NetBindComponent::GetPrefabAssetId ( ) const

Returns the PrefabAssetId of the prefab this entity was loaded from.

Returns
the PrefabAssetId of the prefab this entity was loaded from

◆ GetPrefabEntityId()

const PrefabEntityId& Multiplayer::NetBindComponent::GetPrefabEntityId ( ) const

Returns the PrefabEntityId that this entity was loaded from.

Returns
the PrefabEntityId that this entity was loaded from

◆ HasController()

bool Multiplayer::NetBindComponent::HasController ( ) const

Returns whether or not a controller exists for the bound network entity. Warning, this function is dangerous to use in game code as it makes it easy to write logic that will function incorrectly within multihost environments. Use carefully. The recommended solution for communicating from proxy level to a controller is to use a Server to Authority RPC, as the network layer can route the RPC appropriately.

Returns
boolean true if a controller exists, false otherwise

◆ Init()

void Multiplayer::NetBindComponent::Init ( )
override

AZ::Component overrides.

◆ IsNetEntityRoleAuthority()

bool Multiplayer::NetBindComponent::IsNetEntityRoleAuthority ( ) const

IsNetEntityRoleAuthority

Returns
true if this network entity is an authoritative proxy on a server (full authority); otherwise false.

◆ IsNetEntityRoleAutonomous()

bool Multiplayer::NetBindComponent::IsNetEntityRoleAutonomous ( ) const

IsNetEntityRoleAutonomous

Returns
true if this network entity is an autonomous proxy on a client (can execute local prediction) or if this network entity is an authoritative proxy on a server but has autonomous privileges (ie: a host who is also a player); otherwise false.

◆ IsNetEntityRoleClient()

bool Multiplayer::NetBindComponent::IsNetEntityRoleClient ( ) const

IsNetEntityRoleClient

Returns
true if this network entity is a simulated proxy on a client; otherwise false.

◆ IsNetEntityRoleServer()

bool Multiplayer::NetBindComponent::IsNetEntityRoleServer ( ) const

IsNetEntityRoleServer

Returns
true if this network entity is a simulated proxy on a server (ie: a different server may have authority for this entity, but the entity has been replicated on this server; otherwise false.

◆ IsProcessingInput()

bool Multiplayer::NetBindComponent::IsProcessingInput ( ) const

Return true if we're currently processing inputs.

Returns
true if we're within ProcessInput scope and writing to predictive state

◆ IsReprocessingInput()

bool Multiplayer::NetBindComponent::IsReprocessingInput ( ) const

Return true if we're currently replaying inputs after a correction. If this value returns true, effects, audio, and other cosmetic triggers should be suppressed

Returns
true if we're within correction scope and replaying inputs

◆ SetAllowEntityMigration()

void Multiplayer::NetBindComponent::SetAllowEntityMigration ( EntityMigration  value)

Sets whether or not a netbound entity is allowed to migrate between hosts. Use this feature carefully, as replication is spatially based. If migration is disabled chances are you want to mark the entity as always persistent as well. See INetworkEntityManager::MarkAlwaysRelevantToClients and INetworkEntityManager::MarkAlwaysRelevantToServers

Parameters
valuewhether to enable or disable host migrations for this entity

◆ SetOwningConnectionId()

void Multiplayer::NetBindComponent::SetOwningConnectionId ( AzNetworking::ConnectionId  connectionId)

Sets the AzNetworking::ConnectionId that 'owns' this entity from a local prediction standpoint. This is important for correct rewind operation during backward reconciliation, as we shouldn't rewind anything owned by the autonomous entity itself.

Parameters
connectionIdthe AzNetworking::ConnectionId to mark as the owner of this entity

◆ SetPrefabAssetId()

void Multiplayer::NetBindComponent::SetPrefabAssetId ( const AZ::Data::AssetId &  val)

Sets the PrefabAssetId of the prefab that this entity was loaded from.

Parameters
valthe PrefabAssetId to mark as bound to this entity

◆ SetPrefabEntityId()

void Multiplayer::NetBindComponent::SetPrefabEntityId ( const PrefabEntityId prefabEntityId)

Sets the PrefabEntityId that this entity was loaded from.

Parameters
prefabEntityIdthe PrefabEntityId to mark as bound to this entity

◆ ValidatePropertyRead()

bool Multiplayer::NetBindComponent::ValidatePropertyRead ( const char *  propertyName,
NetEntityRole  replicateFrom,
NetEntityRole  replicateTo 
) const

This is a helper that validates the owning entity is in the correct role to read from a network property that matches the relicateFrom and replicateTo parameters.

Parameters
propertyNamethe name of the property, for logging and debugging purposes
replicateFromthe network entity role that the property replicates from
replicateTothe network entity role that the property replicates to
Returns
boolean true if the read is valid, false if nothing is replicated to the target and invalid data will be read

◆ ValidatePropertyWrite()

bool Multiplayer::NetBindComponent::ValidatePropertyWrite ( const char *  propertyName,
NetEntityRole  replicateFrom,
NetEntityRole  replicateTo,
bool  isPredictable 
) const

This is a helper that validates the owning entity is in the correct role to write to a network property that matches the relicateFrom, replicateTo parameters, and isPredictable parameters.

Parameters
propertyNamethe name of the property, for logging and debugging purposes
replicateFromthe network entity role that the property replicates from
replicateTothe network entity role that the property replicates to
isPredictabletrue if the property is predictable, false otherwise
Returns
boolean true if the write is valid, false if the write will desync the network property

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