Table of Contents

Class WorldReplication

Namespace
Shard.Gameplay.World
Assembly
Shard.Gameplay.World.dll

Manages replication recipients, interest, and updates for one World.

public sealed class WorldReplication
Inheritance
WorldReplication
Inherited Members

Remarks

Connection and projection operations require the owning World's synchronous callback.

Methods

Connect(ReplicationConnectionId, Func<Entity, bool>, Action<ReplicationEnvelope>)

Adds or reconnects a recipient with a synchronous visibility filter, discarding the record of previously sent state.

public void Connect(ReplicationConnectionId connectionId, Func<Entity, bool> interestFilter, Action<ReplicationEnvelope> dispatch)

Parameters

connectionId ReplicationConnectionId
interestFilter Func<Entity, bool>
dispatch Action<ReplicationEnvelope>

Remarks

The filter may inspect its borrowed entity only for the duration of the call.

ConnectWithHandoff(ReplicationConnectionId, Func<Entity, bool>, Func<ReplicationEnvelope, bool>, Func<NetworkEntityId, ReplicationUpdateKind, bool>)

Connects a recipient whose outbound callback returns true when it accepts the envelope for immediate sending. If the callback returns false, replication keeps the previous presentation state and retries on a later tick. The projection filter runs on the World thread. It selects the entity capabilities that replication can record as presented to this recipient.

public void ConnectWithHandoff(ReplicationConnectionId connectionId, Func<Entity, bool> interestFilter, Func<ReplicationEnvelope, bool> dispatch, Func<NetworkEntityId, ReplicationUpdateKind, bool> includeProjection)

Parameters

connectionId ReplicationConnectionId
interestFilter Func<Entity, bool>
dispatch Func<ReplicationEnvelope, bool>
includeProjection Func<NetworkEntityId, ReplicationUpdateKind, bool>

Disconnect(ReplicationConnectionId)

Forgets one connection and all of its presentation state.

public bool Disconnect(ReplicationConnectionId connectionId)

Parameters

connectionId ReplicationConnectionId

Returns

bool

EmitTransient<TPayload>(Entity, ReplicationUpdateKind, TPayload)

Copies one explicit transient event for delivery in the current tick.

public void EmitTransient<TPayload>(Entity entity, ReplicationUpdateKind kind, TPayload payload) where TPayload : ReplicationPayload

Parameters

entity Entity
kind ReplicationUpdateKind
payload TPayload

Type Parameters

TPayload

RegisterRetained<TComponent, TPayload>(World, ReplicationUpdateKind, Func<TComponent, TPayload>)

Registers a retained projection during Store setup. Each update kind can be registered once.

public static void RegisterRetained<TComponent, TPayload>(World store, ReplicationUpdateKind kind, Func<TComponent, TPayload> project) where TComponent : struct where TPayload : ReplicationPayload

Parameters

store World
kind ReplicationUpdateKind
project Func<TComponent, TPayload>

Type Parameters

TComponent
TPayload

RegisterRetained<TFirst, TSecond, TPayload>(World, ReplicationUpdateKind, Func<TFirst, TSecond, TPayload>)

Registers an update built from two required components during Store setup.

public static void RegisterRetained<TFirst, TSecond, TPayload>(World store, ReplicationUpdateKind kind, Func<TFirst, TSecond, TPayload> project) where TFirst : struct where TSecond : struct where TPayload : ReplicationPayload

Parameters

store World
kind ReplicationUpdateKind
project Func<TFirst, TSecond, TPayload>

Type Parameters

TFirst
TSecond
TPayload

RegisterTransient<TPayload>(World, ReplicationUpdateKind)

Registers a transient payload type during Store setup. Each update kind can be registered once.

public static void RegisterTransient<TPayload>(World store, ReplicationUpdateKind kind) where TPayload : ReplicationPayload

Parameters

store World
kind ReplicationUpdateKind

Type Parameters

TPayload

Replicate(CompositionContext, Entity)

Enables replication until the entity is unloaded or deleted.

public static NetworkEntityId Replicate(CompositionContext context, Entity entity)

Parameters

context CompositionContext
entity Entity

Returns

NetworkEntityId

SetInterest(ReplicationConnectionId, IEnumerable<NetworkEntityId>)

Copies candidate entity IDs for a connection. Candidates need not come from a spatial query. Replication checks that each entity is still in the World and passes the connection's visibility filter.

public void SetInterest(ReplicationConnectionId connectionId, IEnumerable<NetworkEntityId> candidates)

Parameters

connectionId ReplicationConnectionId
candidates IEnumerable<NetworkEntityId>

TryWithInboundEntity(ReplicationConnectionId, NetworkEntityId, ReplicationUpdateKind, Func<Entity, bool>, Action<Entity>)

Invokes the callback for a live entity only if the sender has received its required update kind and the caller's authorization check succeeds. The callback must not retain the entity handle.

public bool TryWithInboundEntity(ReplicationConnectionId sender, NetworkEntityId networkId, ReplicationUpdateKind requiredCapability, Func<Entity, bool> authorize, Action<Entity> callback)

Parameters

sender ReplicationConnectionId
networkId NetworkEntityId
requiredCapability ReplicationUpdateKind
authorize Func<Entity, bool>
callback Action<Entity>

Returns

bool

TryWithInboundEntity(ReplicationConnectionId, NetworkEntityId, Func<Entity, bool>, Action<Entity>)

Calls the callback for a live entity if replication presented its network ID to the sender and the caller authorizes access. This overload does not require a specific update kind. Use the entity handle only during the callback.

public bool TryWithInboundEntity(ReplicationConnectionId sender, NetworkEntityId networkId, Func<Entity, bool> authorize, Action<Entity> callback)

Parameters

sender ReplicationConnectionId
networkId NetworkEntityId
authorize Func<Entity, bool>
callback Action<Entity>

Returns

bool