Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

@ArtemisManager

Adrian Papari edited this page · 3 revisions

Configures an artemis Manager by injecting code during the compilation phase.

Simulates Aspects by prepending if-checks before any methods defined in EntityObserver.

Fields for ComponentMappers, EntitySystems and Mangers are wired in the initialize method, prior to any existing code in the initialize method is executed.

Component mappers are named according to the component type they operate on, suffixed with -Mapper. Systems and managers retain their full type name. All field names are camelCased.

Minimal example

What you type:

@ArtemisManager(
    requires={Cullable.class, Renderable.class})
public final class CullableManager extends Manager
{
    @Override
    protected void initialize() {}

    @Override
    public void added(Entity e)
    {
        Vector2 size = cullableMapper.get(e).size;
        Sprite sprite = renderableMapper.get(e).sprite;

        if (size.x == 0) size.x = sprite.getWidth();
        if (size.y == 0) size.y = sprite.getHeight();
    }
}

What the JVM gets:

@WovenByTheHuntress // marker annotation; don't process class when present
@ArtemisManager(
    requires={Cullable.class, Renderable.class})
public final class CullableManager extends Manager
{
    private ComponentMapper<Cullable> cullableMapper;
    private ComponentMapper<Renderable> renderableMapper;

    @Override
    protected void initialize()
    {
        cullableMapper = world.getMapper(Cullable.class);
        renderableMapper = world.getMapper(Renderable.class);
    }

    @Override
    public void added(Entity e)
    {
        if (!cullableMapper.has(e)) return;
        if (!renderableMapper.has(e) return;

        Vector2 size = cullableMapper.get(e).size;
        Sprite sprite = renderableMapper.get(e).sprite;

        if (size.x == 0) size.x = sprite.getWidth();
        if (size.y == 0) size.y = sprite.getHeight();
    }
}
Something went wrong with that request. Please try again.