5 #include "../Components/Component.h" 15 class GameObject :
public std::enable_shared_from_this<GameObject>
36 std::shared_ptr<T> component(
new T());
42 component->gameObject = shared_from_this();
60 for (
unsigned int i = 0; i <
components.size(); i++)
63 std::shared_ptr<T> component = std::dynamic_pointer_cast<T>(
components.at(i));
66 if (component.get() !=
nullptr)
74 return std::weak_ptr<T>();
82 static std::weak_ptr<GameObject>
create(std::string name);
88 void setName(std::string inName) { name = inName; }
GameObject(std::string name)
Constructs Application.
Definition: GameObject.cpp:3
std::vector< std::shared_ptr< Component > > components
A vector of components attached to the game object.
Definition: GameObject.h:139
std::weak_ptr< T > addComponent()
A template for adding components to the components vector.
Definition: GameObject.h:33
A class that handles the components.
Definition: Component.h:13
static std::weak_ptr< GameObject > create(std::string name)
A static function to create a game object.
Definition: GameObject.cpp:11
bool destroyed
A boolean for if the game object is destroyed.
Definition: GameObject.h:143
void setDestroyed(bool inDestroyed)
A function to set the componets destroyed boolean.
Definition: GameObject.h:120
std::string getName()
A function to get the name of the game object.
Definition: GameObject.h:94
virtual void destroy()
A virtual function for the game objects destroy.
Definition: GameObject.cpp:55
bool getDestroyed()
A function to get the componets destroyed boolean.
Definition: GameObject.h:126
void setName(std::string inName)
A function to set the name of the game object.
Definition: GameObject.h:88
std::string name
The name of the game object.
Definition: GameObject.h:137
virtual void render()
A virtual function for the game objects render.
Definition: GameObject.cpp:47
Contains details and functions for the game object.
Definition: GameObject.h:15
virtual ~GameObject()
Destructs GameObject (virtual).
Definition: GameObject.cpp:7
virtual void update()
A virtual function for the game objects update.
Definition: GameObject.cpp:28
Contains details and functions for the application.
Definition: Application.h:17
std::vector< std::string > componentIDs
A vector of the component ID's contained in the game object.
Definition: GameObject.h:141
std::weak_ptr< T > getComponent()
A template for getting a component from the components vector.
Definition: GameObject.h:57
bool checkForComponent(std::string id)
A function to check the if the game object has a specific componet.
Definition: GameObject.cpp:63
virtual void awake()
A virtual function for the game objects awake.
Definition: GameObject.cpp:20