Page tree

This page has not yet been translated to English.

Skip to end of metadata
Go to start of metadata

Accessing game data from source code is possible by using pregenerated API classes

We will use standard names in this example. You can set up your own class names before generation.

  • GameData - API class
  • Document - base class for all entities
  • Character - entity that describes game characters
    • Id - character's numerical identifier
    • Name - character's unique name
  • LootSettings - entity containing loot settings
    • ResetTime - loot reset period
    • RewardFormula - formula for calculating reward

Loading data

The following C# code creates API class and loads your data.

var fileStream = File.OpenRead("gamedata.json");
var gameData = new GameData(fileStream, GameData.Format.Json);

The loaded data is read-only.

Accessing documents

You can access your documents as a list:

var characters = gameData.GetCharacters() // -> ReadOnlyList<Character>
var characters = gameData.GetCharacters(onlyRoot: true) // -> ReadOnlyList<Character>

Or you can access specific documents by their Id or 'unique' fields:

var character = gameData.GetCharacter(characterId); // -> Character
var character = gameData.GetCharacterByName(characterName); // -> Character

Settings entities are accessed by name:

var resetTime = gameData.LootSettings.ResetTime; // -> TimeSpan


Formulas are executed with Invoke method:

var reward = gameData.LootSettings.RewardFormula.Invoke()  // -> int

Formula parameters are passed as common arguments of method.

GameData methods and properties





The list of supported localizations. Must contain at least one.

SetLanguage(string language)

Set current localization for every localized string within game data.

LocalizedString.Value returns either a string from current localization, or empty string if localization is missing.

ApplyVisitor(Visitor visitor)

Go through whole document hierarchy using the supplied Visitor.


Get iterator for all documents.

partial OnBeforeInitialize()

Extension point for 'partial' class. Called after loading the data into lists and dictionaries and before processing references and marking documents read-only.

partial OnInitialize()

Extension point for 'partial' class. Called after loading and prepping all data.

Related pages