A composite class representing any object in a game.
More...
#include <GameObject.hpp>
|
template<typename... Ts> |
bool | send (int slot, Ts...params) |
|
template<typename... Ts> |
bool | send (const char *slot, Ts...params) |
|
template<typename T > |
T * | recv (int slot) |
|
template<typename T > |
T * | recv (const char *slot) |
|
template<typename T , typename... Ts> |
void | attach (Ts...params) |
|
template<typename T > |
bool | composed () const |
|
template<typename T > |
void | detach () |
|
template<typename T > |
T * | get () const |
|
template<typename... Ts> |
void | update (Ts...params) |
|
template<typename... Ts> |
void | render (Ts...params) |
|
template<typename... Ts> |
void | handleEvent (Ts...params) |
|
template<typename Derived, typename ComponentType>
class lm::GameObject< Derived, ComponentType >
A composite class representing any object in a game.
This class should be used as a CRTP.
- Template Parameters
-
Derived | The derived class, for CRTP |
ComponentType | The derived component type |
template<typename Derived , typename ComponentType >
template<typename T , typename... Ts>
Attach a new component to the game object It's undefined behavior to attach multiples instances of the same component.
- Template Parameters
-
T | The component to create |
Ts | Constructor parameter types |
- Parameters
-
params | Constructor parameters |
template<typename Derived , typename ComponentType >
template<typename T >
Check wether a component is attached to this object.
- Template Parameters
-
T | The component type to check |
- Returns
- True if the object holds a component of type T
template<typename Derived , typename ComponentType >
template<typename T >
Detach the component of type T attached to this object. If there is no such component, do nothing.
- Template Parameters
-
template<typename Derived , typename ComponentType >
template<typename T >
Get a pointer to the component of type T attached to this object. If there is no such component, return nullptr.
- Template Parameters
-
- Returns
- A pointer to the component, or nullptr.
template<typename Derived , typename ComponentType >
template<typename... Ts>
void lm::GameObject< Derived, ComponentType >::handleEvent |
( |
Ts... |
params | ) |
|
|
inline |
Iterate over each component, and call handleEvent on them.
- Template Parameters
-
- Parameters
-
template<typename Derived , typename ComponentType >
template<typename T >
Get a response from a component
- Template Parameters
-
- Parameters
-
slot | The slot to listen to. |
- Returns
- A pointer to data, or nullptr.
template<typename Derived , typename ComponentType >
template<typename T >
T* lm::GameObject< Derived, ComponentType >::recv |
( |
const char * |
slot | ) |
|
|
inline |
Get a response from a component
- Template Parameters
-
- Parameters
-
slot | The slot to listen to - it will be hashed at compile time if possible |
- Returns
- A pointer to data, or nullptr.
template<typename Derived , typename ComponentType >
template<typename... Ts>
Iterate over each component, and call render on them.
- Template Parameters
-
- Parameters
-
template<typename Derived , typename ComponentType >
template<typename... Ts>
bool lm::GameObject< Derived, ComponentType >::send |
( |
int |
slot, |
|
|
Ts... |
params |
|
) |
| |
|
inline |
Send a message to every components this GameObject holds
- Template Parameters
-
- Parameters
-
slot | The destination slot |
params | Parameters |
- Returns
- True if the message was received by at least one component
template<typename Derived , typename ComponentType >
template<typename... Ts>
bool lm::GameObject< Derived, ComponentType >::send |
( |
const char * |
slot, |
|
|
Ts... |
params |
|
) |
| |
|
inline |
Send a message to every components this GameObject holds
- Template Parameters
-
- Parameters
-
slot | The destination slot - it will be hashed at compile time |
params | Parameters |
- Returns
- True if the message was received by at least one component
template<typename Derived , typename ComponentType >
template<typename... Ts>
Iterate over each component, and call update on them.
- Template Parameters
-
- Parameters
-
The documentation for this class was generated from the following file: