CmComponent.h 772 B

1234567891011121314151617181920212223242526272829
  1. #pragma once
  2. #include "CmPrerequisites.h"
  3. namespace CamelotEngine
  4. {
  5. class CM_EXPORT Component
  6. {
  7. public:
  8. GameObjectPtr getGameObject() const { return mParent.lock(); }
  9. // TODO - This shouldn't really be public since only GameObject should be allowed to add components.
  10. // But then I have a problem that all derived classes need to have GameObject as a friend class.
  11. Component(GameObjectPtr parent);
  12. virtual ~Component();
  13. protected:
  14. friend class GameObject;
  15. /**
  16. * @brief Destroys the Component and makes it unusable, without actually deleting it.
  17. *
  18. * This is an internal method that should only get called by GameObject.
  19. */
  20. void destroy();
  21. std::weak_ptr<GameObject> mParent;
  22. bool mIsDestroyed;
  23. };
  24. }