master | development | ||||
---|---|---|---|---|---|
Entity Essentials is a Component-based Entity System written in Java. This framework provides operations and structures to work with entities and components. Apart from that, it provides a couple of useful extras. The current implementation isn’t a typical Entity Component System (ECS) known from game development as a part of a game engine. Instead, this framework is designed as foundation when you need the most flexible runtime-model for your application.
public class Quickstart
{
public static void main(String[] args) {
/* Create a context and obtain required managers */
Context context = ContextProvider.getInstance().createContext();
EntityManager entityManager = context.getService(EntityManager.class);
ComponentManager componentManager = context.getService(ComponentManager.class);
/* Create an entity */
EntityRef ref = entityManager.createEntity(context);
/* Add a component to the entity */
componentManager.addComponent(ref, ExampleComponent.class);
/* Lookup a component */
ExampleComponent cmp = componentManager.getComponent(ref, ExampleComponent.class);
/* Change the component's properties */
cmp.setText("Fubar!");
cmp.setTextSize(14);
/* Commit changes */
cmp.pushTo(ref);
/* Shutdown everything */
context.dispose();
}
/* Define a custom component by a java interface */
public interface ExampleComponent extends Component
{
/* Define properties by declaration of getters and setters */
String getText();
void setText(String text);
int getTextSize();
void setTextSize(int size);
}
}
More examples can be found here.
Group ID | Artifact ID | Version |
---|---|---|
org.jayware |
entity-essentials-api |
0.6.0 |
org.jayware |
entity-essentials-impl |
0.6.0 |
<repository>
<id>central</id>
<name>bintray</name>
<url>http://jcenter.bintray.com</url>
</repository>