Skip to content
Daan van Yperen edited this page Aug 2, 2015 · 17 revisions

Why

  • Makes your odb extension easy to use.
  • Avoids dependency clashes with other extensions.
  • Inject systems/managers before/after others.

How?

Implement ArtemisPlugin.

When adding plugin dependencies, use WorldConfigurationBuilder#dependsOn instead of #wire. #DependsOn ensures dependencies that already exist are not instanced twice. Plugin users are not required to use #DependsOn as their systems/managers will be instanced before the plugins.

see WorldConfigurationBuilder for all options.

Example

public class MyPlugin implements ArtemisPlugin {

    @Override
    public void setup(WorldConfigurationBuilder b) {

        // hook plugins.
        b.dependsOn(ExtendedComponentMapperPlugin.class);

        // hook managers or systems.
        b.dependsOn(TagManager.class, GroupManager.class);
        b.dependsOn(MySystemA.class, MySystemB.class);

        // Optionally Specify loading order.
        b.with(WorldConfigurationBuilder.Priority.HIGH, new LoadFirstSystem());

        // And your custom DI features!
        b.register(new MyFieldResolver());
    }
}

Using

  WorldConfiguration myConfig = new WorldConfigurationBuilder()
                .with(new TagManager())
                .with(new MyGameSystemA(), new MyGameSystemB())
                .with(new MyPlugin())
                .build();