Skip to content
Daan van Yperen edited this page Aug 11, 2015 · 50 revisions

Entities are distinct containers of related components.

Creating

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

Or

  • Archetype - Fastest, low level, no parameterized components.
  • Entity Factory - Fast, clean and convenient. For fixed composition entities. Requires some setup.
  • Edit created entity - Fast, bit verbose. see below.

Editing

classes

  EntityEdit chickenEdit = entity.edit();
  Flaming flaming = chickenEdit.create(Flaming.class);
  flaming.strength = 500;
  chickenEdit.remove(Freezing.class);

Entity Transmuters allow for high performance edits.

instances

entity.edit().add(new Flaming(500))

Discouraged for games that may require pooling or packing!

Good to know

Delayed Subscriptions

Events for Created, altered or removed entities are postponed until the current system has done processing and the next system is about to be invoked. This removes the need for systems to defend their subscription lists and allows for cleaner code and better performance.

Clone this wiki locally