/entity-essentials

Entity Essentials - A Component-based Entity System

Primary LanguageJavaApache License 2.0Apache-2.0

Entity Essentials

Entity Essentials - E2

master development
Build Status Codecov Dependency Status Build Status Codecov Dependency Status

Description

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.

Quickstart

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.

Usage

Maven coordinates

Group ID Artifact ID Version

org.jayware

entity-essentials-api

0.6.0

org.jayware

entity-essentials-impl

0.6.0

Gradle

Repository
repositories {
   jcenter()
}
Dependencies
dependencies {
    compile group: 'org.jayware', name: 'entity-essentials-api', version: '0.6.0'
    runtime group: 'org.jayware', name: 'entity-essentials-impl', version: '0.6.0'
}

Maven

Repository
<repository>
    <id>central</id>
    <name>bintray</name>
    <url>http://jcenter.bintray.com</url>
</repository>
Dependencies
<dependency>
    <groupId>org.jayware</groupId>
    <artifactId>entity-essentials-api</artifactId>
    <version>0.6.0</version>
</dependency>
<dependency>
    <groupId>org.jayware</groupId>
    <artifactId>entity-essentials-impl</artifactId>
    <version>0.6.0</version>
    <scope>runtime</scope>
</dependency>

Contributions

All contributions are welcome: ideas, patches, documentation, bug reports, complaints.