Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.
Lusito edited this page Nov 25, 2017 · 3 revisions

In ecstasy, entities are simple bags of components grouped under a unique ID. All non zero entity IDs are considered valid.

Creating and adding an entity

If you want to create an Entity, you need to ask your Engine for a new instance.

auto entity = engine.createEntity(); // returns Entity*

Entities need to be explicitly added to the engine so as to be processed by systems:

engine.addEntity(entity);

The reason this is divided into two steps is to allow you to add all of your components to the entity before actually adding it to the engine.

Removing entities from the engine is rather simple. Calling engine.removeEntity() or entity->destroy() frees the entity (possibly delayed).

engine.removeEntity(entity); // or entity->destroy();

Entity IDs

As said, each entity has a unique ID. You can get it using entity->getId(), which returns an uint64_t. Entities will have invalid IDs until they're added to an engine.

Entities can be retrieved from the engine using their ID:

auto entity = engine.getEntity(id); // returns Entity*

Data driven approach

If you want to create entities from files, have a look at the Data-driven-approach after you finished the basic tutorials.