From a556b45abf18f1bd509daaf63b66b7d55e9fd291 Mon Sep 17 00:00:00 2001 From: jjesswan Date: Mon, 22 Apr 2024 21:56:26 -0400 Subject: add engine version --- engine-ocean/Game/GameObjects/GameObject.h | 54 ++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 engine-ocean/Game/GameObjects/GameObject.h (limited to 'engine-ocean/Game/GameObjects/GameObject.h') diff --git a/engine-ocean/Game/GameObjects/GameObject.h b/engine-ocean/Game/GameObjects/GameObject.h new file mode 100644 index 0000000..a9ddbd7 --- /dev/null +++ b/engine-ocean/Game/GameObjects/GameObject.h @@ -0,0 +1,54 @@ +#ifndef GAMEOBJECT_H +#define GAMEOBJECT_H + + +#include "Game/Components/Component.h" +#include "Game/TypeMap.h" +#include +#include "Graphics/global.h" + +class GameObject +{ +public: + GameObject(); + ~GameObject(){ + std::cout << "deleting" << std::endl; + } + + template + void addComponent(std::unique_ptr &&component){ + m_components.put(std::forward>(component)); + } + + template + bool hasComponent(){ + return m_components.contains(); + } + + template + T* getComponent(){ + auto comp = m_components.find(); + assert(comp != m_components.end()); + return static_cast(comp->second.get()); + } + + template + void removeComponent(){ +// auto comp = m_components.find(); +// assert(comp != m_components.end()); + m_components.remove(); + } + + + +private: + void setPlayerPos(); + void makePlayer(); + + TypeMap> m_components; + std::shared_ptr m_object; + std::shared_ptr m_object_mt; + +}; + +#endif // GAMEOBJECT_H -- cgit v1.2.3-70-g09d2