Skip to content

Entity

The concept of Entity in an ECS is very different from a classical Entity class that can be found in other Game Engines, but it is very simple to understand.

An Entity is just a number, that correspond to a position in the differents arrays of Components stored in the Registry.

Here is a schema explaining how we retrieve values from the Entity index:

Name of the image

The class Entity looks like this:

class Entity {
    public:
        explicit Entity(size_t size) {};
        operator size_t() const {
            return _size;
        };
    protected:
    private:
        size_t _size;
};

Constructor

Entity()

explicit Entity(size_t size) {}
This constructors allows the Entity class to be constructed from a size_t value like this: Entity e = 13;

Operator

size_t()

operator size_t() const
Returns the size_t value of the Entity

Value

size_t _size

size_t _size
The "index" of the Entity in the Registry