Level H Engine
Component.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 #include "../Core/GameObject.h"
5 
7 class GameObject;
8 class Application;
9 
13 class Component
14 {
16  friend class GameObject;
17 
18 public:
22  virtual ~Component();
23 
28  std::weak_ptr<GameObject> getGameObject();
29 
33  virtual void onAwake();
34 
38  virtual void onUpdate();
39 
43  virtual void onRender();
44 
48  virtual void onDestroy();
49 
54  void setDestroyed(bool inDestroyed) { destroyed = inDestroyed; }
55 
60  bool getDestroyed() { return destroyed; }
61 
66  std::string getID() { return id; }
67 
68 private:
70  std::weak_ptr<GameObject> gameObject;
72  bool destroyed;
73 
74 protected:
76  std::string id;
77 };
std::string getID()
A function to set the components type ID.
Definition: Component.h:66
A class that handles the components.
Definition: Component.h:13
virtual void onAwake()
A virtual function for the componets awake.
Definition: Component.cpp:12
virtual void onDestroy()
A virtual function for the componets destroy.
Definition: Component.cpp:27
virtual void onRender()
A virtual function for the componets render.
Definition: Component.cpp:22
Contains details and functions for the game object.
Definition: GameObject.h:15
std::weak_ptr< GameObject > gameObject
A weak pointer to the linked game object.
Definition: Component.h:70
void setDestroyed(bool inDestroyed)
A function to set the componets destroyed boolean.
Definition: Component.h:54
virtual void onUpdate()
A virtual function for the componets update.
Definition: Component.cpp:17
std::weak_ptr< GameObject > getGameObject()
A function to get the game object linked with the component.
Definition: Component.cpp:7
Contains details and functions for the application.
Definition: Application.h:17
std::string id
The ID of the component type.
Definition: Component.h:76
bool destroyed
A boolean for if the component has been destroyed.
Definition: Component.h:72
virtual ~Component()
A virtual destructor.
Definition: Component.cpp:3
bool getDestroyed()
A function to get the componets destroyed boolean.
Definition: Component.h:60