Atlas
A Convenient Entity Component System
|
An Entity Component System is a software technique using Composition rather than Inheritance to build high-performance code-architectures. Atlas was designed to take advantage of the decoupling and effeciency that this architecture provides in modern C++ 11.
Atlas is a simple and convenient component entity system that has influences from the popular Java ECS Artemis
This simple example showcases Atlas' use of a PositionComponent
and VelocityComponent
in conjuction with a MovementSystem
to process the movement of an Atlas::Entity
.
Entities are essensially a container of Components. Each Atlas::Entity
has a unique Atlas::Entity::ID
that is used to represent relationships with Atlas::Component
s.
All entities are created internally by the Atlas::EntityManager
. In addition Atlas::World
provides a delegated function to create entities.
To destroy an Atlas::Entity
, you simply set it as inactive and it will be destroyed on the next Atlas::EntityManager::update()
Atlas::EntityManager
Atlas::Entity
holds two bitsets: one for represents Components and one for SystemsAtlas::Component
s the entity ownsAtlas::System
s that the entity is being processed by Atlas was designed for users to keep logic and data separate. Data is placed into components. All components inherit from Atlas::Component
.
Components can be attached to entities through Atlas::EntityManager::addComponent()
or Atlas::Entity::addComponent()
.
Components can be retrieved through Atlas::EntityManager::getComponentFor<>()
or Atlas::Entity::getComponent<>()
. This will return a pointer to the base type for the component.
Atlas::EntityManager
Atlas::ComponentIdentifier
through the Atlas::ComponentIdentifierManager
std::vector
using the ID from the Atlas::ComponentIdentifier
and Atlas::Entity::ID
as indexes to it's position in a table-like structure Most, if not all, logic should be placed within a System. Each system should inherit from Atlas::System
.
All systems must implement the Atlas::System::update()
function and each system is responsible for adding the component types that it is interested in processing.
Atlas::Entity::ID
s to refer to entitiesAtlas::Entity
, all systems recieve a notification that checks if the entity should be processed by the system The Atlas::GroupManager
provides a grouping mechanism for entities. This allows for entities to be assigned to and retrieved from named groups.
This can be used to process a subset of entities, such as "Enemies", "Bullets", or "Allies".
Retrieve and process "Enemies" only: