Table of Contents

Interface ISaveLoadCapability

Namespace
KeenEyes.Capabilities
Assembly
KeenEyes.Core.dll

Capability interface for world save/load operations.

public interface ISaveLoadCapability : IPersistenceCapability
Inherited Members
IPersistenceCapability.SaveDirectory

Examples

if (World is ISaveLoadCapability saveLoad)
{
    if (saveLoad.SaveSlotExists("autosave"))
    {
        var info = saveLoad.GetSaveSlotInfo("autosave");
        // Work with save slot info
    }
}

Remarks

This capability provides access to the complete save/load functionality including save slots, snapshots, and delta saves. Systems that need to perform save operations should use this interface rather than casting to the concrete World type.

This interface extends KeenEyes.Capabilities.IPersistenceCapability which provides basic persistence configuration such as the save directory.

Methods

ClearAllDirtyFlags()

Clears dirty flags for all entities and component types.

void ClearAllDirtyFlags()

CreateDelta<TSerializer>(WorldSnapshot, TSerializer, string, int)

Creates a delta snapshot by comparing the current world state to a baseline.

DeltaSnapshot CreateDelta<TSerializer>(WorldSnapshot baseline, TSerializer serializer, string baselineSlotName, int sequenceNumber) where TSerializer : IComponentSerializer

Parameters

baseline WorldSnapshot

The baseline snapshot to compare against.

serializer TSerializer

The component serializer.

baselineSlotName string

The slot name of the baseline snapshot.

sequenceNumber int

The sequence number for this delta.

Returns

DeltaSnapshot

A delta snapshot containing only the changes since the baseline.

Type Parameters

TSerializer

The serializer type that implements IComponentSerializer.

CreateSnapshot<TSerializer>(TSerializer)

Creates a snapshot of the current world state.

WorldSnapshot CreateSnapshot<TSerializer>(TSerializer serializer) where TSerializer : IComponentSerializer

Parameters

serializer TSerializer

The component serializer for AOT-compatible serialization.

Returns

WorldSnapshot

A snapshot containing all entities, components, hierarchy, and singletons.

Type Parameters

TSerializer

The serializer type that implements IComponentSerializer.

DeleteSaveSlot(string)

Deletes a save slot.

bool DeleteSaveSlot(string slotName)

Parameters

slotName string

The name of the save slot to delete.

Returns

bool

True if the slot was deleted; false if it didn't exist.

GetSaveSlotInfo(string)

Gets information about a save slot without loading it.

SaveSlotInfo? GetSaveSlotInfo(string slotName)

Parameters

slotName string

The name of the save slot.

Returns

SaveSlotInfo

The save slot info, or null if the slot doesn't exist.

ListSaveSlots()

Lists all available save slots.

IEnumerable<SaveSlotInfo> ListSaveSlots()

Returns

IEnumerable<SaveSlotInfo>

An enumerable of save slot info for all valid save files.

LoadFromSlot<TSerializer>(string, TSerializer, bool)

Loads a world state from a save slot.

(SaveSlotInfo SlotInfo, Dictionary<int, Entity> EntityMap) LoadFromSlot<TSerializer>(string slotName, TSerializer serializer, bool validateChecksum = true) where TSerializer : IComponentSerializer, IBinaryComponentSerializer

Parameters

slotName string

The name of the save slot to load.

serializer TSerializer

The component serializer.

validateChecksum bool

Whether to validate the checksum if present.

Returns

(SaveSlotInfo SlotInfo, Dictionary<int, Entity> EntityMap)

A tuple containing the save slot info and a mapping from original entity IDs to new entities.

Type Parameters

TSerializer

The serializer type that implements both IComponentSerializer and IBinaryComponentSerializer.

SaveDeltaToSlot<TSerializer>(string, DeltaSnapshot, TSerializer, SaveSlotOptions?)

Saves a delta snapshot to a slot.

SaveSlotInfo SaveDeltaToSlot<TSerializer>(string slotName, DeltaSnapshot delta, TSerializer serializer, SaveSlotOptions? options = null) where TSerializer : IComponentSerializer, IBinaryComponentSerializer

Parameters

slotName string

The name of the save slot.

delta DeltaSnapshot

The delta snapshot to save.

serializer TSerializer

The component serializer.

options SaveSlotOptions

Optional save options.

Returns

SaveSlotInfo

The save slot info with updated metadata.

Type Parameters

TSerializer

The serializer type that implements both IComponentSerializer and IBinaryComponentSerializer.

SaveSlotExists(string)

Checks if a save slot exists.

bool SaveSlotExists(string slotName)

Parameters

slotName string

The name of the save slot.

Returns

bool

True if the slot exists and is valid.

SaveToSlot<TSerializer>(string, TSerializer, SaveSlotOptions?)

Saves the current world state to a slot.

SaveSlotInfo SaveToSlot<TSerializer>(string slotName, TSerializer serializer, SaveSlotOptions? options = null) where TSerializer : IComponentSerializer, IBinaryComponentSerializer

Parameters

slotName string

The name of the save slot. Must be a valid filename (alphanumeric, underscores, hyphens).

serializer TSerializer

The component serializer for AOT-compatible serialization.

options SaveSlotOptions

Optional save options for compression, checksum, and metadata.

Returns

SaveSlotInfo

The save slot info with updated metadata.

Type Parameters

TSerializer

The serializer type that implements both IComponentSerializer and IBinaryComponentSerializer.