Table of Contents

Class DeltaSnapshotApplier

Namespace
KeenEyes.Serialization
Assembly
KeenEyes.Core.dll

Reconstructs a full WorldSnapshot by applying a DeltaSnapshot to a baseline snapshot, without requiring a live World.

public static class DeltaSnapshotApplier
Inheritance
DeltaSnapshotApplier
Inherited Members

Remarks

DeltaRestorer mutates a live world in place; this applier is its world-free counterpart. It operates purely on the serialized representation (WorldSnapshot, SerializedEntity, SerializedComponent) and never deserializes component payloads, so it needs no component serializer and performs no reflection.

This makes it suitable for tools that must reconstruct historical state offline - for example extracting ghost trails from a delta-compressed replay - where spinning up a world purely to read back state would be wasteful and would require a serializer.

To reconstruct the state at a delta marker, restore the governing keyframe's WorldSnapshot and apply each intervening delta in order:

var state = keyframe.Snapshot!;
foreach (var marker in deltaMarkersInOrder)
{
    state = DeltaSnapshotApplier.Apply(state, marker.Delta!);
}

Methods

Apply(WorldSnapshot, DeltaSnapshot)

Applies a delta snapshot to a baseline snapshot and returns the reconstructed state.

public static WorldSnapshot Apply(WorldSnapshot baseline, DeltaSnapshot delta)

Parameters

baseline WorldSnapshot

The snapshot the delta is relative to - either a keyframe or a previously reconstructed state.

delta DeltaSnapshot

The incremental changes to apply.

Returns

WorldSnapshot

A new WorldSnapshot representing the world state after the delta is applied. The input snapshots are never mutated.

Remarks

The delta is applied in the same conceptual order as ApplyDelta(World, DeltaSnapshot, IComponentSerializer, Dictionary<int, Entity>): destroyed entities are removed, created entities are appended, then per-entity modifications (name, parent, and added/removed/modified components) are applied, followed by singleton additions, replacements, and removals.

Baseline entity order is preserved and newly created entities are appended, keeping parents ahead of children as required by Entities. References that cannot be resolved (a modification targeting an entity absent from the baseline, a removal of a component that is not present) are skipped, mirroring the lenient behavior of DeltaRestorer.

Exceptions

ArgumentNullException

Thrown when baseline or delta is null.