Skip to content

Class DefDatabase

Namespace: Apogee.Content.Xml
Assembly: Apogee.Content.dll

The definitions of a game and its mods: every .xml file of the content folders, read in load order (a folder's files sorted, then its folders, each the same way), each file holding one definition (a root element with an id) or a list of them (the root's children). A definition is identified by its type (the element's name) and its id. A later file replaces a definition with the same id (with a warning that names both files), patches it with patch="true" (see ), or removes it with remove="true". Each definition is then checked against the schemas and decoded; what is wrong is in , and the definition is still there, with whatever could be made of it.

public sealed class DefDatabase

Inheritance

object ← DefDatabase

Inherited Members

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()

Properties

All

Every definition, in the order they were first defined.

public IReadOnlyList<Def> All { get; }

Property Value

IReadOnlyList<Def>

HasErrors

public bool HasErrors { get; }

Property Value

bool

Problems

public IReadOnlyList<SchemaProblem> Problems { get; }

Property Value

IReadOnlyList<SchemaProblem>

Types

The types that have definitions, sorted.

public IReadOnlyList<string> Types { get; }

Property Value

IReadOnlyList<string>

Methods

Get(string, string)

public Def? Get(string type, string id)

Parameters

type string

id string

Returns

Def?

Load(VirtualFileSystem, IReadOnlyList<DefFolder>, SchemaSet?)

Reads the definitions in folders (in this order) from files and checks them against schemas (none: they are read as plain XML).

public static DefDatabase Load(VirtualFileSystem files, IReadOnlyList<DefFolder> folders, SchemaSet? schemas = null)

Parameters

files VirtualFileSystem

folders IReadOnlyList<DefFolder>

schemas SchemaSet?

Returns

DefDatabase

Merge(XmlNode, XmlNode)

patch merged into original (neither changes): an attribute of the patch replaces the original's (and adds it when it has none), its text replaces the text, and its children are matched with the original's children by name and id or, without an id, by name and place (the second <Unit/> of a patch is the second of the original). A matched child is merged the same way, one with remove="true" removes its match, and one that matches nothing is added at the end. A child with append="true" is never matched: it is always added at the end (how to add a third <Tag> to a definition that has two). The patch, remove and append attributes are not kept.

public static XmlNode Merge(XmlNode original, XmlNode patch)

Parameters

original XmlNode

patch XmlNode

Returns

XmlNode

OfType(string)

public IReadOnlyList<Def> OfType(string type)

Parameters

type string

Returns

IReadOnlyList<Def>