Skip to content
Jimmy Cushnie edited this page Mar 10, 2019 · 7 revisions

Complex Types are any types that are not base types or collection types.

SUCC will save all the members of a complex type that meet the following criteria:

  • the member is a field or property
  • the member is not static
  • the member can be both read and written to
  • the member is public or has SUCC.DoSaveAttribute defined - see Custom Complex Type Rules
  • the member does not have SUCC.DontSaveAttribute defined - see Custom Complex Type Rules
  • the member is not an indexer

These members will be saved as child key nodes in the SUCC file, using the name of the member for the key.

See also: Complex Type Shortcuts

Example

using System.Collections.Generic;
using SUCC;

class NPC
{
    public string name;
    public string profession;
    public int health;
}

static class Program
{
    static void Main()
    {
        var characters = new List<NPC>()
        {
            new NPC()
            {
                name = "Garret",
                profession = "Builder",
                health = 100
            },
            new NPC()
            {
                name = "Kevin",
                profession = "Bear",
                health = 100
            },
        };

        var file = new DataFile("test");
        file.Set("characters", characters);
    }
}
characters:
    -
        name: Garret
        profession: Builder
        health: 100
    -
        name: Kevin
        profession: Bear
        health: 100
Clone this wiki locally