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
baselineWorldSnapshotThe baseline snapshot to compare against.
serializerTSerializerThe component serializer.
baselineSlotNamestringThe slot name of the baseline snapshot.
sequenceNumberintThe sequence number for this delta.
Returns
- DeltaSnapshot
A delta snapshot containing only the changes since the baseline.
Type Parameters
TSerializerThe 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
serializerTSerializerThe component serializer for AOT-compatible serialization.
Returns
- WorldSnapshot
A snapshot containing all entities, components, hierarchy, and singletons.
Type Parameters
TSerializerThe serializer type that implements IComponentSerializer.
DeleteSaveSlot(string)
Deletes a save slot.
bool DeleteSaveSlot(string slotName)
Parameters
slotNamestringThe 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
slotNamestringThe 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
slotNamestringThe name of the save slot to load.
serializerTSerializerThe component serializer.
validateChecksumboolWhether 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
TSerializerThe 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
slotNamestringThe name of the save slot.
deltaDeltaSnapshotThe delta snapshot to save.
serializerTSerializerThe component serializer.
optionsSaveSlotOptionsOptional save options.
Returns
- SaveSlotInfo
The save slot info with updated metadata.
Type Parameters
TSerializerThe serializer type that implements both IComponentSerializer and IBinaryComponentSerializer.
SaveSlotExists(string)
Checks if a save slot exists.
bool SaveSlotExists(string slotName)
Parameters
slotNamestringThe 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
slotNamestringThe name of the save slot. Must be a valid filename (alphanumeric, underscores, hyphens).
serializerTSerializerThe component serializer for AOT-compatible serialization.
optionsSaveSlotOptionsOptional save options for compression, checksum, and metadata.
Returns
- SaveSlotInfo
The save slot info with updated metadata.
Type Parameters
TSerializerThe serializer type that implements both IComponentSerializer and IBinaryComponentSerializer.