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
connectionIdReplicationConnectionIdinterestFilterFunc<Entity, bool>dispatchAction<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
connectionIdReplicationConnectionIdinterestFilterFunc<Entity, bool>dispatchFunc<ReplicationEnvelope, bool>includeProjectionFunc<NetworkEntityId, ReplicationUpdateKind, bool>
Disconnect(ReplicationConnectionId)
Forgets one connection and all of its presentation state.
public bool Disconnect(ReplicationConnectionId connectionId)
Parameters
connectionIdReplicationConnectionId
Returns
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
entityEntitykindReplicationUpdateKindpayloadTPayload
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
storeWorldkindReplicationUpdateKindprojectFunc<TComponent, TPayload>
Type Parameters
TComponentTPayload
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
storeWorldkindReplicationUpdateKindprojectFunc<TFirst, TSecond, TPayload>
Type Parameters
TFirstTSecondTPayload
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
storeWorldkindReplicationUpdateKind
Type Parameters
TPayload
Replicate(CompositionContext, Entity)
Enables replication until the entity is unloaded or deleted.
public static NetworkEntityId Replicate(CompositionContext context, Entity entity)
Parameters
contextCompositionContextentityEntity
Returns
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
connectionIdReplicationConnectionIdcandidatesIEnumerable<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
senderReplicationConnectionIdnetworkIdNetworkEntityIdrequiredCapabilityReplicationUpdateKindauthorizeFunc<Entity, bool>callbackAction<Entity>
Returns
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
senderReplicationConnectionIdnetworkIdNetworkEntityIdauthorizeFunc<Entity, bool>callbackAction<Entity>