Entity

Entity structure.

This is the combination of two 32-bits id: a unique-id and a version-id.

Constructors

this
this(EntityManager manager, Id id)
Undocumented in source.

Members

Functions

component
C* component()

Get a component pointer of the entity.

component
void component(C c)

Set the value of a component of the entity.

destroy
void destroy()

Destroy the entity (unregister all attached components).

id
Id id()

Returns the id of the entity.

invalidate
void invalidate()

Invalidate the entity instance (but does not destroy it).

isRegistered
bool isRegistered()

Tell whether a component is registered to the entity.

iterate
void iterate()

Iterate over the components registered to the entity. It calls the accessor delegate that has been set to each component.

opEquals
bool opEquals(Entity e)

Compare two entities and tells whether they are the same (same id).

register
C* register(Args args)

Register a component C to an entity.

toString
string toString()

Returns a string representation of an entity.

unregister
void unregister()

Unregister a component C from an entity.

valid
bool valid()

Tells whether the entity is valid.

Structs

Id
struct Id
Undocumented in source.

Variables

invalid
enum Id invalid;
Undocumented in source.

Examples

@component struct Position
{
    float x, y;
}

auto em = new EntityManager(new EventManager);
auto entity = em.create();
auto posCompPtr = entity.register!Position(2.0, 3.0);

assert(posCompPtr == entity.component!Position);
assert(posCompPtr.x == 2.0);
assert(entity.component!Position.y == 3.0);

Meta