#include <tb_entity_manager.h>
Public Types | |
typedef std::list< EntityInterface * > | EntityList |
Public Member Functions | |
EntityManager (void) | |
virtual | ~EntityManager (void)=0 |
void | AddEntity (EntityInterface *entity) |
void | AddEntity (EntityInterface &entity) |
void | RemoveEntity (EntityInterface *entity) |
void | RemoveEntities (const EntityType &byType=Entity::kInvalidType) |
EntityList | GetAllEntities (void) |
EntityList | GetEntitiesByType (const EntityType &byType) |
EntityList | GetEntitiesAt (const tbMath::Vector2 &point, const EntityType &byType=Entity::kInvalidType, bool onlyCollidableEntities=false) |
EntityList | GetEntitiesWithin (const tbMath::Vector2 ¢er, const float radius, const EntityType &byType=Entity::kInvalidType, bool onlyCollidableEntities=false) |
EntityList | GetEntitiesWithin (const tbMath::Vector2 ¢er, const float width, const float height, const EntityType &byType=Entity::kInvalidType, bool onlyCollidableEntities=false) |
void | Simulate (void) |
![]() | |
GraphicList (void) | |
virtual | ~GraphicList (void) |
void | AddGraphic (Graphic *graphic) |
void | AddGraphic (Graphic &graphic) |
void | RemoveGraphic (Graphic *graphic) |
virtual void | SetColor (const tbGraphics::Color &newColor) |
![]() | |
Graphic (void) | |
Graphic (const Graphic &other) | |
virtual | ~Graphic (void) |
bool | IsActive (void) const |
void | SetActive (const bool isActive) |
void | Update (const float deltaTime) |
bool | IsVisible (void) const |
void | SetVisible (const bool isVisible) |
void | Render (void) const |
const tbMath::Vector2 & | GetPosition (void) const |
void | SetPosition (const float x, const float y) |
void | SetPosition (const tbMath::Vector2 &position) |
float | GetDepth (void) const |
void | SetDepth (const float newDepth) |
bool | IsRelative (void) const |
Protected Member Functions | |
virtual void | OnUpdate (const float deltaTime) override |
![]() | |
virtual void | OnRender (void) const override |
![]() | |
const Color & | GetColor (void) const |
The EntityManager will contain several entities to Simulate, Update and Render as well as perform collisions and access the entities by type or area.
typedef std::list<EntityInterface*> TurtleBrains::Game::EntityManager::EntityList |
A simple list of entities.
TurtleBrains::Game::EntityManager::EntityManager | ( | void | ) |
Constructs an empty entity object which contains no Graphics and position is defaults to 0,0.
|
pure virtual |
Destructs an entity which currently (TurtleBrains v0.2.0) does not have any resources to clean up after.
void TurtleBrains::Game::EntityManager::AddEntity | ( | EntityInterface * | entity | ) |
First creates an Entity by calling the EntityFactoryInterface CreateEntity() then adds the entity to be managed and accessed.
Adds an Entity to the manager in a few containers for the entity to be accessed, and it will be simulated, updated and rendered each from of the game while it exists in the EntityManager. When the Entity is removed from the manager it will be deleted, cleaned up and destroyed.
void TurtleBrains::Game::EntityManager::AddEntity | ( | EntityInterface & | entity | ) |
Adds an Entity to the manager in a few containers for the entity to be accessed, and it will be simulated, updated and rendered each from of the game while it exists in the EntityManager. When the Entity is removed from the manager it will NOT be deleted or cleaned up, or destroyed. The entity manager will not 'own' an entity added this way.
EntityList TurtleBrains::Game::EntityManager::GetAllEntities | ( | void | ) |
TODO: TIM: Documentation: Teach the user how to use this.
EntityList TurtleBrains::Game::EntityManager::GetEntitiesAt | ( | const tbMath::Vector2 & | point, |
const EntityType & | byType = Entity::kInvalidType , |
||
bool | onlyCollidableEntities = false |
||
) |
TODO: TIM: Documentation: Teach the user how to use this.
EntityList TurtleBrains::Game::EntityManager::GetEntitiesByType | ( | const EntityType & | byType | ) |
TODO: TIM: Documentation: Teach the user how to use this.
EntityList TurtleBrains::Game::EntityManager::GetEntitiesWithin | ( | const tbMath::Vector2 & | center, |
const float | radius, | ||
const EntityType & | byType = Entity::kInvalidType , |
||
bool | onlyCollidableEntities = false |
||
) |
TODO: TIM: Documentation: Teach the user how to use this.
EntityList TurtleBrains::Game::EntityManager::GetEntitiesWithin | ( | const tbMath::Vector2 & | center, |
const float | width, | ||
const float | height, | ||
const EntityType & | byType = Entity::kInvalidType , |
||
bool | onlyCollidableEntities = false |
||
) |
TODO: TIM: Documentation: Teach the user how to use this.
|
overrideprotectedvirtual |
Calls Update() on each of the entities, before removing any entities that may have expired.
Reimplemented from TurtleBrains::Graphics::GraphicList.
Reimplemented in TurtleBrains::Game::GameScene.
void TurtleBrains::Game::EntityManager::RemoveEntities | ( | const EntityType & | byType = Entity::kInvalidType | ) |
Marks entities for removal by type, or removes all entities if Entity::kInvalidType is used.
void TurtleBrains::Game::EntityManager::RemoveEntity | ( | EntityInterface * | entity | ) |
Marks an Entity for removal from the EntityManger, the actual removal will happen at the end of either Simulate or Update to prevent modifying the container while iterating through it.
void TurtleBrains::Game::EntityManager::Simulate | ( | void | ) |
Calls Simulate() on each of the entities, and then calls PerformCollision() to check for collision updates before finally removing any entities that may have expired during the simulate logic.