CmComponent.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #pragma once
  2. #include "CmPrerequisites.h"
  3. #include "CmGameObject.h"
  4. namespace BansheeEngine
  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. * @note Internal method.
  21. */
  22. virtual void update() = 0;
  23. /**
  24. * @brief Removes the component from parent SceneObject and deletes it. All
  25. * the references to this component will be marked as destroyed and you
  26. * will get an exception if you try to use them.
  27. */
  28. void destroy();
  29. protected:
  30. friend class SceneObject;
  31. Component(const HSceneObject& parent);
  32. virtual ~Component();
  33. virtual void onDestroyed() {}
  34. HSceneObject mParent;
  35. private:
  36. Component(const Component& other) { }
  37. /************************************************************************/
  38. /* RTTI */
  39. /************************************************************************/
  40. public:
  41. friend class ComponentRTTI;
  42. static RTTITypeBase* getRTTIStatic();
  43. virtual RTTITypeBase* getRTTI() const;
  44. protected:
  45. Component() {} // Serialization only
  46. };
  47. }