Table of Contents

Class DeltaSnapshot

Namespace
KeenEyes.Serialization
Assembly
KeenEyes.Core.dll

Represents incremental changes to a world state relative to a baseline snapshot.

public sealed record DeltaSnapshot : IEquatable<DeltaSnapshot>
Inheritance
DeltaSnapshot
Implements
Inherited Members

Examples

// Create delta from current world state
var delta = DeltaDiffer.CreateDelta(world, baselineSnapshot, serializer);

// Later, restore by applying delta to baseline
SnapshotManager.RestoreSnapshot(world, baselineSnapshot, serializer);
DeltaRestorer.ApplyDelta(world, delta, serializer);

Remarks

Delta snapshots capture only what has changed since a baseline snapshot was taken, resulting in significantly smaller save files for games with many entities but few changes per save cycle.

To restore a world, you must first load the baseline snapshot, then apply the delta snapshots in sequence.

Properties

BaselineSlotName

Gets the slot name of the baseline this delta is relative to.

public required string BaselineSlotName { get; init; }

Property Value

string

ChangeCount

Gets the total number of changes in this delta.

[JsonIgnore]
public int ChangeCount { get; }

Property Value

int

CreatedEntities

Gets the entities that were created since the baseline.

public IReadOnlyList<SerializedEntity> CreatedEntities { get; init; }

Property Value

IReadOnlyList<SerializedEntity>

DestroyedEntityIds

Gets the IDs of entities that were destroyed since the baseline.

public IReadOnlyList<int> DestroyedEntityIds { get; init; }

Property Value

IReadOnlyList<int>

IsEmpty

Gets whether this delta is empty (no changes).

[JsonIgnore]
public bool IsEmpty { get; }

Property Value

bool

Metadata

Gets optional metadata attached to this delta.

public IReadOnlyDictionary<string, object>? Metadata { get; init; }

Property Value

IReadOnlyDictionary<string, object>

ModifiedEntities

Gets the modifications to existing entities.

public IReadOnlyList<EntityDelta> ModifiedEntities { get; init; }

Property Value

IReadOnlyList<EntityDelta>

ModifiedSingletons

Gets the singletons that were added or modified since the baseline.

public IReadOnlyList<SerializedSingleton> ModifiedSingletons { get; init; }

Property Value

IReadOnlyList<SerializedSingleton>

RemovedSingletonTypes

Gets the type names of singletons that were removed since the baseline.

public IReadOnlyList<string> RemovedSingletonTypes { get; init; }

Property Value

IReadOnlyList<string>

SequenceNumber

Gets the sequence number of this delta relative to the baseline.

public int SequenceNumber { get; init; }

Property Value

int

Remarks

Sequence numbers start at 1 for the first delta after a baseline.

Timestamp

Gets the timestamp when this delta was created.

public DateTimeOffset Timestamp { get; init; }

Property Value

DateTimeOffset

Version

Gets the version of the delta snapshot format.

public int Version { get; init; }

Property Value

int