GameEntity class that represents an entity in the game.
More...
#include <GameEntity.hpp>
|
| GameEntity (const GameEntity &entity) |
| Copy constructor to create a new entity from an existing one.
|
|
virtual void | Input (float deltaTime) |
| Handle input.
|
|
virtual void | Update (float deltaTime) |
| Update the entity.
|
|
virtual void | Render (SDL_Renderer *renderer) |
| Render the entity.
|
|
template<typename T > |
void | AddComponent (std::shared_ptr< T > component) |
| Add a component to the entity.
|
|
bool | HasComponent (ComponentType type) |
| Check if the entity has a component of a certain type.
|
|
template<typename T > |
std::shared_ptr< T > | GetComponent (ComponentType type) |
| Get a component of a certain type.
|
|
void | AddDefaultTransformComponent () |
| Add a default transform component to the entity.
|
|
std::shared_ptr< TransformComponent > | GetTransform () |
| Get the transform component of the entity.
|
|
void | SetRenderable (bool value) |
| Set the renderable flag.
|
|
bool | IsRenderable () const |
| Check if the entity is renderable.
|
|
bool | Intersects (std::shared_ptr< GameEntity > e) |
| Check if the entity intersects with another entity. Only checks for collision2D components.
|
|
void | OnStart () |
| Run when the entity is started.
|
|
void | AddTag (std::string tag) |
| Add a tag to the entity for identification.
|
|
std::vector< std::string > | GetTags () const |
| Get the tags of the entity.
|
|
void | SetOnStart (std::function< void()> onStart) |
| Set the function to be called when the entity is started.
|
|
void | SetOnInput (std::function< void(float)> onInput) |
| Set the function to be called when the entity receives input.
|
|
void | SetOnUpdate (std::function< void(float)> onUpdate) |
| Set the function to be called when the entity is updated.
|
|
|
std::vector< std::string > | mTags |
|
std::map< ComponentType, std::shared_ptr< Component > > | mComponents |
|
bool | mRenderable {true} |
|
std::function< void()> | mOnStart = nullptr |
|
std::function< void(float)> | mOnInput = nullptr |
|
std::function< void(float)> | mOnUpdate = nullptr |
|
GameEntity class that represents an entity in the game.
◆ GameEntity()
GameEntity::GameEntity |
( |
const GameEntity & | entity | ) |
|
Copy constructor to create a new entity from an existing one.
- Parameters
-
◆ AddComponent()
template<typename T >
void GameEntity::AddComponent |
( |
std::shared_ptr< T > | component | ) |
|
Add a component to the entity.
- Parameters
-
◆ AddTag()
void GameEntity::AddTag |
( |
std::string | tag | ) |
|
|
inline |
Add a tag to the entity for identification.
- Parameters
-
◆ GetComponent()
template<typename T >
std::shared_ptr< T > GameEntity::GetComponent |
( |
ComponentType | type | ) |
|
Get a component of a certain type.
- Template Parameters
-
- Parameters
-
- Returns
- std::shared_ptr<T>
◆ GetTags()
std::vector< std::string > GameEntity::GetTags |
( |
| ) |
const |
|
inline |
Get the tags of the entity.
- Returns
- std::vector<std::string> Tags
◆ GetTransform()
Get the transform component of the entity.
- Returns
- std::shared_ptr<TransformComponent> Transform component
◆ HasComponent()
bool GameEntity::HasComponent |
( |
ComponentType | type | ) |
|
Check if the entity has a component of a certain type.
- Parameters
-
- Returns
- true
-
false
◆ Input()
virtual void GameEntity::Input |
( |
float | deltaTime | ) |
|
|
virtual |
Handle input.
- Parameters
-
deltaTime | Time since last frame |
◆ Intersects()
bool GameEntity::Intersects |
( |
std::shared_ptr< GameEntity > | e | ) |
|
Check if the entity intersects with another entity. Only checks for collision2D components.
- Parameters
-
- Returns
- true if intersects
-
false if does not intersect
◆ IsRenderable()
bool GameEntity::IsRenderable |
( |
| ) |
const |
|
inline |
Check if the entity is renderable.
- Returns
- true if renderable
-
false if not renderable
◆ Render()
virtual void GameEntity::Render |
( |
SDL_Renderer * | renderer | ) |
|
|
virtual |
Render the entity.
- Parameters
-
◆ SetOnInput()
void GameEntity::SetOnInput |
( |
std::function< void(float)> | onInput | ) |
|
Set the function to be called when the entity receives input.
- Parameters
-
◆ SetOnStart()
void GameEntity::SetOnStart |
( |
std::function< void()> | onStart | ) |
|
Set the function to be called when the entity is started.
- Parameters
-
◆ SetOnUpdate()
void GameEntity::SetOnUpdate |
( |
std::function< void(float)> | onUpdate | ) |
|
Set the function to be called when the entity is updated.
- Parameters
-
◆ SetRenderable()
void GameEntity::SetRenderable |
( |
bool | value | ) |
|
|
inline |
Set the renderable flag.
- Parameters
-
◆ Update()
virtual void GameEntity::Update |
( |
float | deltaTime | ) |
|
|
virtual |
Update the entity.
- Parameters
-
deltaTime | Time since last frame |
The documentation for this struct was generated from the following file: