API
Assembly: Spark.Save Interface: ISaveDataPlugin Implementation: SaveDataPlugin
Interface
public interface ISaveDataPlugin
{
// Type registration
void RegisterSaveDataType<T>();
// Data access
T GetSaveData<T>(string key = null);
void SetSaveData<T>(T data, string key = null);
bool HasSaveData<T>(string key = null);
string[] GetRegisteredTypeNames();
// Persistence
Task<bool> SaveAsync();
Task<bool> LoadAsync();
void ClearAllData();
// Storage providers
void RegisterStorageProvider(ISaveDataProvider provider);
void SetActiveStorageProvider(string providerId);
// Slot management
SaveSlotManager GetSlotManager();
Task<SaveSlotMetadata> CreateNewSlot(string displayName);
Task<bool> LoadSlot(string slotId);
Task<bool> DeleteSlot(string slotId);
Task<List<SaveSlotMetadata>> GetAllSlots();
Task<SaveSlotMetadata> GetCurrentSlotMetadata();
Task<bool> SaveAndUpdateMetadata();
// Version management
Task<SaveVersionMetadata> CreateManualVersion(string displayName,
long totalPlaytimeSeconds);
Task<List<SaveVersionMetadata>> GetAllVersions();
Task<bool> LoadVersion(string versionId);
Task<bool> DeleteVersion(string versionId);
bool IsLoadingVersion();
}SaveDataEntry
Abstract base class for all save data types.
saveKey
string
Storage key identifier
lastModified
long
Timestamp of last modification
Virtual Methods:
SaveSlotMetadata
Represents a save slot.
slotId
string
Unique slot identifier
displayName
string
Player-facing name
creationTimestamp
long
When the slot was created
lastModifiedTimestamp
long
When last saved
activeVersionId
string
Current version within the slot
Methods:
SaveVersionMetadata
Represents a versioned snapshot within a slot.
versionId
string
Unique version identifier
displayName
string
Player-facing name
creationTimestamp
long
When created
versionType
SaveVersionType
Initial, Auto, Manual, or QuickSave
fileName
string
Storage file name
savedTimestamp
long
When saved
fileSizeBytes
long
File size
totalPlaytimeSeconds
long
Playtime at save
Methods:
SaveDataContainer
Internal JSON serialization wrapper.
saveDataEntries
List<TypedSaveDataEntry>
Type-keyed data
keyedSaveData
List<KeyedSaveDataEntry>
String-keyed data
saveTimestamp
long
When the container was saved
sparkVersion
string
Spark version at save time
Commands
SaveDataCommand
Triggers async save with optional completion callback
LoadDataCommand
Triggers async load with optional completion callback
ClearSaveDataCommand
Clears all in-memory data with optional callback
Storage Providers
The Save plugin supports pluggable storage backends through ISaveDataProvider:
LocalFileSaveProvider
Writes to local JSON files
SlotAwareLocalFileSaveProvider
Multi-slot local storage with versioning
Custom providers implement ISaveDataProvider and register via RegisterStorageProvider().
Usage
Creating Custom Save Data
Register the type during your plugin's initialization:
Last updated
Was this helpful?
