Skip to main content

Crate pylon_replication

Crate pylon_replication 

Source
Expand description

Entity replication for Pylon realtime shards.

A simulation keeps its replicated state in a Replicated store: entities with stable u64 ids, a 3D position, and components (bytes in the game’s own encoding, keyed by a u8 id). Every change bumps the store’s change counter, so the server can tell what changed since it last wrote to a given subscriber without diffing snapshots.

The server sends each subscriber replication frames (frame): spawn (full state) for entities that came into view, update (only changed axes and components) for entities in view, and despawn for entities that left view. A client applies them to a ReplicaTable.

A WebAssembly shard module records its store’s changes (Replicated::record_changes) and hands them to the host each tick; the host applies them to its copy (Replicated::apply_changes).

This crate has no dependencies, so guests build it for wasm32-unknown-unknown.

Re-exports§

pub use frame::DecodeError;
pub use frame::FrameSummary;
pub use frame::ReplicaEntity;
pub use frame::ReplicaTable;
pub use view::ViewHistory;

Modules§

datagram
The replication datagram: entity updates that may be lost, duplicated, or reordered (a WebTransport datagram, or a relay of one).
frame
The replication frame: what one subscriber receives per tick.
varint
LEB128 varints and zigzag signed integers.
view
What one subscriber was sent, kept so the server can see what that subscriber drew at an earlier tick (lag compensation).

Structs§

ChangeError
Why a change log did not apply.
Component
Entity
One replicated entity.
Replicated
The replicated state of a simulation.

Type Aliases§

ComponentId
A component id: the game decides what each one holds.
EntityId
A stable entity id, chosen by the simulation.