Gentitas is a fast code generator for Entitas and a framework on top of Entitas. It watches your Assets
folder for Context declarations in .gentitas.cs
files and generates Entitas API from them.
Important! This project is dead and no longer maintained, I recommend using official Entitas Code Generator.
// Declaration
namespace Game.YourModule.Declaration
{
public class State : Context
{
State()
{
var Application = Component().GroupSingle;
var RabbitName = Component<string>().Index;
var Rabbit = Component();
var RabbitUnit = Component<float>().GroupSingle;
var Fast = Component();
var Speed = Component<float>().Group;
var RabbitWithName = Group(Matcher.All(Rabbit, RabbitName));
var FastRabbitName = Index(RabbitName, Rabbit, Fast);
}
}
}
// If generator is running, it will automatically
// regenerate API so you can use it immediately.
// Usage
void Example ()
{
// Components
var entity = Contexts.state.CreateEntity();
entity.rabbitName = "Steve";
entity.rabbit = true;
entity.fast = true;
entity.speed = 10f;
// Groups
var applicationEntity = Contexts.state.applicationEntity;
var applicationExists = Contexts.state.HasApplication();
var speedGroup = Contexts.state.speedGroup;
var speedEntities = Contexts.state.speedEntities;
var rabbitUnit = Contexts.state.rabbitUnit;
var rabbitWithNameGroup = Contexts.state.rabbitWithNameGroup;
// Index
var numberOfRabbitsWithNameSteve = Contexts.state.fastRabbitNameIndex.GetCount("Steve");
var rabbitsWithNameSteve = Contexts.state.fastRabbitNameIndex.Find("Steve");
var rabbitWithNameSteve = Contexts.state.fastRabbitNameIndex.FindSingle("Steve");
}
- Download latest version
- Move downloaded
Gentitas
folder into yourAssets/Plugins
* folder - Run
Tools/Entitas/Check System For Gentitas
- If you don't have Node.js installed - it will tell you
- Run
Tools/Entitas/Install Gentitas Dependecies
- Run
Tools/Entitas/Start Gentitas Generator
- Create
[AnyFileName].gentitas.cs
somewhere in yourAssets
folder - Add declaration code from First glimpse and save file
- Check your
Assets/Generated
folder - Enjoy generated Entitas API
*It's important to use Plugins
folder, otherewise Menu Items will not work.
Each release contains framework code, generator code and .sh
/ .cmd
scripts to run generator and install it's dependencies.
The project is hosted on GitHub where you can report issues, fork the project and submit pull requests.
Feel free to suggest your ideas.