Skip to content
Christopher Williams edited this page Apr 19, 2021 · 18 revisions

You need a container for your entities, systems and components. The World is this container.

Creating a World

To assemble a world, you first configure it with WorldConfigurationBuilder.

WorldConfiguration config = new WorldConfigurationBuilder()
	.dependsOn(MyPlugin.class)
	.with(
		new MySystemA(),
		new MySystemB(),
		new MySystemC(),
	).build();

// All systems initialized and injected. 
World world = new World(config);

// Instance entities and assets here, or via your systems.

Integrating world in your game.

Typically games have a loop where the game gets updated and rendered each frame. Put the following logic in your game loop to have World iterate over all systems in order.

world.setDelta(delta);
world.process();

WorldConfigurationBuilder

The builder is where you alter and extend the artemis-odb framework. Here you register systems, plugins and inject Pojo's, and more advanced features like custom dependency injector

Usage

WorldConfiguration config = new WorldConfigurationBuilder()
   .with( new MyManagerA(), new MyManagerB()  ) 
   .with( new MySystemA(), new MySystemB(), new MySystemN()  )
   .with( new MyPluginA(), new MyPluginB(), new MyPluginN()  )
   .register( new MyDIResolver())
   .build();

Order of addition is preserved, but can be overridden. This is especially useful for writing plugins.

  // Systems and managers are called from highest to lowest priority. Default is `NORMAL`.
  .with( WorldConfigurationBuilder.Priority.HIGH + 1, new MyPluginA())
Clone this wiki locally