CmComponent.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #pragma once
  2. #include "CmPrerequisites.h"
  3. #include "CmGameObject.h"
  4. namespace CamelotFramework
  5. {
  6. class CM_EXPORT Component : public GameObject
  7. {
  8. public:
  9. /**
  10. * @brief Returns the SceneObject this Component is assigned to.
  11. */
  12. HSceneObject sceneObject() const { return mParent; }
  13. /**
  14. * @brief Same as sceneObject(), just a shorter name.
  15. */
  16. HSceneObject SO() const { return sceneObject(); }
  17. /**
  18. * @brief Called once per frame on all components.
  19. */
  20. virtual void update() = 0;
  21. /**
  22. * @brief Removes the component from parent SceneObject and deletes it. All
  23. * the references to this component will be marked as destroyed and you
  24. * will get an exception if you try to use them.
  25. */
  26. void destroy();
  27. protected:
  28. friend class SceneObject;
  29. Component(const HSceneObject& parent);
  30. virtual ~Component();
  31. HSceneObject mParent;
  32. /************************************************************************/
  33. /* RTTI */
  34. /************************************************************************/
  35. public:
  36. friend class ComponentRTTI;
  37. static RTTITypeBase* getRTTIStatic();
  38. virtual RTTITypeBase* getRTTI() const;
  39. protected:
  40. Component() {} // Serialization only
  41. };
  42. }