CmComponent.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. private:
  33. Component(const Component& other) { }
  34. /************************************************************************/
  35. /* RTTI */
  36. /************************************************************************/
  37. public:
  38. friend class ComponentRTTI;
  39. static RTTITypeBase* getRTTIStatic();
  40. virtual RTTITypeBase* getRTTI() const;
  41. protected:
  42. Component() {} // Serialization only
  43. };
  44. }