@ArtemisInjected

Adrian Papari edited this page Nov 24, 2013 · 2 revisions

Configures an arbitrary class by injecting an initialize(World) method during the compilation phase.

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:

@ArtemisInjected(
    mappers={ComponentA.class, ComponentB.class},
    managers=SomeManager.class,
    systems=BasicSystem.class)
public class InjectedType
{

}

What the JVM gets:

@WovenByTheHuntress // marker annotation; don't process class when present
@ArtemisInjected(
    mappers={ComponentA.class, ComponentB.class},
    managers=SomeManager.class,
    systems=BasicSystem.class)
public class InjectedType
{
    private ComponentMapper<ComponentA> componentAMapper;
    private ComponentMapper<ComponentB> componentBMapper;
    private SomeManager someManager;
    private BasicSystem basicSystem;

    public void initialize(World world)
    {
        componentAMapper = world.getMapper(ComponentA.class);
        componentBMapper = world.getMapper(ComponentB.class);
        basicSystem = world.getSystem(BasicSystem.class);
        someManager = world.getManager(SomeManager.class);
    }
}