dustArtemis, a fork of Artemis Entity System framework
java ecs artemis dustArtemis entity-component system
dustArtemis is a fork of Artemis Entity System, which is a BSD-licenced small Java framework for setting up Entities, Components and Systems.
Artemis is structured with a few main classes:
- World: Here all your entities, systems and components live. You define through a World instance what Systems will be iterated on at each "tick" and in which order.
- EntitySystem: This is where your logic goes into. They iterate over entities, but only those which meet the system's requirements.
- Entity: This is your game entity, its just an ID and works as a container for components.
- Component: This is your data holder.
Iterating over a few EntitySystems calling process() on each sounds simple enough, the interesting part is how they pick Entities they're interested in.
When an Entity is added to the World, the EntitySystems present must see if they're "interested" in the Entity, their interest is defined by which Components the Entity has, this is done through the Aspect class.
The Aspect class is defined by 3 sets of Component types:
- allSet: A set of Components of which the Entity must have all for it to be processed by the system.
- oneSet: A set of Components of which the Entity must have at least one for it to be processed by the system.
- exclusionSet: A set of Components of which the Entity must have none of them for it to be processed by the system.
An Aspect might be made out of any combination of the three sets, so you can have for example an EntitySystem that culls non-visible entities, it could be interested in entities which have a 'Spatial' component, one of either 'BoundingBox' or 'BoundingSphere' components and no 'Camera' component. Or maybe you just have an EntitySystem that calculates frame time, its interested in no entities, so it just has an empty Aspect. Its pretty flexible.
In any case, original Artemis site has a pretty good examples on how to start with it, the spaceship warriors demo project is nice for testing things out and seeing Artemis in action. Spaceship Warriors should work with dustArtemis with few, if any, changes.
I fork so you don't have to
The reason why I forked Artemis is because it had a few bugs that haven't been ever fixed (unless you look for other forks, like artemis-odb), and because I wanted to see if I could make some improvements to it, for example, converting it to The One True Brace Style.
More seriously, I didn't wanted complete changes in how it worked, just tweaks here and there. Mostly I removed quite a few classes and code sections that were redundant or not used (ie, some math utils, some inner classes that were generalized into a single class, etc), expanded Artemis backbone collection, the Bag, considerably so it can be used outside Artemis itself (adding general Java 8 goodness too), added comments, removed warnings, optimized a few things, etc.
I've seen a few forks with quite a few changes like adding an event system to it, bytecode weaving, and so on, but I prefer to maintain it simple, no extra build steps nor dependencies, so you only need Java 8, a repo clone and you're good to go.
I just opened the issue tracker, I have no idea how it works.
I've been using Bitbucktet repositories for a while, but I don't know how to use the more "advanced" features (merges, pull requests, etc).
dustArtemis repository (more details in the readme!)
original Artemis Entity System framework:
And of course, thanks a lot to Arni Arent, Artemis Entity System's original author