Skip to content
Adrian Papari edited this page Feb 3, 2015 · 50 revisions

In artemis-odb, an Entity wraps a set of related components, and provides helper methods for component and entity management.

You cannot customize entities directly, extend the functionality by means of custom components.

Creating

 Entity myEntity = new EntityBuilder(world)
 .with(new Pos(10,10), new Anim("Chicken"))
 .tag("boss")
 .group("enemies")
 .build();

alternatively:

  • use EntityFactory - Fast, clean and convenient. For fixed composition entities. Requires some setup.
  • use Archetype - Fastest, low level, no support for parameterized components.
  • Call world.createEntity().edit()

Components post creation

Adding

  Flaming flaming = entity.edit().create(Flaming.class);
  flaming.strength = 500;

User managed components are possible but discouraged: entity.edit().add(new Flaming(500))

Removing

  entity.edit().remove(Flaming.class);

Entity Transmuters

Fastest way of changing entity component compositions. Primarily useful when bootstrapping entities over several different managers/systems or when dealing with many entities at the same time (lightweight particle systems etc).

// initialize to a field
this.transmuter = new EntityTransmuterFactory(world)
			.add(Sprite.class)
			.add(Renderable.class)
			.remove(AssetReference.class)
			.build();

// apply transformation to entity
this.transmuter.transmute(entity)
Clone this wiki locally