6#include "../components/component.hpp"
7#include "../../platform/mouse.hpp"
33 virtual void onUpdate(
double deltaTime);
46 this->pendingDestroy =
true;
61 assert(
false &&
"Unique component already exist in gameobject");
79 if (
dynamic_cast<T*
>(*
it)) {
108 template <
typename T>
127 template <
typename T,
typename...
Args>
Base class for everything that lives in the scene.
Definition game_object.hpp:20
virtual void onEnable()
Called when the object becomes active.
Definition game_object.hpp:42
virtual void onUpdate(double deltaTime)
Per-frame update hook.
Definition game_object.cpp:40
bool active
Whether the object is active (updated/drawn).
Definition game_object.hpp:24
bool isActive()
Reports whether the object is active.
Definition game_object.cpp:30
virtual ~GameObject()
Definition game_object.cpp:34
std::vector< IComponent * > components
Components attached to this object.
Definition game_object.hpp:22
T * getComponent()
Returns the first attached component of a type.
Definition game_object.hpp:93
void setActive(bool a)
Activates or deactivates the object.
Definition game_object.cpp:24
bool pendingDestroy
Whether the object is queued for destruction.
Definition game_object.hpp:23
void appendComponent(T *component)
Attaches an existing component to this object.
Definition game_object.hpp:58
void destroyComponent()
Destroys and removes the first component of a type.
Definition game_object.hpp:77
GameObject()
Definition game_object.cpp:8
std::vector< T * > getComponents()
Returns all attached components of a type.
Definition game_object.hpp:109
virtual void onMouseEvent(const MouseEvent *e)
Mouse event hook.
Definition game_object.cpp:18
virtual void onDisable()
Called when the object becomes inactive.
Definition game_object.hpp:40
T * newComponent(Args &&... args)
Constructs a component in place and attaches it.
Definition game_object.hpp:128
void destroy()
Marks the object for destruction by the ObjectManager.
Definition game_object.hpp:45
Singleton registry that owns and updates all game objects.
Definition object_manager.hpp:17
Definition audiomanager.cpp:4
A mouse event carrying its type, button, position and scroll offset.
Definition mouse.hpp:37