Game of Ur 0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
|
The Entity is a wrapper on an entity ID, used as the primary interface between an application and the engine's ECS system. More...
#include <ecs_world.hpp>
Public Member Functions | |
Entity (const Entity &other) | |
Construct a new Entity object. | |
Entity (Entity &&other) noexcept | |
Construct a new Entity object. | |
Entity & | operator= (const Entity &other) |
Copies an Entity object, replacing any component values currently present on this one. | |
Entity & | operator= (Entity &&other) noexcept |
Moves other's resources into this object, while destroying previously held resources associated with this. | |
~Entity () | |
Destroy the Entity object. | |
EntityID | getID () |
Gets the ID associated with this Entity. | |
void | copy (const Entity &other) |
Copies component values from another entity into this one. | |
template<typename TComponent> | |
void | addComponent (const TComponent &component) |
Adds a new component to this Entity. | |
void | addComponent (const nlohmann::json &jsonComponent) |
Adds a new component to this Entity based on its JSON description. | |
template<typename TComponent> | |
void | removeComponent () |
Removes a component from an entity. | |
void | removeComponent (const std::string &typeName) |
Removes a component from an entity. | |
template<typename TComponent> | |
bool | hasComponent () const |
Tests whether this entity has a particular component. | |
bool | hasComponent (const std::string &typeName) const |
Tests whether this entity has a particular component. | |
template<typename TComponent> | |
TComponent | getComponent (float simulationProgress=1.f) const |
Get the value of the component at a specific time this frame. | |
template<typename TComponent> | |
void | updateComponent (const TComponent &newValue) |
Updates the value of a component belonging to this Entity. | |
void | updateComponent (const nlohmann::json &jsonValue) |
Updates the value of a component belonging to this Entity. | |
template<typename TSystem> | |
bool | isEnabled () const |
Tests whether this entity is enabled for a particular system. | |
template<typename TSystem> | |
bool | isRegistered () const |
Tests whether this entity is eligible for participation with a given system. | |
template<typename TSystem> | |
void | enableSystem () |
Enables this Entity for a particular System. | |
template<typename TSystem> | |
void | disableSystem () |
Disables this entity for a particular system. | |
void | disableSystems () |
Disables this entity's participation in all systems. | |
void | enableSystems (Signature systemMask) |
Enables this entity's participation in a set of systems. | |
std::weak_ptr< ECSWorld > | getWorld () |
Get the ECSWorld object this Entity belongs to. | |
void | joinWorld (ECSWorld &world) |
Removes this Entity from its current ECS world, and moves it to the new one. | |
Private Member Functions | |
Entity (EntityID entityID, std::shared_ptr< ECSWorld > world) | |
Construct a new Entity object, with a new ID as a member of a new ECSWorld. | |
Private Attributes | |
EntityID | mID |
The ID of this entity within its owning ECSWorld. | |
std::weak_ptr< ECSWorld > | mWorld |
The world this Entity belongs to. | |
Friends | |
class | ECSWorld |
The Entity is a wrapper on an entity ID, used as the primary interface between an application and the engine's ECS system.
Holds an entity ID, and has several methods for querying and changing components, participation in different systems belonging to its ECSWorld.
Entity::Entity | ( | const Entity & | other | ) |
Construct a new Entity object.
other | The entity whose components will be copied to create this one. |
|
noexcept |
Construct a new Entity object.
other | Soon to be destroyed entity whose resources this object will now own. |
void Entity::addComponent | ( | const nlohmann::json & | jsonComponent | ) |
Adds a new component to this Entity based on its JSON description.
jsonComponent | A description of the new component, including its type and initial value. |
void ToyMaker::Entity::addComponent | ( | const TComponent & | component | ) |
Adds a new component to this Entity.
TComponent | The type of component being added. |
component | The initial value of the component when added. |
void Entity::copy | ( | const Entity & | other | ) |
Copies component values from another entity into this one.
other | The Entity being copied from |
void ToyMaker::Entity::disableSystem | ( | ) |
Disables this entity for a particular system.
TSystem | The System this entity is being disabled on. |
void Entity::disableSystems | ( | ) |
Disables this entity's participation in all systems.
void ToyMaker::Entity::enableSystem | ( | ) |
Enables this Entity for a particular System.
TSystem | The System this entity is being enabled for. |
void Entity::enableSystems | ( | Signature | systemMask | ) |
Enables this entity's participation in a set of systems.
systemMask | A bitset, each position of which corresponds to a SystemType for which activation is to be attempted. |
TComponent ToyMaker::Entity::getComponent | ( | float | simulationProgress = 1.f | ) | const |
Get the value of the component at a specific time this frame.
TComponent | The type of component being retrieved. |
simulationProgress | Progress towards the next simulation step from the last one, a value between 0 and 1. |
|
inline |
|
inline |
bool ToyMaker::Entity::hasComponent | ( | ) | const |
Tests whether this entity has a particular component.
TComponent | The type of component whose existence is being tested. |
true | The component is present; |
false | The component is absent; |
bool Entity::hasComponent | ( | const std::string & | typeName | ) | const |
Tests whether this entity has a particular component.
typeName | The component type string of the component being tested. |
true | The component is present; |
false | The component is absent; |
bool ToyMaker::Entity::isEnabled | ( | ) | const |
Tests whether this entity is enabled for a particular system.
TSystem | The System being queried. |
true | This entity is active on the system; |
false | This entity is not active on the system; |
bool ToyMaker::Entity::isRegistered | ( | ) | const |
Tests whether this entity is eligible for participation with a given system.
TSystem | The System being queried. |
true | This entity fulfills participation prerequisites; |
false | This entity fails participation prerequisites; |
void Entity::joinWorld | ( | ECSWorld & | world | ) |
void ToyMaker::Entity::removeComponent | ( | ) |
Removes a component from an entity.
TComponent | The type of component being retrieved. |
void Entity::removeComponent | ( | const std::string & | typeName | ) |
Removes a component from an entity.
typeName | The component type string of the component being removed. |
void Entity::updateComponent | ( | const nlohmann::json & | jsonValue | ) |
Updates the value of a component belonging to this Entity.
jsonValue | A json description of the value, which also includes its type. |
void ToyMaker::Entity::updateComponent | ( | const TComponent & | newValue | ) |
Updates the value of a component belonging to this Entity.
TComponent | The type of component being updated. |
newValue | The new value of the component. |