Vixen
02b45cc4
csharp
public static class HandoffCodec

Writes and reads the volatile half of a player, with the codec that writes snapshots.

Read the guide page for this →

Remarks

Doc 27 § The overlap: "the handoff payload reuses the replication codec", and it is not a convenience. Four things fall out of it and none would be free otherwise:

a component that replicates transfers with no extra code; the encoding is already fuzzed and already pinned by doc 16's wire corpus; the bit-exactness gate covers realm-to-realm agreement for nothing; there is one wire format for a component rather than two that can drift.

⚠ Nothing durable is in here. ADR-021: inventory, currency and progression stay in the database behind IPlayerGrain, and what travels is position, velocity, buffs with their remaining durations, cooldowns, combat state, the animation graph's position. If this payload is lost, an abort costs the player nothing — which is the property that makes every failure path in SourceTransfer cheap.

⚠ The two realms must agree about which replicators exist and in what order. They do, because they are the same build — ADR-022 makes the version pair a placement filter, so a shard on another build is one this player is never sent to. The type id is written anyway and checked on the way in, because "cannot happen" and "is not checked" should not be the same sentence.

Fields and properties (1)

  • public const byte Version

    The format this writes. Bumped when the framing changes, not when a component does.

Methods (3)

  • public static ImmutableArray<byte> Write(World world, Entity entity, IReadOnlyList<IComponentReplicator> replicators, Span<byte> buffer)

    Encodes everything a replicator will carry for one entity.

  • public static bool Apply(World world, Entity entity, ReadOnlySpan<byte> payload, IReadOnlyList<IComponentReplicator> replicators, out int applied)

    Applies a payload to an entity on the receiving realm.

  • public static RealmHandoff Handoff(PlayerKey player, long epoch, long tick, World world, Entity entity, IReadOnlyList<IComponentReplicator> replicators, Span<byte> buffer)

    Builds the payload for a whole handoff.

Used by (1)

  • HandoffCodecTestsVixen.Live.Realm.Tests