Table of Contents

Class DeltaRestorer

Namespace
KeenEyes.Serialization
Assembly
KeenEyes.Core.dll

Applies delta snapshots to restore a world to a specific state.

public static class DeltaRestorer
Inheritance
DeltaRestorer
Inherited Members

Examples

// First, restore the baseline
var entityMap = SnapshotManager.RestoreSnapshot(world, baseline, serializer);

// Then apply each delta in sequence
foreach (var delta in deltas.OrderBy(d => d.SequenceNumber))
{
    entityMap = DeltaRestorer.ApplyDelta(world, delta, serializer, entityMap);
}

Remarks

The DeltaRestorer applies incremental changes captured in a DeltaSnapshot to a world that has been restored from a baseline. Deltas must be applied in sequence order (1, 2, 3...) after the baseline is restored.

Methods

ApplyDelta(World, DeltaSnapshot, IComponentSerializer, Dictionary<int, Entity>)

Applies a delta snapshot to a world.

public static Dictionary<int, Entity> ApplyDelta(World world, DeltaSnapshot delta, IComponentSerializer serializer, Dictionary<int, Entity> entityMap)

Parameters

world World

The world to apply changes to.

delta DeltaSnapshot

The delta snapshot containing changes to apply.

serializer IComponentSerializer

The component serializer for AOT-compatible deserialization.

entityMap Dictionary<int, Entity>

The entity ID mapping from the baseline restoration. Maps original IDs to current entities.

Returns

Dictionary<int, Entity>

An updated entity ID mapping reflecting any new entities created by this delta.

Remarks

The delta is applied in the following order:

  1. Destroy removed entities
  2. Create new entities with their components
  3. Apply modifications to existing entities
  4. Update singletons

The returned entity map includes all entities from the input map (minus destroyed ones) plus any newly created entities.

Exceptions

ArgumentNullException

Thrown when any parameter is null.