SavedData
namespace Griff.Scenes;
public sealed class SavedDataA component’s saved values as an UpgradeFromAttribute step sees them, before they’re read into the component. Properties are named as they are in code (“MoveSpeed”); values are the same types the component’s properties have (numbers, text, vectors, colors, enums, lists of lines).
Properties
Section titled “Properties”Fields
Section titled “Fields”public SavedData? Fields { get; }In a saved game (as an ISaveUpgrader sees it), a script’s own fields: its private fields and the rest a saved game keeps besides its properties, or what it saves itself (ISavesState), to read and change by name as properties are (“_wave” for a field called _wave, “Day” for an auto property’s). Null if none were saved. A field holding an object or a list points to it in the save’s objects (see Objects).
public JsonObject Json { get; }The raw JSON, for changes the other methods don’t cover. Keys are camelCase (“moveSpeed”).
Methods
Section titled “Methods”public T? Get<T>(string property, T? fallback = null)The saved value of property, or fallback if there’s none or it isn’t a T.
public bool Has(string property)True if a value was saved for property.
Remove
Section titled “Remove”public void Remove(string property)Forgets the value of property.
Rename
Section titled “Rename”public void Rename(string from, string to)Moves the value of from to to (nothing happens if there’s none).
public void Set<T>(string property, T? value)Saves value as property, replacing what was there.