BaseContainer Usage – Arma Reforger
A BaseContainer is a data holder for many kinds of data: Prefab, Config, IEntitySource, IEntityComponentSource, WidgetSource, UserSettings, MetaFile are all BaseContainers.
Structure
Let's take a look at the Tree_Base.et Prefab to understand a BaseContainer's structure:
Tree {
// ...
Flags 524291
MaxHealth 10000
// ...
}
- Tree is the BaseContainer's class
- there is no inheritance, this is the topmost Prefab; inheritance (e.g in Tree_Coniferous_Base.et) looks like this:
Tree : "{388AE316D09D0680}Prefabs/Vegetation/Core/Tree_Base.et" { // ... }
- Tree being the class (a Prefab can have a class that is different from its ancestor)
- "{388AE316D09D0680}Prefabs
/Vegetation being the ancestor, the inherited Prefab/Core /Tree_Base.et"
- its Flags value is 524291, which is the General > Flags value of Traceable, Visible and Relative Y flags together
- its MaxHealth value is 10000, which is a GameCode-side property (not defined in script)
Inheritance
In case of inheritance:
- every level can set a property's value
- if the value is not defined in a level, the value is read from its ancestor where it is defined (making it a "default value" for its children)
- if a property is not set anywhere, the default value is the type's default value (see Scripting: Values - Types)
Object Array
A property can be an array of objects, represented as a BaseContainerList.
Usage
a BaseContainer cannot be strongly referenced in script (cref BaseContainer m_BaseContainer; // not possible).
See BaseContainerTools and SCR_BaseContainerTools classes for useful methods.
Create
Obtain
Read
Iterating a BaseContainerList:
Config =
IEntitySource
An IEntitySource can be obtained from WorldEditorAPI usage:
Localization
Meta File
Update
Editing:
Saving:
WorldEditorAPI
For a value that is not at root level, the path must be defined:
An IEntitySource component's value can be set the same way: