|
Thrive
|
Convenience class to handle an entity. More...
#include <entity.h>
Classes | |
| struct | Implementation |
Public Member Functions | |
| Entity (GameState *gameState=nullptr) | |
| Constructor. More... | |
| Entity (EntityId id, GameState *gameState=nullptr) | |
| Constructor. More... | |
| Entity (const std::string &name, GameState *gameState=nullptr) | |
| Constructor. More... | |
| Entity (const Entity &other) | |
| Copy constructor. More... | |
| ~Entity () | |
| Destructor. | |
| Entity & | operator= (const Entity &other) |
| Copy assignment. More... | |
| bool | operator== (const Entity &other) const |
| Compares two entities. More... | |
| void | addComponent (std::unique_ptr< Component > component) |
| Adds a component to this entity. More... | |
| void | destroy () |
| Removes all components of this entity. | |
| bool | exists () const |
| Checks if the entity has any components. More... | |
| Component * | getComponent (ComponentTypeId typeId) |
| Retrieves a component by type id. More... | |
| bool | hasComponent (ComponentTypeId typeId) |
| Checks whether this entity has a component. More... | |
| EntityId | id () const |
| The entity's id. | |
| bool | isVolatile () const |
| Returns the volatile flag. More... | |
| void | addChild (Entity &child) |
| Adds a child to the current entity. More... | |
| bool | hasChildren () const |
| Returns whether the entity has any children. More... | |
| void | stealName (const std::string &name) |
| Rebinds the name to the new Id. More... | |
| void | removeComponent (ComponentTypeId typeId) |
| Removes a component by type id. More... | |
| Entity | transfer (GameState *newGameState) |
| Transfers an entity to a different gameState. More... | |
| void | setVolatile (bool isVolatile) |
| Sets the volatile flag. More... | |
Static Public Member Functions | |
| static luabind::scope | luaBindings () |
| Lua bindings. More... | |
Convenience class to handle an entity.
This is a thin wrapper around the EntityManager API. Mostly for script purposes, but if you prefer, you can use this class instead of directly calling the EntityManager functions.
| Entity::Entity | ( | GameState * | gameState = nullptr | ) |
Constructor.
Creates a new unnamed entity
| gameState | The game state the new entity belongs to. If null, the current game state of the global engine object is used. |
| Entity::Entity | ( | EntityId | id, |
| GameState * | gameState = nullptr |
||
| ) |
Constructor.
Interfaces to an existing entity
| id | The entity id to interface to |
| gameState | The game state the entity belongs to. If null, the current game state of the global engine object is used. |
| Entity::Entity | ( | const std::string & | name, |
| GameState * | gameState = nullptr |
||
| ) |
Constructor.
Interfaces to a named entity
Uses the EntityManager of Game::engine()
| name | The name of the entity to interface to |
| gameState | The game state the entity belongs to. If null, the current game state of the global engine object is used. |
| Entity::Entity | ( | const Entity & | other | ) |
Copy constructor.
This does not copy the entity's components, it just creates another wrapper.
| other |
| void Entity::addChild | ( | Entity & | child | ) |
Adds a child to the current entity.
| child |
| void Entity::addComponent | ( | std::unique_ptr< Component > | component | ) |
Adds a component to this entity.
| component |
| bool Entity::exists | ( | ) | const |
Checks if the entity has any components.
true if the entity has at least one component, false otherwise | Component * Entity::getComponent | ( | ComponentTypeId | typeId | ) |
Retrieves a component by type id.
| typeId | The component's type id |
nullptr if no such component was found | bool Entity::hasChildren | ( | ) | const |
Returns whether the entity has any children.
| bool Entity::hasComponent | ( | ComponentTypeId | typeId | ) |
Checks whether this entity has a component.
Equivalent to
| typeId | The component's type id |
true if such a component was found, false otherwise | bool Entity::isVolatile | ( | ) | const |
Returns the volatile flag.
Volatile entities are not serialized into a savegame
|
static |
Lua bindings.
Exposes the following constructors:
Exposes the following functions:
addComponent(Component): addComponent(std::unique_ptr<Component>)getComponent(number): getComponent(ComponentTypeId)removeComponent(number): removeComponent(ComponentTypeId)transfer(gameState) : transfer(gameState)setVolatile(bool) : setVolatile(bool)stealName(string): stealName(name)addChild(EntityId) : addChild(child)hasChhild(EntityId) : hasChildren()Exposes the following operators:
==: operator==(const Entity&) Copy assignment.
This does not copy the entity's components, it just changes the entity id this wrapper points to.
| bool Entity::operator== | ( | const Entity & | other | ) | const |
Compares two entities.
Entities compare to true if their entity ids are equal and they are part of the same game state.
| void Entity::removeComponent | ( | ComponentTypeId | typeId | ) |
Removes a component by type id.
If no such component was found, does nothing.
| typeId | The component's type id |
| void Entity::setVolatile | ( | bool | isVolatile | ) |
| void Entity::stealName | ( | const std::string & | name | ) |
Rebinds the name to the new Id.
| entityId | The stealing entity |
| name | The name to rebind |
1.8.10