summaryrefslogtreecommitdiff
path: root/engine-ocean/Game/GameObjects/GameObject.h
diff options
context:
space:
mode:
authorjjesswan <jessica_wan@brown.edu>2024-04-22 21:56:26 -0400
committerjjesswan <jessica_wan@brown.edu>2024-04-22 21:56:26 -0400
commita556b45abf18f1bd509daaf63b66b7d55e9fd291 (patch)
treebc9b8a2d184c12aee236e7f9f276a34b84ca552d /engine-ocean/Game/GameObjects/GameObject.h
parentcd7c76017a12bb548036571c1ff13e551369d06d (diff)
add engine version
Diffstat (limited to 'engine-ocean/Game/GameObjects/GameObject.h')
-rw-r--r--engine-ocean/Game/GameObjects/GameObject.h54
1 files changed, 54 insertions, 0 deletions
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 <memory>
+#include "Graphics/global.h"
+
+class GameObject
+{
+public:
+ GameObject();
+ ~GameObject(){
+ std::cout << "deleting" << std::endl;
+ }
+
+ template <typename T>
+ void addComponent(std::unique_ptr<T> &&component){
+ m_components.put<T>(std::forward<std::unique_ptr<T>>(component));
+ }
+
+ template <typename T>
+ bool hasComponent(){
+ return m_components.contains<T>();
+ }
+
+ template <class T>
+ T* getComponent(){
+ auto comp = m_components.find<T>();
+ assert(comp != m_components.end());
+ return static_cast<T*>(comp->second.get());
+ }
+
+ template <class T>
+ void removeComponent(){
+// auto comp = m_components.find<T>();
+// assert(comp != m_components.end());
+ m_components.remove<T>();
+ }
+
+
+
+private:
+ void setPlayerPos();
+ void makePlayer();
+
+ TypeMap<std::unique_ptr<Component>> m_components;
+ std::shared_ptr<Shape> m_object;
+ std::shared_ptr<ModelTransform> m_object_mt;
+
+};
+
+#endif // GAMEOBJECT_H