Skip to main content

SavingSystem.SavingSetup

A class in Root.Township, Alta.Saving.

How one savable type is saved: its hash, every save data version registered with SaveStructure, and its parent type's setup. Built by SavingSystem at startup.

Constructors​

MemberWhat it is
SavingSetup(Type topic)Creates a SavingSystem.SavingSetup from topic.

Fields​

6 private and internal fields
MemberWhat it is
private SavingSystem.VersionSetup latestSetupSetup for the newest save format version. Exposed as LatestSetup.
private uint latestVersionThe newest save format version number. Exposed as LatestVersion.
private static Logger loggerNLog logger.
private static MethodInfo saveMethodReflection handle to SaveInternal.
private Dictionary<Type, uint> typeToVersionVersion number for each save data type.
private Dictionary<uint, SavingSystem.VersionSetup> versionsSetup for each save format version.

Properties​

MemberWhat it is
uint Hash { get; private set; }The type's save hash, from SavingInfo or the hash of its class name.
bool IsComponent { get; private set; }Whether the type is a Unity component.
bool IsTag { get; private set; }Whether the type is a tag, added to the entity on load if missing.
SavingSystem.VersionSetup LatestSetup { get; }The version setup for the latest version.
uint LatestVersion { get; }The highest registered version.
SavingSystem.SavingSetup Parent { get; private set; }The setup of the nearest base type that is also saved, written after this one.
Func<object, ISerializeChildren, SaveData> Save { get; private set; }Calls the target's ISavable.Save for the latest data type.
Type Topic { get; }The savable type this setup is for.

Methods​

MemberWhat it is
void Add(uint version, Type dataType)Registers a save data type for a version. The highest version becomes the latest.
void FinishInitialization(Dictionary<Type, SavingSystem.SavingSetup> map)Links the parent setup and builds Save. Logs an error if the type doesn't implement ISavable for its latest data type.
SavingSystem.VersionSetup GetSetup(uint version)The version setup for a version number, or null.
uint GetVersion(SaveData data)The version number of a save data object's type, or 0.
3 private and internal methods
MemberWhat it is
private static T Cast<T>(object value)Casts an object to a type. Not called in this class.
private void ProcessInfo()Reads the hash and tag flag from SavingInfoAttribute, or hashes the type name if there is no hash.
private static SaveData SaveInternal<T>(object target, ISerializeChildren children)Calls the type's ISavable Save for a given save data type; bound into Save by reflection.

Used in​

Members of other types that take, return or hold a SavingSetup: