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
The following C# code creates API class and loads your data.
The loaded data is read-only.
You can access your documents as a list:
Or you can access specific documents by their Id or 'unique' fields:
Settings entities are accessed by name:
Formulas are executed with Invoke method:
Formula parameters are passed as common arguments of method.
GameData methods and properties
The list of supported localizations. Must contain at least one.
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.
Go through whole document hierarchy using the supplied Visitor.
Get iterator for all documents.
Extension point for 'partial' class. Called after loading the data into lists and dictionaries and before processing references and marking documents read-only.
Extension point for 'partial' class. Called after loading and prepping all data.