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
worldWorldThe world to apply changes to.
deltaDeltaSnapshotThe delta snapshot containing changes to apply.
serializerIComponentSerializerThe component serializer for AOT-compatible deserialization.
entityMapDictionary<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:
- Destroy removed entities
- Create new entities with their components
- Apply modifications to existing entities
- 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.