BsComponent.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include "BsComponent.h"
  2. #include "BsSceneObject.h"
  3. #include "BsComponentRTTI.h"
  4. namespace BansheeEngine
  5. {
  6. Component::Component(const HSceneObject& parent)
  7. :mParent(parent)
  8. {
  9. setName("Component");
  10. }
  11. Component::~Component()
  12. {
  13. }
  14. bool Component::typeEquals(const Component& other)
  15. {
  16. return getRTTI()->getRTTIId() == other.getRTTI()->getRTTIId();
  17. }
  18. bool Component::calculateBounds(Bounds& bounds)
  19. {
  20. Vector3 position = SO()->getWorldPosition();
  21. bounds = Bounds(AABox(position, position), Sphere(position, 0.0f));
  22. return false;
  23. }
  24. void Component::destroy(bool immediate)
  25. {
  26. SO()->destroyComponent(this, immediate);
  27. }
  28. void Component::destroyInternal(GameObjectHandleBase& handle, bool immediate)
  29. {
  30. if (immediate)
  31. GameObjectManager::instance().unregisterObject(handle);
  32. else
  33. GameObjectManager::instance().queueForDestroy(handle);
  34. }
  35. RTTITypeBase* Component::getRTTIStatic()
  36. {
  37. return ComponentRTTI::instance();
  38. }
  39. RTTITypeBase* Component::getRTTI() const
  40. {
  41. return Component::getRTTIStatic();
  42. }
  43. }