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.cpp | 27 ++++++++++++++ engine-ocean/Game/GameObjects/GameObject.h | 54 ++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 engine-ocean/Game/GameObjects/GameObject.cpp create mode 100644 engine-ocean/Game/GameObjects/GameObject.h (limited to 'engine-ocean/Game/GameObjects') diff --git a/engine-ocean/Game/GameObjects/GameObject.cpp b/engine-ocean/Game/GameObjects/GameObject.cpp new file mode 100644 index 0000000..0c7bce8 --- /dev/null +++ b/engine-ocean/Game/GameObjects/GameObject.cpp @@ -0,0 +1,27 @@ +#include "gameobject.h" +#include "Game/Components/DrawComponent.h" + +//GameObject::GameObject(std::shared_ptr object, std::shared_ptr object_mt) +//{ +// m_object = object; +// m_object_mt = object_mt; +//} + +GameObject::GameObject(){ + +} + +//GameObject::~GameObject(){ + +//} + +//void GameObject::addMaterial(std::string material_name, std::string material_filepath){ +// getComponent()->addMaterial("mouse", "/Users/jesswan/Desktop/cs1950u/cs1950u-jjesswan/Resources/Images/mouse.png"); +//} + +//void GameObject::addComps(){ +// addComponent(m_object); +// getComponent()->addMaterial("mouse", "/Users/jesswan/Desktop/cs1950u/cs1950u-jjesswan/Resources/Images/mouse.png"); +//} + + 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