Class SaveGameData
ENGINE LAYER - Container for all save game data
Architecture:
- Generic container, systems populate their own sections
- Metadata for version compatibility and UI display
- State snapshot for fast loading
- Command log for determinism verification
Usage: SaveManager creates this, passes to systems via OnSave() Systems populate their data sections SaveManager serializes to disk
[Serializable]
public class SaveGameData
- Inheritance
-
objectSaveGameData
Fields
commandLog
Command history (last N commands for verification) Serialized command bytes
public List<byte[]> commandLog
Field Value
- List<byte[]>
currentTick
Current game tick when saved
public int currentTick
Field Value
- int
expectedChecksum
Expected checksum after replaying command log Used to verify determinism
public uint expectedChecksum
Field Value
- uint
gameSpeed
Current game speed when saved
public int gameSpeed
Field Value
- int
gameVersion
Game version that created this save (for compatibility checks) Format: "1.0.0"
public string gameVersion
Field Value
- string
saveDateTicks
Date/time when save was created (for sorting/display) Stored as ticks for serialization
public long saveDateTicks
Field Value
- long
saveFormatVersion
Save file format version (incremented when format changes) Allows migration of old saves to new format
public int saveFormatVersion
Field Value
- int
saveName
User-facing save name (displayed in UI)
public string saveName
Field Value
- string
scenarioName
Scenario name (e.g., "1444 Start")
public string scenarioName
Field Value
- string
systemData
Generic storage for system-specific data Key: System name, Value: Serialized system data Systems can store byte[] or custom serializable objects
public Dictionary<string, object> systemData
Field Value
- Dictionary<string, object>
Methods
GetSaveDate()
Get save date as DateTime
public DateTime GetSaveDate()
Returns
- DateTime
GetSystemData<T>(string)
Get system data for a specific system
public T GetSystemData<T>(string systemName) where T : class
Parameters
systemNamestring
Returns
- T
Type Parameters
T
IsCompatibleVersion(string)
Check if this save is compatible with current game version
public bool IsCompatibleVersion(string currentVersion)
Parameters
currentVersionstring
Returns
- bool
SetSaveDate(DateTime)
Set save date from DateTime
public void SetSaveDate(DateTime date)
Parameters
dateDateTime
SetSystemData(string, object)
Set system data for a specific system
public void SetSystemData(string systemName, object data)
Parameters
systemNamestringdataobject