Table of Contents

Class SaveDataBuilder

Namespace
Squiggles.Core.Data
Assembly
SquigglesCommon4X.dll

A utility class for serializing and deserializing structured data in a more custom way. Useful to pass as ref between different components.

public class SaveDataBuilder : IDisposable
Inheritance
SaveDataBuilder
Implements
Inherited Members

Constructors

SaveDataBuilder(bool)

public SaveDataBuilder(bool isEmbedded = true)

Parameters

isEmbedded bool

SaveDataBuilder(string, bool, bool)

Constructs a new SaveDataBuilder

public SaveDataBuilder(string filePath, bool alertErrs = false, bool useCurrentSaveSlot = true)

Parameters

filePath string

the file path to use

alertErrs bool

Whether or not to print out errors on failure. Defaults to false

useCurrentSaveSlot bool

Whether or not to use the root save slot ("user://")

Fields

_alertErrs

private readonly bool _alertErrs

Field Value

bool

_data

private Dictionary _data

Field Value

Dictionary

_filePath

private readonly string _filePath

Field Value

string

_isEmbedded

private readonly bool _isEmbedded

Field Value

bool

_useCurrentSlot

private readonly bool _useCurrentSlot

Field Value

bool

Properties

Iterator

public IEnumerable<KeyValuePair<string, string>> Iterator { get; }

Property Value

IEnumerable<KeyValuePair<string, string>>

Keys

public IEnumerable<string> Keys { get; }

Property Value

IEnumerable<string>

Methods

Append(SaveDataBuilder, string)

public void Append(SaveDataBuilder childBuilder, string subKey)

Parameters

childBuilder SaveDataBuilder
subKey string

GetBool(string)

Parses out a bool value from the given key, returning the default value on failure.

public bool GetBool(string key)

Parameters

key string

the key to search for

Returns

bool

the value stored, else the default value

GetBool(string, out bool)

Parses out a bool value from the key and outputs the value, returning whether or not parsing was successful.

public bool GetBool(string key, out bool value)

Parameters

key string

the key to search for

value bool

the value passed out as an out variable

Returns

bool

true if parsing was successful, false if not

GetFloat(string)

Parses out a float value from the given key, returning the default value on failure.

public float GetFloat(string key)

Parameters

key string

the key to search for

Returns

float

the value stored, else the default value

GetFloat(string, out float)

Parses out a float value from the key and outputs the value, returning whether or not parsing was successful.

public bool GetFloat(string key, out float value)

Parameters

key string

the key to search for

value float

the value passed out as an out variable

Returns

bool

true if parsing was successful, false if not

GetInt(string)

Parses out a int value from the given key, returning the default value on failure.

public int GetInt(string key)

Parameters

key string

the key to search for

Returns

int

the value stored, else the default value

GetInt(string, out int)

Parses out a int value from the key and outputs the value, returning whether or not parsing was successful.

public bool GetInt(string key, out int value)

Parameters

key string

the key to search for

value int

the value passed out as an out variable

Returns

bool

true if parsing was successful, false if not

GetString(string)

Parses out a string value from the given key, returning the default value on failure.

public string GetString(string key)

Parameters

key string

the key to search for

Returns

string

the value stored, else the default value

GetString(string, out string)

Parses out a string value from the key and outputs the value, returning whether or not parsing was successful.

public bool GetString(string key, out string value)

Parameters

key string

the key to search for

value string

the value passed out as an out variable

Returns

bool

true if parsing was successful, false if not

GetVector2(string)

Parses out a Vector2 value from the given key, returning the default value on failure.

public Vector2 GetVector2(string key)

Parameters

key string

the key to search for

Returns

Vector2

the value stored, else the default value

GetVector2(string, out Vector2)

Parses out a Vector2 value from the key and outputs the value, returning whether or not parsing was successful.

public bool GetVector2(string key, out Vector2 value)

Parameters

key string

the key to search for

value Vector2

the value passed out as an out variable

Returns

bool

true if parsing was successful, false if not

GetVector3(string)

Parses out a Vector3 value from the given key, returning the default value on failure.

public Vector3 GetVector3(string key)

Parameters

key string

the key to search for

Returns

Vector3

the value stored, else the default value

GetVector3(string, out Vector3)

Parses out a Vector3 value from the key and outputs the value, returning whether or not parsing was successful.

public bool GetVector3(string key, out Vector3 value)

Parameters

key string

the key to search for

value Vector3

the value passed out as an out variable

Returns

bool

true if parsing was successful, false if not

LoadEmbedded(string)

public SaveDataBuilder LoadEmbedded(string subKey)

Parameters

subKey string

Returns

SaveDataBuilder

LoadFromFile()

Loads the necessary data from file

public SaveDataBuilder LoadFromFile()

Returns

SaveDataBuilder

returns this calling save datat builder. Constructing a new one when failing to load

PutBool(string, bool)

Stores a bool value

public void PutBool(string key, bool value)

Parameters

key string

the key in the data (must be unique)

value bool

the value to assign

PutFloat(string, float)

Stores a float value

public void PutFloat(string key, float value)

Parameters

key string

the key in the data (must be unique)

value float

the value to assign

PutInt(string, int)

Stores an Int value

public void PutInt(string key, int value)

Parameters

key string

the key in the data (must be unique)

value int

the value to assign

PutString(string, string)

Stores a string value

public void PutString(string key, string value)

Parameters

key string

the key in the data (must be unique)

value string

the value to assign

PutVariant(string, Variant)

public void PutVariant(string key, Variant value)

Parameters

key string
value Variant

PutVector2(string, Vector2)

Stores a Vector2 value

public void PutVector2(string key, Vector2 value)

Parameters

key string

the key in the data (must be unique)

value Vector2

the value to assign

PutVector3(string, Vector3)

Stores a Vector3 value

public void PutVector3(string key, Vector3 value)

Parameters

key string

the key in the data (must be unique)

value Vector3

the value to assign

SaveToFile()

Writes out all data to disk using the parameters specified at construction.

public void SaveToFile()

Explicit Interface Implementations

IDisposable.Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

void IDisposable.Dispose()