-
Notifications
You must be signed in to change notification settings - Fork 5
Configs
URSA has a Configuration system that:
- Has a ConfigSystem as a manager
- Uses ConfigBase that is a child of ComponentBase thus it is an ECS Component and is accessible through the Pool
- supports save a load from files on disk with different modes.
##Intro Configs are just a set of data objects that will live for the whole lifecycle of the program, and are global. They are different from PersistentData, they will ignore changes of profiles and are used to:
- Hold core engine state configuration, like graphics options, input layouts
- Hold global gameplay variables, like player speed, drop rates, etc.
- Save data that should be retained between sessions, like - what was the last player profile/save file used, etc.
ConfigSystem allows you to specify where you want your files to be saved.
##Usage
Creating new config component is nearly identical to Component , but you inherit from ConfigBase instead and add ConfigAttribute to your class, providing config pretty name and description.
Instead of using SerializedData like Component, config is using **exclusively rVars ** that are serialized directly from the body of the class. Types that are not wrapped in rVar will not be serialized.
Multiple instances of the same config object are not supported.
The ConfigAttribute's name and description are not for developer but for players that want to modify it.
To register variable in the console add ConsoleVar attribute.
[Config("Internal", "Edit at your own risk, these are not intended to be changed, but have fun breaking the game :) ")]
public class InternalConfig : ConfigBase
{
const string inter = "internal.";
[ConsoleVar(inter+ "updateAllowed", "will the simulation systems update")]
public r_bool UpdateAllowed = new r_bool();
[ConsoleVar(inter+ "debugGui", "show debug gui")]
public r_bool DebugGUI = new r_bool();
public r_string player_prefab = new r_string( "player");
public r_string ui_prefab = new r_string( "ui");
public override void OnEnable()
{
base.OnEnable();
}
public override void OnDisable()
{
base.OnDisable();
}
}