Click or drag to resize

PersistentFieldsDatabaseAttribute Class

A simple annotation to associate a persistent group with a game's database key.
Inheritance Hierarchy

Namespace:  KSPDev.ConfigUtils
Assembly:  KSPDev_Utils.1.1 (in KSPDev_Utils.1.1.dll) Version: 1.1 for KSP v1.6+
Syntax
C#
[AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Struct, AllowMultiple = true)]
public sealed class PersistentFieldsDatabaseAttribute : AbstractPersistentFieldsFileAttribute
Request Example View Source

The PersistentFieldsDatabaseAttribute type exposes the following members.

Constructors
  NameDescription
Public methodPersistentFieldsDatabaseAttribute
Initializes a new instance of the PersistentFieldsDatabaseAttribute class
Top
Remarks

Each .cfg file in the mod's folders is scanned and indexed by the game on start. The data is stored in the database where it can be accessed from the game. The access is read-only, any changes to the node returned from the database won't affect the database state.

The config file in the database is identified by a key which is made of three major parts:

  • A file path relative to GameData. ATTENTION: the path must not contain "."!
  • The config filename without extension.
  • Node path inside the file starting from the root. I.e. the root node should have name as well.

E.g. key KIS/settings/KISConfig/Global addresses a node KISConfig/Global in file stored at GameData/KIS/settings.cfg.

Special case is subfolders PluginData, they are ignored during database scan. Put there configs that can change during the gameplay. Remember, that even a tiny change in the config will trigger database re-compilation on the next start which may significantly impact game loading time.

Database is actively used by ModuleManager (a.k.a. MM). Be wise when choosing if the fields should be read from a file or from the database. The module manager patches are only applied on the database, they don't affect the config files. E.g. if the part config is expected to be a target of the MM patches but never updated from the gameplay, then reading id via the database is the best choice. However, various mod's settings, that change during the game, will unlikely be a target for a MM patch - put the config into PluginData and read it as a file.

See Also