-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Codegen Configuration
All plugins are configured with standard .properties files. Most of the keys you'll see start with Jenny or Entitas, but you can add your own for custom plugins if you need it.
To use the parsed configuration, your plugins will need to implement IConfigurable, like so:
using System.Collections.Generic;
using DesperateDevs.Serialization;
public class MyConfigurablePlugin : ICodeGenerationPlugin, IConfigurable
{
Dictionary<string, string> defaultProperties { get; }
void Configure(Preferences preferences);
// Other methods and properties omitted for brevity
}TODO: Finish this section
- For kits containing pre-made
IComponents orISystems, configure whichContexts are used. - When C# attributes are unsuitable for your desired customization, e.g. when your customization doesn't revolve around specific C# constructs.
- For providing sensitive API information to your plugins, if necessary.
TODO: Document IConfigurable
TODO: Document how it's decided which .properties files to load
Prepending key names with your project or company name to mitigate collisions with those of other projects, i.e. use YourCompany.CustomCodeGens.Contexts instead of Contexts.
If you intend configuration values to be used as C# identifiers (e.g. when listing contexts) but also want to provide values with special meaning, give these values names that are not valid identifiers. Suppose, for instance, that you have a configuration that looks like this:
MyCompany.MyProject.SupportedContexts = Game, Input, Ui, Config
Entitas.CodeGeneration.Plugins.Contexts = Game, Input, Ui, ConfigIf you want to denote support for all contexts in your project, you could add a special value named All that generates code for all contexts, like so:
MyCompany.MyProject.SupportedContexts = AllBut Entitas generates lots of code that contains identifiers derived from context names, such as GameContext or InputEntity or UiMatcher. If you have a context that happens to be named All, this can complicate your life; you'd have to either handle errors or disambiguate it.
MyCompany.MyProject.SupportedContexts = All
Entitas.CodeGeneration.Plugins.Contexts = Game, Input, Ui, Config, AllShould this custom plugin support all contexts? Or just the context named All? If you have to write code to answer that question, you will have to deal with any bugs or edge cases that occur as a result. Consider using a special name that's not a valid C# identifier, like anything prepended with $:
MyCompany.MyProject.SupportedContexts = $All
Entitas.CodeGeneration.Plugins.Contexts = Game, Input, Ui, Config, AllGuides: Introduction - Installation - Upgrading - FAQ - Cookbook - Contributing
Need Help? Ask a question on Discord or create an issue.
- The Basics
- Concepts
- Architecture / Patterns