Search Results for

    Show / Hide Table of Contents

    Class SaveStateUtility

    Utility for saving and loading simulation states as well as particle configuration templates.

    A simulation state comprises the entire history of all particles in the system. It is stored in a SimulationStateSaveData object, which can be serialized and deserialized by Unity's JsonUtility.

    Similarly, InitModeSaveData objects represent the system state in Initialization Mode.

    Inheritance
    object
    SaveStateUtility
    Namespace: AS2
    Assembly: .dll
    Syntax
    public static class SaveStateUtility

    Fields

    | Edit this page View Source

    defaultSaveFile

    Default file for saving simulation states.

    Declaration
    public static string defaultSaveFile
    Field Value
    Type Description
    string
    | Edit this page View Source

    tmpSaveFile

    Temporary save file used to restore simulation when Init Mode is aborted.

    Declaration
    public static string tmpSaveFile
    Field Value
    Type Description
    string

    Methods

    | Edit this page View Source

    Load(string)

    Loads a simulation state from a save file.

    Declaration
    public static SimulationStateSaveData Load(string filename = null)
    Parameters
    Type Name Description
    string filename

    The file from which to read the save data. Default value is defaultSaveFile.

    Returns
    Type Description
    SimulationStateSaveData

    The serializable object representation of the data stored in the given file. Can be null if the file could not be read or its content could not be parsed correctly.

    | Edit this page View Source

    LoadInit(string)

    Loads an initialization state from a save file.

    Declaration
    public static InitializationStateSaveData LoadInit(string filename = null)
    Parameters
    Type Name Description
    string filename

    The file from which to read the save data. Default value is defaultSaveFile.

    Returns
    Type Description
    InitializationStateSaveData

    The serializable object representation of the data stored in the given file. Can be null if the file could not be read or its content could not be parsed correctly.

    | Edit this page View Source

    Save(SimulationStateSaveData, string, bool)

    Converts the given simulation state to JSON format and writes it to a file.

    Declaration
    public static bool Save(SimulationStateSaveData data, string filename = null, bool prettyPrint = false)
    Parameters
    Type Name Description
    SimulationStateSaveData data

    The serializable representation of the simulation state.

    string filename

    The file in which to store the JSON string. Default value is defaultSaveFile.

    bool prettyPrint

    If true, the JSON text is formatted to be human-readable. Note that this significantly increases the file size.

    Returns
    Type Description
    bool

    true if and only if the file was written successfully.

    | Edit this page View Source

    SaveInit(InitializationStateSaveData, string, bool)

    Converts the given initialization state to JSON format and writes it to a file.

    Declaration
    public static bool SaveInit(InitializationStateSaveData data, string filename = null, bool prettyPrint = false)
    Parameters
    Type Name Description
    InitializationStateSaveData data

    The serializable representation of the initialization state.

    string filename

    The file in which to store the JSON string. Default value is defaultSaveFile.

    bool prettyPrint

    If true, the JSON text is formatted to be human-readable. Note that this significantly increases the file size.

    Returns
    Type Description
    bool

    true if and only if the file was written successfully.

    • Edit this page
    • View Source
    In this article
    Back to top AmoebotSim 2.0 Documentation v1.11
    Copyright © 2025 AmoebotSim 2.0 Authors
    Generated by DocFX