-
Notifications
You must be signed in to change notification settings - Fork 1
Entity
In ecstasy, entities are simple bags of components grouped under a unique ID. All non zero entity IDs are considered valid.
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();
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*
If you want to create entities from files, have a look at the Data-driven-approach after you finished the basic tutorials.